1# 2012 December 19 2# 3# The author disclaims copyright to this source code. In place of 4# 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# This file implements regression tests for SQLite library. Specifically, 12# it tests that ticket [a7b7803e8d1e8699cd8a460a38133b98892d2e17] has 13# been fixed. 14# 15 16set testdir [file dirname $argv0] 17source $testdir/tester.tcl 18source $testdir/lock_common.tcl 19source $testdir/malloc_common.tcl 20 21do_test tkt-a7b7803e.1 { 22 db eval { 23 CREATE TABLE t1(a,b); 24 INSERT INTO t1 VALUES(0,'first'),(99,'fuzzy'); 25 SELECT (t1.a==0) AS x, b 26 FROM t1 27 WHERE a=0 OR x; 28 } 29} {1 first} 30do_test tkt-a7b7803e.2 { 31 db eval { 32 SELECT a, (t1.b='fuzzy') AS x 33 FROM t1 34 WHERE x 35 } 36} {99 1} 37do_test tkt-a7b7803e.3 { 38 db eval { 39 SELECT (a=99) AS x, (t1.b='fuzzy') AS y, * 40 FROM t1 41 WHERE x AND y 42 } 43} {1 1 99 fuzzy} 44do_test tkt-a7b7803e.4 { 45 db eval { 46 SELECT (a=99) AS x, (t1.b='first') AS y, * 47 FROM t1 48 WHERE x OR y 49 ORDER BY a 50 } 51} {0 1 0 first 1 0 99 fuzzy} 52do_test tkt-a7b7803e.5 { 53 db eval { 54 SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b 55 FROM t1 M, t1 N 56 WHERE x OR y 57 ORDER BY M.a, N.a 58 } 59} {0 first 1 first 1 fuzzy 1 first 1 fuzzy 0 fuzzy} 60do_test tkt-a7b7803e.6 { 61 db eval { 62 SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b 63 FROM t1 M, t1 N 64 WHERE x AND y 65 ORDER BY M.a, N.a 66 } 67} {1 fuzzy 1 first} 68do_test tkt-a7b7803e.7 { 69 db eval { 70 SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b 71 FROM t1 M JOIN t1 N ON x AND y 72 ORDER BY M.a, N.a 73 } 74} {1 fuzzy 1 first} 75do_test tkt-a7b7803e.8 { 76 db eval { 77 SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b 78 FROM t1 M JOIN t1 N ON x 79 ORDER BY M.a, N.a 80 } 81} {1 fuzzy 1 first 1 fuzzy 0 fuzzy} 82 83 84finish_test 85