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 #***********************************************************************
11 # This file implements regression tests for SQLite library. The focus
12 # is testing of where.c. More specifically, the focus is on handling OOM
13 # errors within the code that optimizes WHERE clauses that feature the
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
20 source $testdir/malloc_common.tcl
22 set testprefix wherefault
24 do_malloc_test 1 -sqlprep {
25 CREATE TABLE t1(a, b, c);
26 CREATE INDEX i1 ON t1(a);
27 CREATE INDEX i2 ON t1(b);
31 a = 2 OR b = 'three' OR a = 4 OR b = 'five' OR a = 6 OR
32 b = 'seven' OR a = 8 OR b = 'nine' OR a = 10
35 SELECT c FROM t1 WHERE
36 a = 1 OR a = 2 OR a = 3 OR a = 4 OR a = 5 OR a = 6;
38 SELECT c FROM t1 WHERE
39 a BETWEEN 1 AND 3 AND b < 5 AND b > 2 AND c = 4;
42 do_malloc_test 2 -tclprep {
45 CREATE TABLE t1(a, b, c);
46 CREATE INDEX i1 ON t1(a);
47 CREATE INDEX i2 ON t1(b);
49 for {set i 0} {$i < 1000} {incr i} {
52 db eval { INSERT INTO t1 VALUES($i, $ii, $iii) }
56 SELECT count(*) FROM t1 WHERE a BETWEEN 5 AND 995 OR b BETWEEN 5 AND 900000;