Merge trunk into this branch.
[sqlite.git] / test / mallocH.test
blob7017b381ab1d8595648ab3be0d28423072878350
1 # 2008 August 01
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
12 # This test script checks malloc failures in various obscure operations.
13
14 # $Id: mallocH.test,v 1.2 2008/08/01 20:10:09 drh Exp $
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
18 source $testdir/malloc_common.tcl
20 # Malloc failures in journaling of in-memory databases.
22 do_malloc_test mallocH-1 -tclprep {
23   db close
24   sqlite3 db :memory:
25   db eval {
26     CREATE TABLE t1(x UNIQUE, y);
27     INSERT INTO t1 VALUES(1,2);
28   }
29 } -sqlbody {
30   INSERT INTO t1 SELECT x+1, y+100 FROM t1;
33 # Malloc failures while parsing a CASE expression.
35 do_malloc_test mallocH-2 -sqlbody {
36    SELECT CASE WHEN 1 THEN 1 END;
39 # Malloc failures while parsing a EXISTS(SELECT ...)
41 do_malloc_test mallocH-3 -sqlbody {
42    SELECT 3+EXISTS(SELECT * FROM sqlite_master);
45 # Malloc failures within the replace() function.
47 do_malloc_test mallocH-3 -sqlbody {
48    SELECT replace('ababa','a','xyzzy');
51 # Malloc failures during EXPLAIN.
53 ifcapable explain {
54   do_malloc_test mallocH-4 -sqlprep {
55      CREATE TABLE abc(a PRIMARY KEY, b, c);
56   } -sqlbody {
57      EXPLAIN SELECT * FROM abc AS t2 WHERE rowid=1;
58      EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE rowid=1;
59   }
62 # Malloc failure during integrity_check pragma.
64 do_malloc_test mallocH-5 -sqlprep {
65    CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
66    CREATE TABLE t2(x,y);
67    INSERT INTO t1 VALUES(1,2);
68    INSERT INTO t2 SELECT * FROM t1;
69 } -sqlbody {
70    PRAGMA integrity_check;
73 finish_test