1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/mallocH.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,73 @@
1.4 +# 2008 August 01
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +#
1.15 +# This test script checks malloc failures in various obscure operations.
1.16 +#
1.17 +# $Id: mallocH.test,v 1.2 2008/08/01 20:10:09 drh Exp $
1.18 +
1.19 +set testdir [file dirname $argv0]
1.20 +source $testdir/tester.tcl
1.21 +source $testdir/malloc_common.tcl
1.22 +
1.23 +# Malloc failures in journaling of in-memory databases.
1.24 +#
1.25 +do_malloc_test mallocH-1 -tclprep {
1.26 + db close
1.27 + sqlite3 db :memory:
1.28 + db eval {
1.29 + CREATE TABLE t1(x UNIQUE, y);
1.30 + INSERT INTO t1 VALUES(1,2);
1.31 + }
1.32 +} -sqlbody {
1.33 + INSERT INTO t1 SELECT x+1, y+100 FROM t1;
1.34 +}
1.35 +
1.36 +# Malloc failures while parsing a CASE expression.
1.37 +#
1.38 +do_malloc_test mallocH-2 -sqlbody {
1.39 + SELECT CASE WHEN 1 THEN 1 END;
1.40 +}
1.41 +
1.42 +# Malloc failures while parsing a EXISTS(SELECT ...)
1.43 +#
1.44 +do_malloc_test mallocH-3 -sqlbody {
1.45 + SELECT 3+EXISTS(SELECT * FROM sqlite_master);
1.46 +}
1.47 +
1.48 +# Malloc failures within the replace() function.
1.49 +#
1.50 +do_malloc_test mallocH-3 -sqlbody {
1.51 + SELECT replace('ababa','a','xyzzy');
1.52 +}
1.53 +
1.54 +# Malloc failures during EXPLAIN.
1.55 +#
1.56 +ifcapable explain {
1.57 + do_malloc_test mallocH-4 -sqlprep {
1.58 + CREATE TABLE abc(a PRIMARY KEY, b, c);
1.59 + } -sqlbody {
1.60 + EXPLAIN SELECT * FROM abc AS t2 WHERE rowid=1;
1.61 + EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE rowid=1;
1.62 + }
1.63 +}
1.64 +
1.65 +# Malloc failure during integrity_check pragma.
1.66 +#
1.67 +do_malloc_test mallocH-5 -sqlprep {
1.68 + CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
1.69 + CREATE TABLE t2(x,y);
1.70 + INSERT INTO t1 VALUES(1,2);
1.71 + INSERT INTO t2 SELECT * FROM t1;
1.72 +} -sqlbody {
1.73 + PRAGMA integrity_check;
1.74 +}
1.75 +
1.76 +finish_test