sl@0
|
1 |
# 2008 August 26
|
sl@0
|
2 |
#
|
sl@0
|
3 |
# The author disclaims copyright to this source code. In place of
|
sl@0
|
4 |
# a legal notice, here is a blessing:
|
sl@0
|
5 |
#
|
sl@0
|
6 |
# May you do good and not evil.
|
sl@0
|
7 |
# May you find forgiveness for yourself and forgive others.
|
sl@0
|
8 |
# May you share freely, never taking more than you give.
|
sl@0
|
9 |
#
|
sl@0
|
10 |
#***********************************************************************
|
sl@0
|
11 |
#
|
sl@0
|
12 |
# This file implements regression tests for SQLite library.
|
sl@0
|
13 |
# Specifically, it tests that bug #3334 has been fixed by the
|
sl@0
|
14 |
# addition of restriction (19) to the subquery flattener optimization.
|
sl@0
|
15 |
#
|
sl@0
|
16 |
# $Id: tkt3334.test,v 1.1 2008/08/26 12:56:14 drh Exp $
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
set testdir [file dirname $argv0]
|
sl@0
|
20 |
source $testdir/tester.tcl
|
sl@0
|
21 |
|
sl@0
|
22 |
do_test tkt3334-1.0 {
|
sl@0
|
23 |
execsql {
|
sl@0
|
24 |
CREATE TABLE t1(a,b);
|
sl@0
|
25 |
INSERT INTO t1 VALUES(1,934);
|
sl@0
|
26 |
INSERT INTO t1 VALUES(2,221);
|
sl@0
|
27 |
INSERT INTO t1 VALUES(1,372);
|
sl@0
|
28 |
INSERT INTO t1 VALUES(3,552);
|
sl@0
|
29 |
INSERT INTO t1 VALUES(1,719);
|
sl@0
|
30 |
INSERT INTO t1 VALUES(4,102);
|
sl@0
|
31 |
SELECT * FROM t1 ORDER BY b;
|
sl@0
|
32 |
}
|
sl@0
|
33 |
} {4 102 2 221 1 372 3 552 1 719 1 934}
|
sl@0
|
34 |
|
sl@0
|
35 |
do_test tkt3334-1.1 {
|
sl@0
|
36 |
execsql {
|
sl@0
|
37 |
SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 2) WHERE a=1;
|
sl@0
|
38 |
}
|
sl@0
|
39 |
} {}
|
sl@0
|
40 |
do_test tkt3334-1.2 {
|
sl@0
|
41 |
execsql {
|
sl@0
|
42 |
SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 2) WHERE a=1;
|
sl@0
|
43 |
}
|
sl@0
|
44 |
} {0}
|
sl@0
|
45 |
do_test tkt3334-1.3 {
|
sl@0
|
46 |
execsql {
|
sl@0
|
47 |
SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 3) WHERE a=1;
|
sl@0
|
48 |
}
|
sl@0
|
49 |
} {1}
|
sl@0
|
50 |
do_test tkt3334-1.4 {
|
sl@0
|
51 |
execsql {
|
sl@0
|
52 |
SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 3) WHERE a=1;
|
sl@0
|
53 |
}
|
sl@0
|
54 |
} {1}
|
sl@0
|
55 |
do_test tkt3334-1.5 {
|
sl@0
|
56 |
execsql {
|
sl@0
|
57 |
SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 99) WHERE a=1;
|
sl@0
|
58 |
}
|
sl@0
|
59 |
} {1 1 1}
|
sl@0
|
60 |
do_test tkt3334-1.6 {
|
sl@0
|
61 |
execsql {
|
sl@0
|
62 |
SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 99) WHERE a=1;
|
sl@0
|
63 |
}
|
sl@0
|
64 |
} {3}
|
sl@0
|
65 |
do_test tkt3334-1.7 {
|
sl@0
|
66 |
execsql {
|
sl@0
|
67 |
SELECT a FROM (SELECT a FROM t1 ORDER BY b) WHERE a=1;
|
sl@0
|
68 |
}
|
sl@0
|
69 |
} {1 1 1}
|
sl@0
|
70 |
do_test tkt3334-1.8 {
|
sl@0
|
71 |
execsql {
|
sl@0
|
72 |
SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b) WHERE a=1;
|
sl@0
|
73 |
}
|
sl@0
|
74 |
} {3}
|
sl@0
|
75 |
do_test tkt3334-1.9 {
|
sl@0
|
76 |
execsql {
|
sl@0
|
77 |
SELECT a FROM (SELECT a FROM t1) WHERE a=1;
|
sl@0
|
78 |
}
|
sl@0
|
79 |
} {1 1 1}
|
sl@0
|
80 |
do_test tkt3334-1.10 {
|
sl@0
|
81 |
execsql {
|
sl@0
|
82 |
SELECT count(*) FROM (SELECT a FROM t1) WHERE a=1;
|
sl@0
|
83 |
}
|
sl@0
|
84 |
} {3}
|