AryaWu/sqlite
0
1# 2008 August 012#3# The author disclaims copyright to this source code. In place of4# 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#***********************************************************************11#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 $15 16set testdir [file dirname $argv0]17source $testdir/tester.tcl18source $testdir/malloc_common.tcl19 20# Malloc failures in journaling of in-memory databases.21#22do_malloc_test mallocH-1 -tclprep {23 db close24 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;31}32 33# Malloc failures while parsing a CASE expression.34#35do_malloc_test mallocH-2 -sqlbody {36 SELECT CASE WHEN 1 THEN 1 END;37}38 39# Malloc failures while parsing a EXISTS(SELECT ...)40#41do_malloc_test mallocH-3 -sqlbody {42 SELECT 3+EXISTS(SELECT * FROM sqlite_master);43}44 45# Malloc failures within the replace() function.46#47do_malloc_test mallocH-3 -sqlbody {48 SELECT replace('ababa','a','xyzzy');49}50 51# Malloc failures during EXPLAIN.52#53ifcapable 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 }60}61 62# Malloc failure during integrity_check pragma.63#64do_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;71}72 73finish_test74 