diff options
author | drh <drh@noemail.net> | 2016-11-23 21:01:38 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-11-23 21:01:38 +0000 |
commit | 018d5d7642150da3e232ef072d7060d998a8e763 (patch) | |
tree | 2b90c9a393d70ec13348671f5212df5e942a1799 | |
parent | 02e84703e8ba376aa2693c8473c20743c49291e7 (diff) | |
download | sqlite-018d5d7642150da3e232ef072d7060d998a8e763.tar.gz sqlite-018d5d7642150da3e232ef072d7060d998a8e763.zip |
Disable the query flattener optimization for SELECT statements that are on
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: 27438fb43db4eae90fa005e7872debbb1db22c88
-rw-r--r-- | manifest | 16 | ||||
-rw-r--r-- | manifest.uuid | 2 | ||||
-rw-r--r-- | src/wherecode.c | 3 | ||||
-rw-r--r-- | test/rowvalue3.test | 14 |
4 files changed, 26 insertions, 9 deletions
@@ -1,5 +1,5 @@ -C Fix\sa\spotential\suse-after-free\serror\sduring\sparsing\sof\smalformed\nCREATE\sTABLE\sstatement. -D 2016-11-23T20:44:04.507 +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-23T21:01:38.248 F Makefile.in 6fd48ffcf7c2deea7499062d1f3747f986c19678 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5151cc64c4c05f3455f4f692ad11410a810d937f @@ -470,7 +470,7 @@ F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2 F src/walker.c 91a6df7435827e41cff6bb7df50ea00934ee78b0 F src/where.c 125af074723cf390d0e71ed1ca385240e6d4ea7c F src/whereInt.h 2bcc3d176e6091cb8f50a30b65c006e88a73614d -F src/wherecode.c 717a65294df46f30e9b9933d2a63a4bcbca5a9a8 +F src/wherecode.c e895f34fe8cd06c386524f84da63eea5040b19b1 F src/whereexpr.c a83d70154f3bbce5051a7e9710021f647c0fe4f2 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -1027,7 +1027,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 @@ -1527,8 +1527,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4efd331e9c680e1eb9c2bf58c5f45c03c0a31772 -Q +c5dbc599b910c02a961675b12b273b8df6d29450 -R 468674797cdbc2f53ac3e01c305314f2 +P 0f956597995ca0007c51a32c71cf5fb723ed4134 +Q +005d5b870625d175fdf3c0e87d974006c569d9e1 +R 5a4c01bbdab43d8872c60615f528fa6c U drh -Z 35e7fa15558d3919e253f6fa44eb958f +Z bf757a1f37571efe6fd6858b9a0726c1 diff --git a/manifest.uuid b/manifest.uuid index 385d74c95..1250c2594 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0f956597995ca0007c51a32c71cf5fb723ed4134
\ No newline at end of file +27438fb43db4eae90fa005e7872debbb1db22c88
\ No newline at end of file diff --git a/src/wherecode.c b/src/wherecode.c index c095ce7c8..d9e7db23a 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -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; diff --git a/test/rowvalue3.test b/test/rowvalue3.test index b050e70dd..988eea900 100644 --- a/test/rowvalue3.test +++ b/test/rowvalue3.test @@ -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 |