1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Fix a bug in subquery generation when the subquery is a compound select.

Also added new tests to cover this case. (CVS 435)

FossilOrigin-Name: aaf7fd4cef04d3d70a0444aad1b606bfc663c3e8
This commit is contained in:
drh
2002-03-23 00:31:29 +00:00
parent 545c23dc42
commit 1cc3d75f69
7 changed files with 76 additions and 21 deletions

View File

@ -12,7 +12,7 @@
# focus of this file is testing SELECT statements that contain
# subqueries in their FROM clause.
#
# $Id: select6.test,v 1.7 2002/03/13 18:54:09 drh Exp $
# $Id: select6.test,v 1.8 2002/03/23 00:31:29 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -292,4 +292,48 @@ do_test select6-5.2 {
}
} {8 5 8 9 6 9 10 7 10}
# Tests of compound sub-selects
#
do_test select5-6.1 {
execsql {
DELETE FROM t1 WHERE x>4;
SELECT * FROM t1
}
} {1 1 2 2 3 2 4 3}
do_test select6-6.2 {
execsql {
SELECT * FROM (
SELECT x AS 'a' FROM t1 UNION ALL SELECT x+10 AS 'a' FROM t1
) ORDER BY a;
}
} {1 2 3 4 11 12 13 14}
do_test select6-6.3 {
execsql {
SELECT * FROM (
SELECT x AS 'a' FROM t1 UNION ALL SELECT x+1 AS 'a' FROM t1
) ORDER BY a;
}
} {1 2 2 3 3 4 4 5}
do_test select6-6.4 {
execsql {
SELECT * FROM (
SELECT x AS 'a' FROM t1 UNION SELECT x+1 AS 'a' FROM t1
) ORDER BY a;
}
} {1 2 3 4 5}
do_test select6-6.5 {
execsql {
SELECT * FROM (
SELECT x AS 'a' FROM t1 INTERSECT SELECT x+1 AS 'a' FROM t1
) ORDER BY a;
}
} {2 3 4}
do_test select6-6.6 {
execsql {
SELECT * FROM (
SELECT x AS 'a' FROM t1 EXCEPT SELECT x*2 AS 'a' FROM t1
) ORDER BY a;
}
} {1 3}
finish_test