blob: 3e301c8018efd249592e72d3356023db04d2ddef [file] [log] [blame]
drh66f4a062006-07-26 14:57:30 +00001# 2006 July 26
drhaa0fe802006-07-26 14:49:19 +00002#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
6# May you do good and not evil.
7# May you find forgiveness for yourself and forgive others.
8# May you share freely, never taking more than you give.
9#
10#***********************************************************************
drh66f4a062006-07-26 14:57:30 +000011# This file contains additional out-of-memory checks (see malloc.tcl)
12# added to expose a bug in out-of-memory handling for sqlite3_prepare16().
drhaa0fe802006-07-26 14:49:19 +000013#
drheee4c8c2008-02-18 22:24:57 +000014# $Id: malloc7.test,v 1.5 2008/02/18 22:24:58 drh Exp $
drhaa0fe802006-07-26 14:49:19 +000015
16set testdir [file dirname $argv0]
17source $testdir/tester.tcl
drheee4c8c2008-02-18 22:24:57 +000018source $testdir/malloc_common.tcl
drhaa0fe802006-07-26 14:49:19 +000019
20# Only run these tests if memory debugging is turned on.
21#
drheee4c8c2008-02-18 22:24:57 +000022if {!$MEMDEBUG} {
drh5a3032b2007-09-03 16:12:09 +000023 puts "Skipping malloc7 tests: not compiled with -DSQLITE_MEMDEBUG..."
drhaa0fe802006-07-26 14:49:19 +000024 finish_test
25 return
26}
27
drhaa0fe802006-07-26 14:49:19 +000028
drhed138fb2007-08-22 22:04:37 +000029do_malloc_test malloc7-1 -sqlprep {
drhaa0fe802006-07-26 14:49:19 +000030 CREATE TABLE t1(a,b,c,d);
31 CREATE INDEX i1 ON t1(b,c);
drhed138fb2007-08-22 22:04:37 +000032} -tclbody {
drhaa0fe802006-07-26 14:49:19 +000033 set sql16 [encoding convertto unicode "SELECT * FROM sqlite_master"]
34 append sql16 "\00\00"
35 set nbyte [string length $sql16]
drhed138fb2007-08-22 22:04:37 +000036 set ::STMT [sqlite3_prepare16 db $sql16 $nbyte DUMMY]
drhaa0fe802006-07-26 14:49:19 +000037 sqlite3_finalize $::STMT
38}
39
40
drhaa0fe802006-07-26 14:49:19 +000041# Ensure that no file descriptors were leaked.
42do_test malloc-99.X {
43 catch {db close}
44 set sqlite_open_file_count
45} {0}
46
47puts open-file-count=$sqlite_open_file_count
drhaa0fe802006-07-26 14:49:19 +000048finish_test