Index: third_party/sqlite/src/test/select4.test |
diff --git a/third_party/sqlite/src/test/select4.test b/third_party/sqlite/src/test/select4.test |
index 8fc200d43468c1b8dd83278b063bc8ffb7f55b8c..a7b1af20a554f8f85e09b1d254e87f064f7338a5 100644 |
--- a/third_party/sqlite/src/test/select4.test |
+++ b/third_party/sqlite/src/test/select4.test |
@@ -105,6 +105,10 @@ ifcapable subquery { |
} |
} {0 1 2 2 3 3 3 3} |
} |
+ |
+# EVIDENCE-OF: R-02644-22131 In a compound SELECT statement, only the |
+# last or right-most simple SELECT may have an ORDER BY clause. |
+# |
do_test select4-1.3 { |
set v [catch {execsql { |
SELECT DISTINCT log FROM t1 ORDER BY log |
@@ -114,6 +118,10 @@ do_test select4-1.3 { |
}} msg] |
lappend v $msg |
} {1 {ORDER BY clause should come after UNION ALL not before}} |
+do_catchsql_test select4-1.4 { |
+ SELECT (VALUES(0) INTERSECT SELECT(0) UNION SELECT(0) ORDER BY 1 UNION |
+ SELECT 0 UNION SELECT 0 ORDER BY 1); |
+} {1 {ORDER BY clause should come after UNION not before}} |
# Union operator |
# |
@@ -144,6 +152,15 @@ do_test select4-2.3 { |
}} msg] |
lappend v $msg |
} {1 {ORDER BY clause should come after UNION not before}} |
+do_test select4-2.4 { |
+ set v [catch {execsql { |
+ SELECT 0 ORDER BY (SELECT 0) UNION SELECT 0; |
+ }} msg] |
+ lappend v $msg |
+} {1 {ORDER BY clause should come after UNION not before}} |
+do_execsql_test select4-2.5 { |
+ SELECT 123 AS x ORDER BY (SELECT x ORDER BY 1); |
+} {123} |
# Except operator |
# |
@@ -260,6 +277,16 @@ do_test select4-4.3 { |
}} msg] |
lappend v $msg |
} {1 {ORDER BY clause should come after INTERSECT not before}} |
+do_catchsql_test select4-4.4 { |
+ SELECT 3 IN ( |
+ SELECT 0 ORDER BY 1 |
+ INTERSECT |
+ SELECT 1 |
+ INTERSECT |
+ SELECT 2 |
+ ORDER BY 1 |
+ ); |
+} {1 {ORDER BY clause should come after INTERSECT not before}} |
# Various error messages while processing UNION or INTERSECT |
# |
@@ -795,6 +822,11 @@ do_test select4-11.15 { |
SELECT x FROM t2 |
} |
} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}} |
+do_test select4-11.16 { |
+ catchsql { |
+ INSERT INTO t2(rowid) VALUES(2) UNION SELECT 3,4 UNION SELECT 5,6 ORDER BY 1; |
+ } |
+} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}} |
do_test select4-12.1 { |
sqlite3 db2 :memory: |
@@ -859,5 +891,29 @@ do_execsql_test select4-14.8 { |
do_execsql_test select4-14.9 { |
SELECT * FROM t14 UNION ALL VALUES(3,2,1),(2,3,1),(1,2,3),(2,1,3); |
} {1 2 3 4 5 6 3 2 1 2 3 1 1 2 3 2 1 3} |
+do_execsql_test select4-14.10 { |
+ SELECT (VALUES(1),(2),(3),(4)) |
+} {1} |
+do_execsql_test select4-14.11 { |
+ SELECT (SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4) |
+} {1} |
+do_execsql_test select4-14.12 { |
+ VALUES(1) UNION VALUES(2); |
+} {1 2} |
+do_execsql_test select4-14.13 { |
+ VALUES(1),(2),(3) EXCEPT VALUES(2); |
+} {1 3} |
+do_execsql_test select4-14.14 { |
+ VALUES(1),(2),(3) EXCEPT VALUES(1),(3); |
+} {2} |
+do_execsql_test select4-14.15 { |
+ SELECT * FROM (SELECT 123), (SELECT 456) ON likely(0 OR 1) OR 0; |
+} {123 456} |
+do_execsql_test select4-14.16 { |
+ VALUES(1),(2),(3),(4) UNION ALL SELECT 5 LIMIT 99; |
+} {1 2 3 4 5} |
+do_execsql_test select4-14.17 { |
+ VALUES(1),(2),(3),(4) UNION ALL SELECT 5 LIMIT 3; |
+} {1 2 3} |
finish_test |