sl@0: # 2008 August 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: # sl@0: # This file implements regression tests for SQLite library. sl@0: # Specifically, it tests that bug #3334 has been fixed by the sl@0: # addition of restriction (19) to the subquery flattener optimization. sl@0: # sl@0: # $Id: tkt3334.test,v 1.1 2008/08/26 12:56:14 drh Exp $ sl@0: sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: sl@0: do_test tkt3334-1.0 { sl@0: execsql { sl@0: CREATE TABLE t1(a,b); sl@0: INSERT INTO t1 VALUES(1,934); sl@0: INSERT INTO t1 VALUES(2,221); sl@0: INSERT INTO t1 VALUES(1,372); sl@0: INSERT INTO t1 VALUES(3,552); sl@0: INSERT INTO t1 VALUES(1,719); sl@0: INSERT INTO t1 VALUES(4,102); sl@0: SELECT * FROM t1 ORDER BY b; sl@0: } sl@0: } {4 102 2 221 1 372 3 552 1 719 1 934} sl@0: sl@0: do_test tkt3334-1.1 { sl@0: execsql { sl@0: SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 2) WHERE a=1; sl@0: } sl@0: } {} sl@0: do_test tkt3334-1.2 { sl@0: execsql { sl@0: SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 2) WHERE a=1; sl@0: } sl@0: } {0} sl@0: do_test tkt3334-1.3 { sl@0: execsql { sl@0: SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 3) WHERE a=1; sl@0: } sl@0: } {1} sl@0: do_test tkt3334-1.4 { sl@0: execsql { sl@0: SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 3) WHERE a=1; sl@0: } sl@0: } {1} sl@0: do_test tkt3334-1.5 { sl@0: execsql { sl@0: SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 99) WHERE a=1; sl@0: } sl@0: } {1 1 1} sl@0: do_test tkt3334-1.6 { sl@0: execsql { sl@0: SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 99) WHERE a=1; sl@0: } sl@0: } {3} sl@0: do_test tkt3334-1.7 { sl@0: execsql { sl@0: SELECT a FROM (SELECT a FROM t1 ORDER BY b) WHERE a=1; sl@0: } sl@0: } {1 1 1} sl@0: do_test tkt3334-1.8 { sl@0: execsql { sl@0: SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b) WHERE a=1; sl@0: } sl@0: } {3} sl@0: do_test tkt3334-1.9 { sl@0: execsql { sl@0: SELECT a FROM (SELECT a FROM t1) WHERE a=1; sl@0: } sl@0: } {1 1 1} sl@0: do_test tkt3334-1.10 { sl@0: execsql { sl@0: SELECT count(*) FROM (SELECT a FROM t1) WHERE a=1; sl@0: } sl@0: } {3}