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
12 # focus of this file is testing NULL comparisons in the WHERE clause.
15 # $Id: where5.test,v 1.2 2007/06/08 08:43:10 drh Exp $
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
20 # Build some test data
24 CREATE TABLE t1(x TEXT);
25 CREATE TABLE t2(x INTEGER);
26 CREATE TABLE t3(x INTEGER PRIMARY KEY);
27 INSERT INTO t1 VALUES(-1);
28 INSERT INTO t1 VALUES(0);
29 INSERT INTO t1 VALUES(1);
30 INSERT INTO t2 SELECT * FROM t1;
31 INSERT INTO t3 SELECT * FROM t2;
34 SELECT * FROM t1 WHERE x<0
39 SELECT * FROM t1 WHERE x<=0
44 SELECT * FROM t1 WHERE x=0
49 SELECT * FROM t1 WHERE x>=0
54 SELECT * FROM t1 WHERE x>0
59 SELECT * FROM t1 WHERE x<>0
64 SELECT * FROM t1 WHERE x<NULL
69 SELECT * FROM t1 WHERE x<=NULL
74 SELECT * FROM t1 WHERE x=NULL
79 SELECT * FROM t1 WHERE x>=NULL
84 SELECT * FROM t1 WHERE x>NULL
89 SELECT * FROM t1 WHERE x!=NULL
94 SELECT * FROM t1 WHERE x IS NULL
99 SELECT * FROM t1 WHERE x IS NOT NULL
106 SELECT * FROM t2 WHERE x<0
111 SELECT * FROM t2 WHERE x<=0
116 SELECT * FROM t2 WHERE x=0
121 SELECT * FROM t2 WHERE x>=0
126 SELECT * FROM t2 WHERE x>0
131 SELECT * FROM t2 WHERE x<>0
136 SELECT * FROM t2 WHERE x<NULL
141 SELECT * FROM t2 WHERE x<=NULL
146 SELECT * FROM t2 WHERE x=NULL
151 SELECT * FROM t2 WHERE x>=NULL
154 do_test where5-2.10 {
156 SELECT * FROM t2 WHERE x>NULL
159 do_test where5-2.11 {
161 SELECT * FROM t2 WHERE x!=NULL
164 do_test where5-2.12 {
166 SELECT * FROM t2 WHERE x IS NULL
169 do_test where5-2.13 {
171 SELECT * FROM t2 WHERE x IS NOT NULL
178 SELECT * FROM t3 WHERE x<0
183 SELECT * FROM t3 WHERE x<=0
188 SELECT * FROM t3 WHERE x=0
193 SELECT * FROM t3 WHERE x>=0
198 SELECT * FROM t3 WHERE x>0
203 SELECT * FROM t3 WHERE x<>0
208 SELECT * FROM t3 WHERE x<NULL
213 SELECT * FROM t3 WHERE x<=NULL
218 SELECT * FROM t3 WHERE x=NULL
223 SELECT * FROM t3 WHERE x>=NULL
226 do_test where5-3.10 {
228 SELECT * FROM t3 WHERE x>NULL
231 do_test where5-3.11 {
233 SELECT * FROM t3 WHERE x!=NULL
236 do_test where5-3.12 {
238 SELECT * FROM t3 WHERE x IS NULL
241 do_test where5-3.13 {
243 SELECT * FROM t3 WHERE x IS NOT NULL
249 SELECT x<NULL FROM t3
254 SELECT x<=NULL FROM t3
259 SELECT x==NULL FROM t3
264 SELECT x>NULL FROM t3
269 SELECT x>=NULL FROM t3
274 SELECT x!=NULL FROM t3
279 SELECT x IS NULL FROM t3
284 SELECT x IS NOT NULL FROM t3