sl@0: # 2005 November 26 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # This file implements regression tests for SQLite library. sl@0: # sl@0: # This file implements tests to verify that ticket #1537 is sl@0: # fixed. sl@0: # sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: sl@0: do_test tkt1537-1.1 { sl@0: execsql { sl@0: CREATE TABLE t1(id, a1, a2); sl@0: INSERT INTO t1 VALUES(1, NULL, NULL); sl@0: INSERT INTO t1 VALUES(2, 1, 3); sl@0: CREATE TABLE t2(id, b); sl@0: INSERT INTO t2 VALUES(3, 1); sl@0: INSERT INTO t2 VALUES(4, NULL); sl@0: SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=+b; sl@0: } sl@0: } {1 {} {} {} {} 2 1 3 3 1} sl@0: do_test tkt1537-1.2 { sl@0: execsql { sl@0: SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=b; sl@0: } sl@0: } {1 {} {} {} {} 2 1 3 3 1} sl@0: do_test tkt1537-1.3 { sl@0: execsql { sl@0: SELECT * FROM t2 LEFT JOIN t1 ON a1=b OR a2=b; sl@0: } sl@0: } {3 1 2 1 3 4 {} {} {} {}} sl@0: ifcapable subquery { sl@0: do_test tkt1537-1.4 { sl@0: execsql { sl@0: SELECT * FROM t1 LEFT JOIN t2 ON b IN (a1,a2); sl@0: } sl@0: } {1 {} {} {} {} 2 1 3 3 1} sl@0: do_test tkt1537-1.5 { sl@0: execsql { sl@0: SELECT * FROM t2 LEFT JOIN t1 ON b IN (a2,a1); sl@0: } sl@0: } {3 1 2 1 3 4 {} {} {} {}} sl@0: } sl@0: do_test tkt1537-1.6 { sl@0: execsql { sl@0: CREATE INDEX t1a1 ON t1(a1); sl@0: CREATE INDEX t1a2 ON t1(a2); sl@0: CREATE INDEX t2b ON t2(b); sl@0: SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=b; sl@0: } sl@0: } {1 {} {} {} {} 2 1 3 3 1} sl@0: do_test tkt1537-1.7 { sl@0: execsql { sl@0: SELECT * FROM t2 LEFT JOIN t1 ON a1=b OR a2=b; sl@0: } sl@0: } {3 1 2 1 3 4 {} {} {} {}} sl@0: sl@0: ifcapable subquery { sl@0: do_test tkt1537-1.8 { sl@0: execsql { sl@0: SELECT * FROM t1 LEFT JOIN t2 ON b IN (a1,a2); sl@0: } sl@0: } {1 {} {} {} {} 2 1 3 3 1} sl@0: do_test tkt1537-1.9 { sl@0: execsql { sl@0: SELECT * FROM t2 LEFT JOIN t1 ON b IN (a2,a1); sl@0: } sl@0: } {3 1 2 1 3 4 {} {} {} {}} sl@0: } sl@0: sl@0: execsql { sl@0: DROP INDEX t1a1; sl@0: DROP INDEX t1a2; sl@0: DROP INDEX t2b; sl@0: } sl@0: sl@0: do_test tkt1537-2.1 { sl@0: execsql { sl@0: SELECT * FROM t1 LEFT JOIN t2 ON b BETWEEN a1 AND a2; sl@0: } sl@0: } {1 {} {} {} {} 2 1 3 3 1} sl@0: do_test tkt1537-2.2 { sl@0: execsql { sl@0: CREATE INDEX t2b ON t2(b); sl@0: SELECT * FROM t1 LEFT JOIN t2 ON b BETWEEN a1 AND a2; sl@0: } sl@0: } {1 {} {} {} {} 2 1 3 3 1} sl@0: do_test tkt1537-2.3 { sl@0: execsql { sl@0: SELECT * FROM t2 LEFT JOIN t1 ON b BETWEEN a1 AND a2; sl@0: } sl@0: } {3 1 2 1 3 4 {} {} {} {}} sl@0: do_test tkt1537-2.4 { sl@0: execsql { sl@0: CREATE INDEX t1a1 ON t1(a1); sl@0: CREATE INDEX t1a2 ON t1(a2); sl@0: SELECT * FROM t2 LEFT JOIN t1 ON b BETWEEN a1 AND a2; sl@0: } sl@0: } {3 1 2 1 3 4 {} {} {} {}} sl@0: sl@0: do_test tkt1537-3.1 { sl@0: execsql { sl@0: SELECT * FROM t1 LEFT JOIN t2 ON b GLOB 'abc*' WHERE t1.id=1; sl@0: } sl@0: } {1 {} {} {} {}} sl@0: do_test tkt1537-3.2 { sl@0: execsql { sl@0: SELECT * FROM t2 LEFT JOIN t1 ON a1 GLOB 'abc*' WHERE t2.id=3; sl@0: } sl@0: } {3 1 {} {} {}} sl@0: sl@0: sl@0: finish_test