2009-01-07 23:58:57 +03:00
|
|
|
# 2008 August 01
|
|
|
|
#
|
|
|
|
# The author disclaims copyright to this source code. In place of
|
|
|
|
# a legal notice, here is a blessing:
|
|
|
|
#
|
|
|
|
# May you do good and not evil.
|
|
|
|
# May you find forgiveness for yourself and forgive others.
|
|
|
|
# May you share freely, never taking more than you give.
|
|
|
|
#
|
|
|
|
#***********************************************************************
|
|
|
|
#
|
|
|
|
# This test script checks malloc failures in WHERE clause analysis.
|
|
|
|
#
|
2009-01-09 00:00:02 +03:00
|
|
|
# $Id: mallocK.test,v 1.3 2009/01/08 21:00:03 drh Exp $
|
2009-01-07 23:58:57 +03:00
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
source $testdir/malloc_common.tcl
|
|
|
|
|
|
|
|
set sql {SELECT * FROM t1, t2 WHERE (a=1 OR a=2)}
|
|
|
|
for {set x 1} {$x<5} {incr x} {
|
|
|
|
append sql " AND b=y"
|
|
|
|
do_malloc_test mallocK-1.$x -sqlbody $sql -sqlprep {
|
|
|
|
CREATE TABLE t1(a,b);
|
|
|
|
CREATE TABLE t2(x,y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-09 00:00:02 +03:00
|
|
|
set sql {SELECT * FROM t1 WHERE a GLOB 'xyz*' AND (a=1 OR a=2)}
|
2009-01-07 23:58:57 +03:00
|
|
|
for {set x 1} {$x<5} {incr x} {
|
|
|
|
append sql " AND b!=$x"
|
|
|
|
do_malloc_test mallocK-2.$x -sqlbody $sql -sqlprep {
|
|
|
|
CREATE TABLE t1(a,b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set sql {SELECT * FROM t1 WHERE a BETWEEN 5 AND 10}
|
|
|
|
for {set x 1} {$x<5} {incr x} {
|
2009-01-09 00:00:02 +03:00
|
|
|
append sql " AND b=$x"
|
2009-01-07 23:58:57 +03:00
|
|
|
do_malloc_test mallocK-3.$x -sqlbody $sql -sqlprep {
|
|
|
|
CREATE TABLE t1(a,b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-09 00:00:02 +03:00
|
|
|
set sql {SELECT * FROM t1 WHERE b=0}
|
|
|
|
for {set x 1} {$x<5} {incr x} {
|
|
|
|
set term "(b=$x"
|
|
|
|
for {set y 0} {$y<$x} {incr y} {
|
|
|
|
append term " AND a!=$y"
|
|
|
|
}
|
|
|
|
append sql " OR $term)"
|
|
|
|
do_malloc_test mallocK-4.$x -sqlbody $sql -sqlprep {
|
|
|
|
CREATE TABLE t1(a,b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-07 23:58:57 +03:00
|
|
|
ifcapable vtab {
|
|
|
|
set sql {SELECT * FROM t2 WHERE a MATCH 'xyz'}
|
|
|
|
for {set x 1} {$x<5} {incr x} {
|
|
|
|
append sql " AND b!=$x"
|
2009-01-09 00:00:02 +03:00
|
|
|
do_malloc_test mallocK-5.$x -sqlbody $sql -tclprep {
|
2009-01-07 23:58:57 +03:00
|
|
|
register_echo_module [sqlite3_connection_pointer db]
|
|
|
|
db eval {
|
|
|
|
CREATE TABLE t1(a,b);
|
|
|
|
CREATE VIRTUAL TABLE t2 USING echo(t1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
finish_test
|