summaryrefslogtreecommitdiff
path: root/test/select6.test
diff options
context:
space:
mode:
authorHans-Christoph Steiner <hans@eds.org>2013-01-17 14:23:24 -0500
committerHans-Christoph Steiner <hans@eds.org>2013-01-17 14:23:24 -0500
commit4f9313b1de21a03df32bfba4d94207c78a2171b0 (patch)
tree6a637dd4dde653f870346a37ec6555eb0574949a /test/select6.test
parent9da5e9acd37e51b86429d938e7e6a64ffb02da84 (diff)
parent1b5ba8e022836fa8ab93bc90df1b34a29ea6e134 (diff)
Merge tag 'upstream/2.1.1'
Upstream version 2.1.1 Conflicts: .gitignore
Diffstat (limited to 'test/select6.test')
-rw-r--r--test/select6.test44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/select6.test b/test/select6.test
index e0ff165..64a8519 100644
--- a/test/select6.test
+++ b/test/select6.test
@@ -22,6 +22,7 @@ ifcapable !subquery {
finish_test
return
}
+set ::testprefix select6
do_test select6-1.0 {
execsql {
@@ -513,5 +514,48 @@ do_test select6-9.11 {
} {2 12 3 13 4 14}
+#-------------------------------------------------------------------------
+# Test that if a UNION ALL sub-query that would otherwise be eligible for
+# flattening consists of two or more SELECT statements that do not all
+# return the same number of result columns, the error is detected.
+#
+do_execsql_test 10.1 {
+ CREATE TABLE t(i,j,k);
+ CREATE TABLE j(l,m);
+ CREATE TABLE k(o);
+}
+
+set err [list 1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}]
+
+do_execsql_test 10.2 {
+ SELECT * FROM (SELECT * FROM t), j;
+}
+do_catchsql_test 10.3 {
+ SELECT * FROM t UNION ALL SELECT * FROM j
+} $err
+do_catchsql_test 10.4 {
+ SELECT * FROM (SELECT i FROM t UNION ALL SELECT l, m FROM j)
+} $err
+do_catchsql_test 10.5 {
+ SELECT * FROM (SELECT j FROM t UNION ALL SELECT * FROM j)
+} $err
+do_catchsql_test 10.6 {
+ SELECT * FROM (SELECT * FROM t UNION ALL SELECT * FROM j)
+} $err
+do_catchsql_test 10.7 {
+ SELECT * FROM (
+ SELECT * FROM t UNION ALL
+ SELECT l,m,l FROM j UNION ALL
+ SELECT * FROM k
+ )
+} $err
+do_catchsql_test 10.8 {
+ SELECT * FROM (
+ SELECT * FROM k UNION ALL
+ SELECT * FROM t UNION ALL
+ SELECT l,m,l FROM j
+ )
+} $err
+
finish_test