Ensure that subqueries associated with row-values are invoked before being
used when processing a RIGHT JOIN. Fix for the problem described by [forum:/forumpost/087de2d9ec87305b|forum post 087de2d9ec87305b]. FossilOrigin-Name: 5a9465dcc0c23fc2c66cd4898bcdfd5086fe4c71ec19a95db7221fdf7c0bbbbd
This commit is contained in:
commit
f89f4efb28
25
manifest
25
manifest
@ -1,5 +1,5 @@
|
||||
C fiddle:\sadded\sanother\sUI\selement\sto\sthe\slist\sof\sthose\swhich\sare\sdisabled\sduring\slong-running\sactivities.\sAdded\sDB.close()\sbinding\sto\sthe\sWorker-based\swasm\sbinding.
|
||||
D 2022-06-01T16:04:29.637
|
||||
C Ensure\sthat\ssubqueries\sassociated\swith\srow-values\sare\sinvoked\sbefore\sbeing\nused\swhen\sprocessing\sa\sRIGHT\sJOIN.\s\sFix\sfor\sthe\sproblem\sdescribed\sby\n[forum:/forumpost/087de2d9ec87305b|forum\spost\s087de2d9ec87305b].
|
||||
D 2022-06-01T16:05:25.847
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -657,10 +657,10 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
|
||||
F src/wal.c b9df133a705093da8977da5eb202eaadb844839f1c7297c08d33471f5491843d
|
||||
F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
|
||||
F src/walker.c f890a3298418d7cba3b69b8803594fdc484ea241206a8dfa99db6dd36f8cbb3b
|
||||
F src/where.c c4b64c6fa224e5b89ed547ec0ebdfd243c081509b195e71581164a2fbb8d4a80
|
||||
F src/whereInt.h 8da918f392bf202ccc0ee61291455b33ad171d209445f1ff3eaf62e0b6f6b363
|
||||
F src/wherecode.c 1d5bed686d60e272e93c04e34fec5b487d086383dd4773a7f2f98f86278e6a94
|
||||
F src/whereexpr.c 7c5ee52e1df81d6a43f39e6b6f35d540fd37254e2b6e953a4e2715c3abf26f46
|
||||
F src/where.c 3a69f4403aa994cda45db8f4070d146d8f253f9850b4c827a9ade7d444f889ea
|
||||
F src/whereInt.h b48ca529ffe293c18cbfa8326af18a09e39910de66fb3e96ef788c7cbf8ef3a7
|
||||
F src/wherecode.c 0b09abfcb88c61c6a6984a3e065786631ff35495e9bdf865e6b74ab0a1299c5b
|
||||
F src/whereexpr.c 416d6a847bc0c3d391b65e7748dc04d57d3117c82e072c222888f9eb346760da
|
||||
F src/window.c fff1b51757438c664e471d5184634e48dcdf8ea34b640f3b1b0810b1e06de18c
|
||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||
F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627
|
||||
@ -1166,7 +1166,7 @@ F test/join4.test 1a352e4e267114444c29266ce79e941af5885916
|
||||
F test/join5.test d22b6cba8fb59ab3f1c82701434c360705eb12d4ce200c449f37b018fc47681a
|
||||
F test/join6.test f809c025fa253f9e150c0e9afd4cef8813257bceeb6f46e04041228c9403cc2c
|
||||
F test/join7.test 2268dcbb54b724391dda3748ea95c60d960607ffeed67885675998e7117697f6
|
||||
F test/join8.test 2d7e2d744cd6967cd141e97572af039f3e9494ca33650c057600846b02a1633f
|
||||
F test/join8.test 01c46c005f3cd20f530e1b7e17d003a1e6d16ae945ceca395f6c016bbee92e9f
|
||||
F test/join9.test 9056ddd3b0c0f4f9d658f4521038d9a37dc23ead8ca9a505d0b0db2b6a471e05
|
||||
F test/joinA.test 7eab225dc1c1ab258a5e62513a4ed7cabbd3db971d59d5d92f4fb6fa14c12f6a
|
||||
F test/joinB.test 1b2ba3fc8568b49411787fccbf540570c148e9b6a53a30f80691cb6268098ded
|
||||
@ -1354,7 +1354,7 @@ F test/round1.test 768018b04522ca420b1aba8a24bd76091d269f3bce3902af3ec6ebcee41ab
|
||||
F test/rowallock.test 3f88ec6819489d0b2341c7a7528ae17c053ab7cc
|
||||
F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81
|
||||
F test/rowid.test e29025be95baf6b32f0d5edef59a7633028325896a98f1caa8019559ca910350
|
||||
F test/rowvalue.test 228b312f8526ed000ecda559a6a9adf30aa2d79dcb12afa5c04eebaafcf55eae
|
||||
F test/rowvalue.test 00668659c2ffb0ae8711b3f6702979f199170734c00f582622375cde4d03e091
|
||||
F test/rowvalue2.test 060d238b7e5639a7c5630cb5e63e311b44efef2b
|
||||
F test/rowvalue3.test 3068f508753af69884b12125995f023da0dbb256
|
||||
F test/rowvalue4.test 441e7e366ac6d939a3a95a574031c56ec2a854077a91d66eee5ff1d86cb5be58
|
||||
@ -1974,8 +1974,9 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P f0ad6b1b324f9c0f4340f6cf9584884d1206b56fe1010db43bcbef324e713ea3
|
||||
R 8aa54d35311465583fa9edb90a82d403
|
||||
U stephan
|
||||
Z f4b934a70d4d19bc08d2e676d68f616b
|
||||
P 5933163ed1a8f996e81023c7c5822655dc6411d30016f37fe8863f760530dc5b e4e71b4cd4c026fc36f0da1703e6237e6ddd8ff2e08dc3c0011632b9e63098cd
|
||||
R 29237a4ae29ef3cc0374b4c8b3b6c3e8
|
||||
T +closed e4e71b4cd4c026fc36f0da1703e6237e6ddd8ff2e08dc3c0011632b9e63098cd
|
||||
U drh
|
||||
Z 8809ed3fb5097c404e378a7b4bbae70a
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
5933163ed1a8f996e81023c7c5822655dc6411d30016f37fe8863f760530dc5b
|
||||
5a9465dcc0c23fc2c66cd4898bcdfd5086fe4c71ec19a95db7221fdf7c0bbbbd
|
@ -6034,6 +6034,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
SrcList *pTabList = pWInfo->pTabList;
|
||||
sqlite3 *db = pParse->db;
|
||||
int iEnd = sqlite3VdbeCurrentAddr(v);
|
||||
int nRJ = 0;
|
||||
|
||||
/* Generate loop termination code.
|
||||
*/
|
||||
@ -6050,8 +6051,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
pRJ->endSubrtn = sqlite3VdbeCurrentAddr(v);
|
||||
sqlite3VdbeAddOp3(v, OP_Return, pRJ->regReturn, pRJ->addrSubrtn, 1);
|
||||
VdbeCoverage(v);
|
||||
assert( pParse->withinRJSubrtn>0 );
|
||||
pParse->withinRJSubrtn--;
|
||||
nRJ++;
|
||||
}
|
||||
pLoop = pLevel->pWLoop;
|
||||
if( pLevel->op!=OP_Noop ){
|
||||
@ -6332,5 +6332,6 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
*/
|
||||
pParse->nQueryLoop = pWInfo->savedNQueryLoop;
|
||||
whereInfoFree(db, pWInfo);
|
||||
pParse->withinRJSubrtn -= nRJ;
|
||||
return;
|
||||
}
|
||||
|
@ -612,8 +612,9 @@ void sqlite3WhereTabFuncArgs(Parse*, SrcItem*, WhereClause*);
|
||||
#define WO_AND 0x0400 /* Two or more AND-connected terms */
|
||||
#define WO_EQUIV 0x0800 /* Of the form A==B, both columns */
|
||||
#define WO_NOOP 0x1000 /* This term does not restrict search space */
|
||||
#define WO_ROWVAL 0x2000 /* A row-value term */
|
||||
|
||||
#define WO_ALL 0x1fff /* Mask of all possible WO_* values */
|
||||
#define WO_ALL 0x3fff /* Mask of all possible WO_* values */
|
||||
#define WO_SINGLE 0x01ff /* Mask of all non-compound WO_* values */
|
||||
|
||||
/*
|
||||
|
@ -2862,7 +2862,11 @@ SQLITE_NOINLINE void sqlite3WhereRightJoinLoop(
|
||||
mAll |= pLoop->maskSelf;
|
||||
for(k=0; k<pWC->nTerm; k++){
|
||||
WhereTerm *pTerm = &pWC->a[k];
|
||||
if( pTerm->wtFlags & TERM_VIRTUAL ) break;
|
||||
if( (pTerm->wtFlags & (TERM_VIRTUAL|TERM_SLICE))!=0
|
||||
&& pTerm->eOperator!=WO_ROWVAL
|
||||
){
|
||||
break;
|
||||
}
|
||||
if( pTerm->prereqAll & ~mAll ) continue;
|
||||
if( ExprHasProperty(pTerm->pExpr, EP_OuterON|EP_InnerON) ) continue;
|
||||
pSubWhere = sqlite3ExprAnd(pParse, pSubWhere,
|
||||
|
@ -1411,7 +1411,7 @@ static void exprAnalyze(
|
||||
}
|
||||
pTerm = &pWC->a[idxTerm];
|
||||
pTerm->wtFlags |= TERM_CODED|TERM_VIRTUAL; /* Disable the original */
|
||||
pTerm->eOperator = 0;
|
||||
pTerm->eOperator = WO_ROWVAL;
|
||||
}
|
||||
|
||||
/* If there is a vector IN term - e.g. "(a, b) IN (SELECT ...)" - create
|
||||
@ -1612,7 +1612,7 @@ void sqlite3WhereAddLimit(WhereClause *pWC, Select *p){
|
||||
/* This term is a vector operation that has been decomposed into
|
||||
** other, subsequent terms. It can be ignored. See tag-20220128a */
|
||||
assert( pWC->a[ii].wtFlags & TERM_VIRTUAL );
|
||||
assert( pWC->a[ii].eOperator==0 );
|
||||
assert( pWC->a[ii].eOperator==WO_ROWVAL );
|
||||
continue;
|
||||
}
|
||||
if( pWC->a[ii].leftCursor!=iCsr ) return;
|
||||
|
@ -517,4 +517,59 @@ do_execsql_test join8-16070 {
|
||||
SELECT * FROM t1 RIGHT JOIN t2 ON true JOIN t3 ON a<>'' WHERE c IS NOT NULL;
|
||||
} {}
|
||||
|
||||
# 2022-06-01
|
||||
# https://sqlite.org/forum/forumpost/087de2d9ec
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test join8-17000 {
|
||||
CREATE TABLE t1(id INTEGER PRIMARY KEY, x INT, y INT);
|
||||
CREATE TABLE t2(z INT);
|
||||
INSERT INTO t1(id,x,y) VALUES(1, 0, 0);
|
||||
} {}
|
||||
db null NULL
|
||||
do_execsql_test join8-17010 {
|
||||
SELECT * FROM t2 RIGHT JOIN t1 ON true;
|
||||
} {NULL 1 0 0}
|
||||
do_execsql_test join8-17020 {
|
||||
SELECT 99=id AND 0=y AS "truth" FROM t2 RIGHT JOIN t1 ON true;
|
||||
} {0}
|
||||
do_execsql_test join8-17030 {
|
||||
SELECT (99, 0)==(id, y) AS "truth" FROM t2 RIGHT JOIN t1;
|
||||
} {0}
|
||||
do_execsql_test join8-17040 {
|
||||
SELECT * FROM t2 RIGHT JOIN t1 WHERE 99=id AND 0=y;
|
||||
} {}
|
||||
do_execsql_test join8-17041 {
|
||||
SELECT * FROM t2 RIGHT JOIN t1 WHERE 99=+id AND 0=y;
|
||||
} {}
|
||||
do_execsql_test join8-17050 {
|
||||
SELECT * FROM t2 RIGHT JOIN t1 WHERE (99, 0)==(id,y);
|
||||
} {}
|
||||
do_execsql_test join8-17051 {
|
||||
SELECT * FROM t2 RIGHT JOIN t1 WHERE (99, 0)==(+id,y);
|
||||
} {}
|
||||
do_execsql_test join8-17060 {
|
||||
SELECT * FROM t2 RIGHT JOIN t1 WHERE 1=id AND 0=y;
|
||||
} {NULL 1 0 0}
|
||||
do_execsql_test join8-17061 {
|
||||
SELECT * FROM t2 RIGHT JOIN t1 WHERE 1=+id AND 0=y;
|
||||
} {NULL 1 0 0}
|
||||
do_execsql_test join8-17070 {
|
||||
SELECT * FROM t2 RIGHT JOIN t1 WHERE (1, 0)==(id,y);
|
||||
} {NULL 1 0 0}
|
||||
do_execsql_test join8-17071 {
|
||||
SELECT * FROM t2 RIGHT JOIN t1 WHERE (1, 0)==(+id,y);
|
||||
} {NULL 1 0 0}
|
||||
do_execsql_test join8-17080 {
|
||||
CREATE TABLE t3(a INTEGER PRIMARY KEY, b INT);
|
||||
CREATE TABLE t4(x INT, y INT);
|
||||
INSERT INTO t3(a,b) VALUES(1, 3);
|
||||
} {}
|
||||
do_execsql_test join8-17090 {
|
||||
SELECT t3.a FROM t4 RIGHT JOIN t3 ON (x=a) WHERE (b, 4)=(SELECT 3, 4);
|
||||
} {1}
|
||||
do_execsql_test join8-17091 {
|
||||
SELECT t3.a FROM t4 RIGHT JOIN t3 ON (x=a) WHERE (b, 4) IS (SELECT 3, 4);
|
||||
} {1}
|
||||
|
||||
finish_test
|
||||
|
@ -540,7 +540,7 @@ do_execsql_test 19.36 {
|
||||
SELECT * FROM t1 WHERE (3,32)>=(a,b) ORDER BY a DESC;
|
||||
} {2 22 1 11}
|
||||
|
||||
# 2018-02-18: Memory leak nexted row-value. Detected by OSSFuzz.
|
||||
# 2018-02-18: Memory leak nested row-value. Detected by OSSFuzz.
|
||||
#
|
||||
do_catchsql_test 20.1 {
|
||||
SELECT 1 WHERE (2,(2,0)) IS (2,(2,0));
|
||||
|
Loading…
Reference in New Issue
Block a user