]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Disable the query flattener optimization for SELECT statements that are on
authordrh <drh@noemail.net>
Thu, 17 Nov 2016 13:13:25 +0000 (13:13 +0000)
committerdrh <drh@noemail.net>
Thu, 17 Nov 2016 13:13:25 +0000 (13:13 +0000)
the RHS of vector IN operators.  This is a hack that fixes the bug
described in ticket [da7841375186386c]. A better solution that does not
disable the query flattener is needed, but this will server for the time
being.

FossilOrigin-Name: 005d5b870625d175fdf3c0e87d974006c569d9e1

manifest
manifest.uuid
src/wherecode.c
test/rowvalue3.test

index 89b610db7e463ea4f1f0fa8eeb7f1b77daba6a3f..110e1a1a71b7d1a571a6d1f0faf433304a57906c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sa\sneeded\s#include\sto\sspeedtest1.c.
-D 2016-11-15T21:17:13.322
+C Disable\sthe\squery\sflattener\soptimization\sfor\sSELECT\sstatements\sthat\sare\son\nthe\sRHS\sof\svector\sIN\soperators.\s\sThis\sis\sa\shack\sthat\sfixes\sthe\sbug\ndescribed\sin\sticket\s[da7841375186386c].\sA\sbetter\ssolution\sthat\sdoes\snot\ndisable\sthe\squery\sflattener\sis\sneeded,\sbut\sthis\swill\sserver\sfor\sthe\stime\nbeing.
+D 2016-11-17T13:13:25.555
 F Makefile.in 6b572807415d3f0a379cebc9461416d8df4a12c8
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc bb4d970894abbbe0e88d00aac29bd52af8bc95f4
@@ -470,7 +470,7 @@ F src/wal.h bf03a23da3100ab25e5c0363450233cfee09cfc2
 F src/walker.c 91a6df7435827e41cff6bb7df50ea00934ee78b0
 F src/where.c 952f76e7a03727480b274b66ca6641b1657cd591
 F src/whereInt.h 2bcc3d176e6091cb8f50a30b65c006e88a73614d
-F src/wherecode.c 507738d957dcc3cfa93020bcc1e4b02d11ecab9e
+F src/wherecode.c 4ea298998499db5a407ffd70e87e119a86ed7834
 F src/whereexpr.c a83d70154f3bbce5051a7e9710021f647c0fe4f2
 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd
@@ -1033,7 +1033,7 @@ F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81
 F test/rowid.test 5b7509f384f4f6fae1af3c8c104c8ca299fea18d
 F test/rowvalue.test b5a9c0fa347a763c558da2397499df51da3cdf6b
 F test/rowvalue2.test 060d238b7e5639a7c5630cb5e63e311b44efef2b
-F test/rowvalue3.test 01399b7bf150b0d41abce76c18072da777c2500c
+F test/rowvalue3.test 3068f508753af69884b12125995f023da0dbb256
 F test/rowvalue4.test 4b556d7de161a0dd8cff095c336e913986398bea
 F test/rowvalue5.test c81c7d8cf36711ab37675ad7376084ae2a359cb6
 F test/rowvalue6.test d19b54feb604d5601f8614b15e214e0774c01087
@@ -1534,7 +1534,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 663473850c4274270445b3771911fa773a8c405f
-R f5b4a03f1eb13dfd7b1d8f8050241f6c
+P 77aeb705c37b1bf61a05b5e4a09f5b5cd67d07bc
+R fd152d0bb86ce30d6ad75d12d28ac69c
 U drh
-Z 74cbdb3d405329420299a0b66fca7782
+Z 0a052b186d2930619fca6146d580a03f
index fd2e5151f89819e695e60f10006f4dc8ab29c141..fd192eeffda3e6e5b6577ebcc341ebec0cf83942 100644 (file)
@@ -1 +1 @@
-77aeb705c37b1bf61a05b5e4a09f5b5cd67d07bc
\ No newline at end of file
+005d5b870625d175fdf3c0e87d974006c569d9e1
\ No newline at end of file
index d547a71179d113fc8ae9cc427847dfbdc8986524..9a4961d2939fdb743baae7a88eddd0e64edf37d6 100644 (file)
@@ -446,6 +446,7 @@ static int codeEqualityTerm(
     }else{
       Select *pSelect = pX->x.pSelect;
       sqlite3 *db = pParse->db;
+      u16 savedDbOptFlags = db->dbOptFlags;
       ExprList *pOrigRhs = pSelect->pEList;
       ExprList *pOrigLhs = pX->pLeft->x.pList;
       ExprList *pRhs = 0;         /* New Select.pEList for RHS */
@@ -489,7 +490,9 @@ static int codeEqualityTerm(
           testcase( aiMap==0 );
         }
         pSelect->pEList = pRhs;
+        db->dbOptFlags |= SQLITE_QueryFlattener;
         eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap);
+        db->dbOptFlags = savedDbOptFlags;
         testcase( aiMap!=0 && aiMap[0]!=0 );
         pSelect->pEList = pOrigRhs;
         pLeft->x.pList = pOrigLhs;
index b050e70dde646c4aca09c8e78541490309e48204..988eea90084aa17620f19f44b1d857587ba6a26d 100644 (file)
@@ -202,5 +202,19 @@ foreach {tn idx} {
 
 #-------------------------------------------------------------------------
 
+# 2016-11-17.  Query flattening in a vector SELECT on the RHS of an IN
+# operator.  Ticket https://www.sqlite.org/src/info/da7841375186386c
+#
+do_execsql_test 5.0 {
+  DROP TABLE IF EXISTS t1;
+  DROP TABLE IF EXISTS t2;
+  CREATE TABLE T1(a TEXT);
+  INSERT INTO T1(a) VALUES ('aaa');
+  CREATE TABLE T2(a TEXT PRIMARY KEY,n INT);
+  INSERT INTO T2(a, n) VALUES('aaa',0);
+  SELECT * FROM T2
+  WHERE (a,n) IN (SELECT T1.a, V.n FROM T1, (SELECT * FROM (SELECT 0 n)) V);
+} {aaa 0}
+
 
 finish_test