Ensure the EXISTS->IN transformation preserves the collation sequence of the comparison operation.
FossilOrigin-Name: a373baae12c914e48fd84de77998e301fdd3da43b06b9d64ac24a14418ed48cd
This commit is contained in:
parent
9d326d6793
commit
e8f7fcf6f4
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sa\spotential\sNULL\spointer\sdereference\sfollowing\sOOM.
|
||||
D 2021-01-15T15:21:27.437
|
||||
C Ensure\sthe\sEXISTS->IN\stransformation\spreserves\sthe\scollation\ssequence\sof\sthe\scomparison\soperation.
|
||||
D 2021-01-15T15:32:09.587
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -630,7 +630,7 @@ F src/walker.c d9c4e454ebb9499e908aa62d55b8994c375cf5355ac78f60d45af17f7890701c
|
||||
F src/where.c 0e6abb22a2323fec80b450825593c26a2ad8f4815d1ee3af9969d8f6144bf681
|
||||
F src/whereInt.h 9a3f577619f07700d16d89eeb2f3d94d6b7ed7f109c2dacf0ce8844921549506
|
||||
F src/wherecode.c a3a1aff30fe99a818d8e7c607980f033f40c68d890e03ed25838b9dbb7908bee
|
||||
F src/whereexpr.c 8ea4f6cd1332fdfbfbe832dc8a9f5194990684870931e7a07c2cafbc544588e7
|
||||
F src/whereexpr.c d63dcb44253f7ad67449759bca6da63cac1c352aba7bea46ba3210154ad21e22
|
||||
F src/window.c edd6f5e25a1e8f2b6f5305b7f5f7da7bb35f07f0d432b255b1d4c2fcab4205aa
|
||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||
F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627
|
||||
@ -874,7 +874,7 @@ F test/exclusive.test 7ff63be7503990921838d5c9f77f6e33e68e48ed1a9d48cd28745bf650
|
||||
F test/exclusive2.test 984090e8e9d1b331d2e8111daf6e5d61dda0bef7
|
||||
F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7
|
||||
F test/exists.test 79a75323c78f02bbe9c251ea502a092f9ef63dac
|
||||
F test/exists2.test 44e18a6aaadefa8e1c68a8453fb22a57a0270a673d9b256790d142ea257459e3
|
||||
F test/exists2.test 1022fe1c85ee162ae55efda6c00497b29d1f61ecb21e7d5f1c014eb46245c70a
|
||||
F test/expr.test 26cd01e8485bc48c8aa6a1add598e9ce1e706b4eb4f3f554e0b0223022e8c2cf
|
||||
F test/expr2.test c27327ae9c017a7ff6280123f67aff496f912da74d78c888926d68b46ec75fd8
|
||||
F test/extension01.test 00d13cec817f331a687a243e0e5a2d87b0e358c9
|
||||
@ -1896,7 +1896,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 a80c9a076d31729282004ca372913c9fdbfb6e74711fbb8c5dc12ee0ecba2b87
|
||||
R 31b39e7a643244cb65bba0cd39985e5a
|
||||
U drh
|
||||
Z 96ac907b935dc11fb79e0a38f40aef27
|
||||
P 8ce3cb90965771530c0021173d98720fc4c76bb99e69f7a879f80471dea0aace
|
||||
R bc5d3e0052171a4a3fcfe5fb2a3891b3
|
||||
U dan
|
||||
Z 4e48cccd8bd31a2f422fbd932b326f93
|
||||
|
@ -1 +1 @@
|
||||
8ce3cb90965771530c0021173d98720fc4c76bb99e69f7a879f80471dea0aace
|
||||
a373baae12c914e48fd84de77998e301fdd3da43b06b9d64ac24a14418ed48cd
|
@ -1175,12 +1175,18 @@ static void exprAnalyzeExists(
|
||||
pInLhs = exprAnalyzeExistsFindEq(pSel, &pEq, &ppAnd);
|
||||
assert( pInLhs && pEq );
|
||||
assert( pEq==pSel->pWhere || ppAnd );
|
||||
if( pInLhs==pEq->pLeft ){
|
||||
pRet = pEq->pRight;
|
||||
}else{
|
||||
CollSeq *p = sqlite3ExprCompareCollSeq(pParse, pEq);
|
||||
pInLhs = sqlite3ExprAddCollateString(pParse, pInLhs, p?p->zName:"BINARY");
|
||||
pRet = pEq->pLeft;
|
||||
}
|
||||
|
||||
assert( pDup->pLeft==0 );
|
||||
pDup->op = TK_IN;
|
||||
pDup->pLeft = pInLhs;
|
||||
pDup->flags &= ~EP_VarSelect;
|
||||
pRet = (pInLhs==pEq->pLeft) ? pEq->pRight : pEq->pLeft;
|
||||
pSel->pEList = sqlite3ExprListAppend(pParse, 0, pRet);
|
||||
pEq->pLeft = 0;
|
||||
pEq->pRight = 0;
|
||||
|
@ -71,7 +71,6 @@ do_execsql_eqp_test 1.4 {
|
||||
1 one 3 three 5 five 7 seven
|
||||
}
|
||||
|
||||
breakpoint
|
||||
do_execsql_eqp_test 1.5 {
|
||||
SELECT t1.* FROM t1 WHERE EXISTS(
|
||||
SELECT * FROM t2 WHERE t1.a=t2.c AND d IN (1, 2, 3)
|
||||
@ -82,6 +81,83 @@ do_execsql_eqp_test 1.5 {
|
||||
1 one 3 three 5 five
|
||||
}
|
||||
|
||||
do_execsql_eqp_test 1.6 {
|
||||
SELECT t1.* FROM t1 WHERE EXISTS(
|
||||
SELECT * FROM t2 WHERE d IN (1, 2, 3)AND t1.a=t2.c
|
||||
);
|
||||
} {
|
||||
SEARCH TABLE t1 USING INTEGER PRIMARY KEY
|
||||
} {
|
||||
1 one 3 three 5 five
|
||||
}
|
||||
|
||||
do_execsql_eqp_test 1.7 {
|
||||
SELECT t1.* FROM t1 WHERE EXISTS(
|
||||
SELECT * FROM t2 WHERE d IN (1, 2, 3)AND t1.a=t2.c
|
||||
);
|
||||
} {
|
||||
SEARCH TABLE t1 USING INTEGER PRIMARY KEY
|
||||
} {
|
||||
1 one 3 three 5 five
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 2.0 {
|
||||
CREATE TABLE t3(a TEXT PRIMARY KEY, b TEXT) WITHOUT ROWID;
|
||||
CREATE TABLE t4(c TEXT COLLATE nocase);
|
||||
|
||||
INSERT INTO t3 VALUES('one', 'i');
|
||||
INSERT INTO t3 VALUES('two', 'ii');
|
||||
INSERT INTO t3 VALUES('three', 'iii');
|
||||
INSERT INTO t3 VALUES('four', 'iv');
|
||||
INSERT INTO t3 VALUES('five', 'v');
|
||||
|
||||
INSERT INTO t4 VALUES('FIVE'), ('four'), ('TWO'), ('one');
|
||||
}
|
||||
|
||||
do_execsql_test 2.1 { SELECT a FROM t3, t4 WHERE a=c } {four one}
|
||||
do_execsql_test 2.2 { SELECT a FROM t3, t4 WHERE c=a } {five four one two}
|
||||
|
||||
do_execsql_eqp_test 2.3 {
|
||||
SELECT a FROM t3 WHERE EXISTS (SELECT 1 FROM t4 WHERE a=c)
|
||||
} {
|
||||
SEARCH TABLE t3 USING PRIMARY KEY
|
||||
} {
|
||||
four one
|
||||
}
|
||||
|
||||
do_execsql_eqp_test 2.4 {
|
||||
SELECT a FROM t3 WHERE EXISTS (SELECT 1 FROM t4 WHERE c=a)
|
||||
} {
|
||||
SCAN TABLE t3
|
||||
} {
|
||||
five four one two
|
||||
}
|
||||
|
||||
do_execsql_test 2.5 {
|
||||
CREATE INDEX t3anc ON t3(a COLLATE nocase);
|
||||
}
|
||||
|
||||
do_execsql_eqp_test 2.6 {
|
||||
SELECT a FROM t3 WHERE EXISTS (SELECT 1 FROM t4 WHERE c=a)
|
||||
} {
|
||||
SEARCH TABLE t3 USING COVERING INDEX t3anc
|
||||
} {
|
||||
five four one two
|
||||
}
|
||||
|
||||
do_execsql_eqp_test 2.7 {
|
||||
SELECT a FROM t3 WHERE EXISTS (SELECT 1 FROM t4 WHERE a=c)
|
||||
} {
|
||||
SEARCH TABLE t3 USING PRIMARY KEY
|
||||
} {
|
||||
four one
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user