blob: 5473ab4cf8f298bed06d54742bb325c94e5cb071 [file] [log] [blame]
drh229cf702008-08-26 12:56:14 +00001# 2008 August 26
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#
12# This file implements regression tests for SQLite library.
13# Specifically, it tests that bug #3334 has been fixed by the
14# addition of restriction (19) to the subquery flattener optimization.
15#
16# $Id: tkt3334.test,v 1.1 2008/08/26 12:56:14 drh Exp $
17
18
19set testdir [file dirname $argv0]
20source $testdir/tester.tcl
21
22do_test tkt3334-1.0 {
23 execsql {
24 CREATE TABLE t1(a,b);
25 INSERT INTO t1 VALUES(1,934);
26 INSERT INTO t1 VALUES(2,221);
27 INSERT INTO t1 VALUES(1,372);
28 INSERT INTO t1 VALUES(3,552);
29 INSERT INTO t1 VALUES(1,719);
30 INSERT INTO t1 VALUES(4,102);
31 SELECT * FROM t1 ORDER BY b;
32 }
33} {4 102 2 221 1 372 3 552 1 719 1 934}
34
35do_test tkt3334-1.1 {
36 execsql {
37 SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 2) WHERE a=1;
38 }
39} {}
40do_test tkt3334-1.2 {
41 execsql {
42 SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 2) WHERE a=1;
43 }
44} {0}
45do_test tkt3334-1.3 {
46 execsql {
47 SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 3) WHERE a=1;
48 }
49} {1}
50do_test tkt3334-1.4 {
51 execsql {
52 SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 3) WHERE a=1;
53 }
54} {1}
55do_test tkt3334-1.5 {
56 execsql {
57 SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 99) WHERE a=1;
58 }
59} {1 1 1}
60do_test tkt3334-1.6 {
61 execsql {
62 SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 99) WHERE a=1;
63 }
64} {3}
65do_test tkt3334-1.7 {
66 execsql {
67 SELECT a FROM (SELECT a FROM t1 ORDER BY b) WHERE a=1;
68 }
69} {1 1 1}
70do_test tkt3334-1.8 {
71 execsql {
72 SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b) WHERE a=1;
73 }
74} {3}
75do_test tkt3334-1.9 {
76 execsql {
77 SELECT a FROM (SELECT a FROM t1) WHERE a=1;
78 }
79} {1 1 1}
80do_test tkt3334-1.10 {
81 execsql {
82 SELECT count(*) FROM (SELECT a FROM t1) WHERE a=1;
83 }
84} {3}