sl@0: # 2008 August 01 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # sl@0: # This test script checks malloc failures in various obscure operations. sl@0: # sl@0: # $Id: mallocH.test,v 1.2 2008/08/01 20:10:09 drh Exp $ sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: source $testdir/malloc_common.tcl sl@0: sl@0: # Malloc failures in journaling of in-memory databases. sl@0: # sl@0: do_malloc_test mallocH-1 -tclprep { sl@0: db close sl@0: sqlite3 db :memory: sl@0: db eval { sl@0: CREATE TABLE t1(x UNIQUE, y); sl@0: INSERT INTO t1 VALUES(1,2); sl@0: } sl@0: } -sqlbody { sl@0: INSERT INTO t1 SELECT x+1, y+100 FROM t1; sl@0: } sl@0: sl@0: # Malloc failures while parsing a CASE expression. sl@0: # sl@0: do_malloc_test mallocH-2 -sqlbody { sl@0: SELECT CASE WHEN 1 THEN 1 END; sl@0: } sl@0: sl@0: # Malloc failures while parsing a EXISTS(SELECT ...) sl@0: # sl@0: do_malloc_test mallocH-3 -sqlbody { sl@0: SELECT 3+EXISTS(SELECT * FROM sqlite_master); sl@0: } sl@0: sl@0: # Malloc failures within the replace() function. sl@0: # sl@0: do_malloc_test mallocH-3 -sqlbody { sl@0: SELECT replace('ababa','a','xyzzy'); sl@0: } sl@0: sl@0: # Malloc failures during EXPLAIN. sl@0: # sl@0: ifcapable explain { sl@0: do_malloc_test mallocH-4 -sqlprep { sl@0: CREATE TABLE abc(a PRIMARY KEY, b, c); sl@0: } -sqlbody { sl@0: EXPLAIN SELECT * FROM abc AS t2 WHERE rowid=1; sl@0: EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE rowid=1; sl@0: } sl@0: } sl@0: sl@0: # Malloc failure during integrity_check pragma. sl@0: # sl@0: do_malloc_test mallocH-5 -sqlprep { sl@0: CREATE TABLE t1(a PRIMARY KEY, b UNIQUE); sl@0: CREATE TABLE t2(x,y); sl@0: INSERT INTO t1 VALUES(1,2); sl@0: INSERT INTO t2 SELECT * FROM t1; sl@0: } -sqlbody { sl@0: PRAGMA integrity_check; sl@0: } sl@0: sl@0: finish_test