mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Fix for ticket #22: In the code generator for compound SELECT statements, take
care not to generate column name headers if the output is an intermediate table. Otherwise the column headers are not generated correctly if a compound SELECT statement appears as an expression in part of the WHERE clause. (CVS 543) FossilOrigin-Name: a06d9acdd5af0dc69b3a4d024de082631254aead
This commit is contained in:
@ -12,7 +12,7 @@
|
||||
# focus of this file is testing UNION, INTERSECT and EXCEPT operators
|
||||
# in SELECT statements.
|
||||
#
|
||||
# $Id: select4.test,v 1.4 2001/09/16 00:13:28 drh Exp $
|
||||
# $Id: select4.test,v 1.5 2002/04/23 17:10:19 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -249,4 +249,33 @@ do_test select4-6.2 {
|
||||
}
|
||||
} {0 1 1 1 2 2 3 4 3 7 4 8 5 15}
|
||||
|
||||
# Make sure column names are correct when a compound select appears as
|
||||
# an expression in the WHERE clause.
|
||||
#
|
||||
do_test select4-7.1 {
|
||||
execsql {
|
||||
CREATE TABLE t2 AS SELECT log AS 'x', count(*) AS 'y' FROM t1 GROUP BY log;
|
||||
SELECT * FROM t2 ORDER BY x;
|
||||
}
|
||||
} {0 1 1 1 2 2 3 4 4 8 5 15}
|
||||
do_test select4-7.2 {
|
||||
execsql2 {
|
||||
SELECT * FROM t1 WHERE n IN (SELECT n FROM t1 INTERSECT SELECT x FROM t2)
|
||||
ORDER BY n
|
||||
}
|
||||
} {n 1 log 0 n 2 log 1 n 3 log 2 n 4 log 2 n 5 log 3}
|
||||
do_test select4-7.3 {
|
||||
execsql2 {
|
||||
SELECT * FROM t1 WHERE n IN (SELECT n FROM t1 EXCEPT SELECT x FROM t2)
|
||||
ORDER BY n LIMIT 2
|
||||
}
|
||||
} {n 6 log 3 n 7 log 3}
|
||||
do_test select4-7.4 {
|
||||
execsql2 {
|
||||
SELECT * FROM t1 WHERE n IN (SELECT n FROM t1 UNION SELECT x FROM t2)
|
||||
ORDER BY n LIMIT 2
|
||||
}
|
||||
} {n 1 log 0 n 2 log 1}
|
||||
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user