]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Additional tests of the new flattener added. Ticket #272. (CVS 949)
authordrh <drh@noemail.net>
Fri, 2 May 2003 16:44:25 +0000 (16:44 +0000)
committerdrh <drh@noemail.net>
Fri, 2 May 2003 16:44:25 +0000 (16:44 +0000)
FossilOrigin-Name: 8d9ee45ab487614191e8d6aef845141fdddf832a

manifest
manifest.uuid
test/select6.test

index 9c3e31a3cd7fc22dab2f92934f77282c131bcae5..ec63d22893e9a01ca2242a62ea5923dc3b415b5e 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Enhance\sthe\squery\sflattener\sto\shandle\ssubqueries\sthat\sare\sjoins.\nAll\sregressions\spass\sbut\snew\stests\sneed\sto\sbe\sadded\sbefore\srelease.\nTicket\s#272.\s(CVS\s948)
-D 2003-05-02T16:04:17
+C Additional\stests\sof\sthe\snew\sflattener\sadded.\s\sTicket\s#272.\s(CVS\s949)
+D 2003-05-02T16:44:25
 F Makefile.in 004acec253ecdde985c8ecd5b7c9accdb210378f
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -110,7 +110,7 @@ F test/select2.test aceea74fd895b9d007512f72499db589735bd8e4
 F test/select3.test 445a1a3dde4e2fd32541b311f55da5e2f8079d76
 F test/select4.test e7e9a32fa745246cb99fadbeb63af4843a17925b
 F test/select5.test c2a6c4a003316ee42cbbd689eebef8fdce0db2ac
-F test/select6.test efb8d0c07a440441db87db2c4ade6904e1407e85
+F test/select6.test 670026a06c358cc867ace7b1de6020e43adc7245
 F test/sort.test ba07b107c16070208e6aab3cadea66ba079d85ba
 F test/subselect.test f0fea8cf9f386d416d64d152e3c65f9116d0f50f
 F test/table.test 371a1fc1c470982b2f68f9732f903a5d96f949c4
@@ -165,7 +165,7 @@ F www/speed.tcl cb4c10a722614aea76d2c51f32ee43400d5951be
 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P be7aed2011b4af868b6a0c370c3d41354ae0cdf4
-R ed36fbd16d08ea65dbe969ae9a7bbf4c
+P ad57693e9f1b83a8cc4d028264b35018a9a4a701
+R 0c892dfdfe33ba9930d105338a5e3731
 U drh
-Z 80e0fdd6a1502d3a16e3bb09c6a28adb
+Z ba7386fd2621411a19fd3dce98cc1a19
index d68424a0394709f0b9938ebf649a55e304caaa9c..0bf20d8210f26a2732dc4ae294ad93b559417951 100644 (file)
@@ -1 +1 @@
-ad57693e9f1b83a8cc4d028264b35018a9a4a701
\ No newline at end of file
+8d9ee45ab487614191e8d6aef845141fdddf832a
\ No newline at end of file
index 8fe71e1961bb37cb140e9c9a3baa473297aeaa48..d47cdc65f096df35a2f9810e53ee6462facbe5ac 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this file is testing SELECT statements that contain
 # subqueries in their FROM clause.
 #
-# $Id: select6.test,v 1.9 2002/04/30 19:20:29 drh Exp $
+# $Id: select6.test,v 1.10 2003/05/02 16:44:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -359,4 +359,77 @@ do_test select6-7.4 {
   }
 } {c abc b 2 a 1 a 1 b 2 c abc}
 
+# The following procedure compiles the SQL given as an argument and returns
+# TRUE if that SQL uses any transient tables and returns FALSE if no
+# transient tables are used.  This is used to make sure that the
+# sqliteFlattenSubquery() routine in select.c is doing its job.
+#
+proc is_flat {sql} {
+  return [expr 0>[lsearch [execsql "EXPLAIN $sql"] OpenTemp]]
+}
+
+# Check that the flattener works correctly for deeply nested subqueries
+# involving joins.
+#
+do_test select6-8.1 {
+  execsql {
+    BEGIN;
+    CREATE TABLE t3(p,q);
+    INSERT INTO t3 VALUES(1,11);
+    INSERT INTO t3 VALUES(2,22);
+    CREATE TABLE t4(q,r);
+    INSERT INTO t4 VALUES(11,111);
+    INSERT INTO t4 VALUES(22,222);
+    COMMIT;
+    SELECT * FROM t3 NATURAL JOIN t4;
+  }
+} {1 11 111 2 22 222}
+do_test select6-8.2 {
+  execsql {
+    SELECT y, p, q, r FROM
+       (SELECT t1.y AS y, t2.b AS b FROM t1, t2 WHERE t1.x=t2.a) AS m,
+       (SELECT t3.p AS p, t3.q AS q, t4.r AS r FROM t3 NATURAL JOIN t4) as n
+    WHERE  y=p
+  }
+} {1 1 11 111 2 2 22 222 2 2 22 222}
+do_test select6-8.3 {
+  is_flat {
+    SELECT y, p, q, r FROM
+       (SELECT t1.y AS y, t2.b AS b FROM t1, t2 WHERE t1.x=t2.a) AS m,
+       (SELECT t3.p AS p, t3.q AS q, t4.r AS r FROM t3 NATURAL JOIN t4) as n
+    WHERE  y=p
+  }
+} {1}
+do_test select6-8.4 {
+  execsql {
+    SELECT DISTINCT y, p, q, r FROM
+       (SELECT t1.y AS y, t2.b AS b FROM t1, t2 WHERE t1.x=t2.a) AS m,
+       (SELECT t3.p AS p, t3.q AS q, t4.r AS r FROM t3 NATURAL JOIN t4) as n
+    WHERE  y=p
+  }
+} {1 1 11 111 2 2 22 222}
+do_test select6-8.5 {
+  execsql {
+    SELECT * FROM 
+      (SELECT y, p, q, r FROM
+         (SELECT t1.y AS y, t2.b AS b FROM t1, t2 WHERE t1.x=t2.a) AS m,
+         (SELECT t3.p AS p, t3.q AS q, t4.r AS r FROM t3 NATURAL JOIN t4) as n
+      WHERE  y=p) AS e,
+      (SELECT r AS z FROM t4 WHERE q=11) AS f
+    WHERE e.r=f.z
+  }
+} {1 1 11 111 111}
+do_test select6-8.6 {
+  is_flat {
+    SELECT * FROM 
+      (SELECT y, p, q, r FROM
+         (SELECT t1.y AS y, t2.b AS b FROM t1, t2 WHERE t1.x=t2.a) AS m,
+         (SELECT t3.p AS p, t3.q AS q, t4.r AS r FROM t3 NATURAL JOIN t4) as n
+      WHERE  y=p) AS e,
+      (SELECT r AS z FROM t4 WHERE q=11) AS f
+    WHERE e.r=f.z
+  }
+} {1}
+
+
 finish_test