1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

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: 005d5b870625d175fdf3c0e87d974006c569d9e1
This commit is contained in:
drh
2016-11-17 13:13:25 +00:00
parent d2d69cc1fa
commit 54cda4edbe
4 changed files with 25 additions and 8 deletions

View File

@ -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

View File

@ -1 +1 @@
77aeb705c37b1bf61a05b5e4a09f5b5cd67d07bc
005d5b870625d175fdf3c0e87d974006c569d9e1

View 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;

View 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