From fe88fbfc828594d00999649ab6a8dcff5db64821 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 7 Nov 2015 17:51:39 +0000 Subject: [PATCH] Add test cases for WITH clauses. FossilOrigin-Name: e7e65c7559ed43e7065adc2ec1bd242bf187b7c3 --- manifest | 14 +++--- manifest.uuid | 2 +- test/with1.test | 110 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index c81ed9bc69..b8a59cb2c6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Proposed\sfix\sfor\san\sinfinite\sloop\sbug\sin\sthe\sWITH\sclause\ssemantic\sanalysis\nlogic. -D 2015-11-07T17:48:21.602 +C Add\stest\scases\sfor\sWITH\sclauses. +D 2015-11-07T17:51:39.619 F Makefile.in 3a705bb4bd12e194212ddbdbf068310d17153cdb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 702d3e98f3afc6587a78481257f3c4c900efc3a4 @@ -1329,7 +1329,7 @@ F test/wild001.test bca33f499866f04c24510d74baf1e578d4e44b1c F test/win32heap.test ea19770974795cff26e11575e12d422dbd16893c F test/win32lock.test fbf107c91d8f5512be5a5b87c4c42ab9fdd54972 F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d -F test/with1.test a1e8660be88e2eb4648f8860f831d1e38b5b5443 +F test/with1.test 05c8fc7f809f178a8a0519f02c21fe430948c895 F test/with2.test 2b40da883658eb74ad8ad06afabe11a408e7fb87 F test/with3.test 511bacdbe41c49cf34f9fd1bd3245fe1575bca98 F test/withM.test e97f2a8c506ab3ea9eab94e6f6072f6cc924c991 @@ -1401,7 +1401,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2040d88e877bdb69de125a047cefb4a1558e89e8 -R 6cacd3ab17c16b2093b599a59893b257 -U drh -Z 3613be9f7ebbfaa0b17b40694bdae79f +P 028475cb17a4b50baf0e9aba9bd3403d0a5d03b0 +R 0a66e1cb90e0f88ea5b94da656f84e5f +U dan +Z 560670311488774642220bf984dfc3d3 diff --git a/manifest.uuid b/manifest.uuid index 31d437d0c6..c4a678277c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -028475cb17a4b50baf0e9aba9bd3403d0a5d03b0 \ No newline at end of file +e7e65c7559ed43e7065adc2ec1bd242bf187b7c3 \ No newline at end of file diff --git a/test/with1.test b/test/with1.test index 71eec61e7d..d98f33dfb0 100644 --- a/test/with1.test +++ b/test/with1.test @@ -865,4 +865,114 @@ do_catchsql_test 16.1 { SELECT * FROM i; } {1 {recursive aggregate queries not supported}} +#------------------------------------------------------------------------- +do_execsql_test 17.1 { + WITH x(a) AS ( + WITH y(b) AS (SELECT 10) + SELECT 9 UNION ALL SELECT * FROM y + ) + SELECT * FROM x +} {9 10} + +do_execsql_test 17.2 { + WITH x AS ( + WITH y(b) AS (SELECT 10) + SELECT * FROM y UNION ALL SELECT * FROM y + ) + SELECT * FROM x +} {10 10} + +do_test 17.2 { + db eval { + WITH x AS ( + WITH y(b) AS (SELECT 10) + SELECT * FROM y UNION ALL SELECT * FROM y + ) + SELECT * FROM x + } A { + # no op + } + set A(*) +} {b} + +do_catchsql_test 17.3 { + WITH i AS ( + WITH j AS (SELECT 5) + SELECT 5 FROM i UNION SELECT 8 FROM i + ) + SELECT * FROM i; +} {1 {circular reference: i}} + +do_catchsql_test 17.4 { + WITH i AS ( + WITH j AS (SELECT 5) + SELECT 5 FROM t1 UNION SELECT 8 FROM t11 + ) + SELECT * FROM i; +} {1 {no such table: t11}} + +do_execsql_test 17.5 { + WITH + x1 AS (SELECT 10), + x2 AS (SELECT * FROM x1), + x3 AS ( + WITH x1 AS (SELECT 11) + SELECT * FROM x2 UNION ALL SELECT * FROM x2 + ) + SELECT * FROM x3; +} {10 10} + +do_execsql_test 17.6 { + WITH + x1 AS (SELECT 10), + x2 AS (SELECT * FROM x1), + x3 AS ( + WITH x1 AS (SELECT 11) + SELECT * FROM x2 UNION ALL SELECT * FROM x1 + ) + SELECT * FROM x3; +} {10 11} + +do_execsql_test 17.7 { + WITH + x1 AS (SELECT 10), + x2 AS (SELECT * FROM x1), + x3 AS ( + WITH + x1 AS ( SELECT 11 ), + x4 AS ( SELECT * FROM x2 ) + SELECT * FROM x4 UNION ALL SELECT * FROM x1 + ) + SELECT * FROM x3; +} {10 11} + +do_execsql_test 17.8 { + WITH + x1 AS (SELECT 10), + x2 AS (SELECT * FROM x1), + x3 AS ( + WITH + x1 AS ( SELECT 11 ), + x4 AS ( SELECT * FROM x2 ) + SELECT * FROM x4 UNION ALL SELECT * FROM x1 + ) + SELECT * FROM x3; +} {10 11} + +do_execsql_test 17.9 { + WITH + x1 AS (SELECT 10), + x2 AS (SELECT 11), + x3 AS ( + SELECT * FROM x1 UNION ALL SELECT * FROM x2 + ), + x4 AS ( + WITH + x1 AS (SELECT 12), + x2 AS (SELECT 13) + SELECT * FROM x3 + ) + SELECT * FROM x4; +} {10 11} + finish_test