Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: third_party/sqlite/src/test/select4.test

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/test/schema4.test ('k') | third_party/sqlite/src/test/select7.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2001 September 15 1 # 2001 September 15
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 # This file implements regression tests for SQLite library. The 11 # This file implements regression tests for SQLite library. The
12 # focus of this file is testing UNION, INTERSECT and EXCEPT operators 12 # focus of this file is testing UNION, INTERSECT and EXCEPT operators
13 # in SELECT statements. 13 # in SELECT statements.
14 # 14 #
15 # $Id: select4.test,v 1.30 2009/04/16 00:24:24 drh Exp $
16 15
17 set testdir [file dirname $argv0] 16 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl 17 source $testdir/tester.tcl
19 18
20 # Most tests in this file depend on compound-select. But there are a couple 19 # Most tests in this file depend on compound-select. But there are a couple
21 # right at the end that test DISTINCT, so we cannot omit the entire file. 20 # right at the end that test DISTINCT, so we cannot omit the entire file.
22 # 21 #
23 ifcapable compound { 22 ifcapable compound {
24 23
25 # Build some test data 24 # Build some test data
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 do_execsql_test select4-14.15 { 908 do_execsql_test select4-14.15 {
910 SELECT * FROM (SELECT 123), (SELECT 456) ON likely(0 OR 1) OR 0; 909 SELECT * FROM (SELECT 123), (SELECT 456) ON likely(0 OR 1) OR 0;
911 } {123 456} 910 } {123 456}
912 do_execsql_test select4-14.16 { 911 do_execsql_test select4-14.16 {
913 VALUES(1),(2),(3),(4) UNION ALL SELECT 5 LIMIT 99; 912 VALUES(1),(2),(3),(4) UNION ALL SELECT 5 LIMIT 99;
914 } {1 2 3 4 5} 913 } {1 2 3 4 5}
915 do_execsql_test select4-14.17 { 914 do_execsql_test select4-14.17 {
916 VALUES(1),(2),(3),(4) UNION ALL SELECT 5 LIMIT 3; 915 VALUES(1),(2),(3),(4) UNION ALL SELECT 5 LIMIT 3;
917 } {1 2 3} 916 } {1 2 3}
918 917
918 # Ticket https://www.sqlite.org/src/info/d06a25c84454a372
919 # Incorrect answer due to two co-routines using the same registers and expecting
920 # those register values to be preserved across a Yield.
921 #
922 do_execsql_test select4-15.1 {
923 DROP TABLE IF EXISTS tx;
924 CREATE TABLE tx(id INTEGER PRIMARY KEY, a, b);
925 INSERT INTO tx(a,b) VALUES(33,456);
926 INSERT INTO tx(a,b) VALUES(33,789);
927
928 SELECT DISTINCT t0.id, t0.a, t0.b
929 FROM tx AS t0, tx AS t1
930 WHERE t0.a=t1.a AND t1.a=33 AND t0.b=456
931 UNION
932 SELECT DISTINCT t0.id, t0.a, t0.b
933 FROM tx AS t0, tx AS t1
934 WHERE t0.a=t1.a AND t1.a=33 AND t0.b=789
935 ORDER BY 1;
936 } {1 33 456 2 33 789}
937
938 # Enhancement (2016-03-15): Use a co-routine for subqueries if the
939 # subquery is guaranteed to be the outer-most query
940 #
941 do_execsql_test select4-16.1 {
942 DROP TABLE IF EXISTS t1;
943 CREATE TABLE t1(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,
944 PRIMARY KEY(a,b DESC)) WITHOUT ROWID;
945
946 WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
947 INSERT INTO t1(a,b,c,d)
948 SELECT x%10, x/10, x, printf('xyz%dabc',x) FROM c;
949
950 SELECT t3.c FROM
951 (SELECT a,max(b) AS m FROM t1 WHERE a>=5 GROUP BY a) AS t2
952 JOIN t1 AS t3
953 WHERE t2.a=t3.a AND t2.m=t3.b
954 ORDER BY t3.a;
955 } {95 96 97 98 99}
956 do_execsql_test select4-16.2 {
957 SELECT t3.c FROM
958 (SELECT a,max(b) AS m FROM t1 WHERE a>=5 GROUP BY a) AS t2
959 CROSS JOIN t1 AS t3
960 WHERE t2.a=t3.a AND t2.m=t3.b
961 ORDER BY t3.a;
962 } {95 96 97 98 99}
963 do_execsql_test select4-16.3 {
964 SELECT t3.c FROM
965 (SELECT a,max(b) AS m FROM t1 WHERE a>=5 GROUP BY a) AS t2
966 LEFT JOIN t1 AS t3
967 WHERE t2.a=t3.a AND t2.m=t3.b
968 ORDER BY t3.a;
969 } {95 96 97 98 99}
970
971 # Ticket https://www.sqlite.org/src/tktview/f7f8c97e975978d45 on 2016-04-25
972 #
973 # The where push-down optimization from 2015-06-02 is suppose to disable
974 # on aggregate subqueries. But if the subquery is a compound where the
975 # last SELECT is non-aggregate but some other SELECT is an aggregate, the
976 # test is incomplete and the optimization is not properly disabled.
977 #
978 # The following test cases verify that the fix works.
979 #
980 do_execsql_test select4-17.1 {
981 DROP TABLE IF EXISTS t1;
982 CREATE TABLE t1(a int, b int);
983 INSERT INTO t1 VALUES(1,2),(1,18),(2,19);
984 SELECT x, y FROM (
985 SELECT 98 AS x, 99 AS y
986 UNION
987 SELECT a AS x, sum(b) AS y FROM t1 GROUP BY a
988 ) AS w WHERE y>=20
989 ORDER BY +x;
990 } {1 20 98 99}
991 do_execsql_test select4-17.2 {
992 SELECT x, y FROM (
993 SELECT a AS x, sum(b) AS y FROM t1 GROUP BY a
994 UNION
995 SELECT 98 AS x, 99 AS y
996 ) AS w WHERE y>=20
997 ORDER BY +x;
998 } {1 20 98 99}
999 do_catchsql_test select4-17.3 {
1000 SELECT x, y FROM (
1001 SELECT a AS x, sum(b) AS y FROM t1 GROUP BY a LIMIT 3
1002 UNION
1003 SELECT 98 AS x, 99 AS y
1004 ) AS w WHERE y>=20
1005 ORDER BY +x;
1006 } {1 {LIMIT clause should come after UNION not before}}
1007
1008
1009
919 finish_test 1010 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/schema4.test ('k') | third_party/sqlite/src/test/select7.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698