Do not generate subroutines for non-static SELECT and EXISTS expressions.
Fix up some test cases to account for the minor changes in EXPLAIN QUERY PLAN output. FossilOrigin-Name: 06de44ec9e173992ca9afb89dd2b4e40d2a7e35512c7959603cdceb606f5dfbd
This commit is contained in:
parent
efb699fc7c
commit
5198ff5767
18
manifest
18
manifest
@ -1,5 +1,5 @@
|
||||
C Prevent\sthe\suse\sof\ssubroutines\sto\simplement\sthe\sRHS\sof\sIN\soperators\swithin\nCHECK\sconstraints.
|
||||
D 2018-12-24T11:55:44.935
|
||||
C Do\snot\sgenerate\ssubroutines\sfor\snon-static\sSELECT\sand\sEXISTS\sexpressions.\nFix\sup\ssome\stest\scases\sto\saccount\sfor\sthe\sminor\schanges\sin\sEXPLAIN\sQUERY\sPLAN\noutput.
|
||||
D 2018-12-24T12:09:47.593
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F Makefile.in d8b254f8bb81bab43c340d70d17dc3babab40fcc8a348c8255881f780a45fee6
|
||||
@ -462,7 +462,7 @@ F src/date.c ebe1dc7c8a347117bb02570f1a931c62dd78f4a2b1b516f4837d45b7d6426957
|
||||
F src/dbpage.c 135eb3b5e74f9ef74bde5cec2571192c90c86984fa534c88bf4a055076fa19b7
|
||||
F src/dbstat.c 3c8bd4e77f0244fd2bd7cc90acf116ad2f8e82d70e536637f35ac2bc99b726f9
|
||||
F src/delete.c f7938125847e8ef485448db5fbad29acb2991381a02887dd854c1617315ab9fb
|
||||
F src/expr.c 84b83f3f5cbed871be9388693ca4f5a95ff3104f27cd2e5440ae9f431993f899
|
||||
F src/expr.c 7122877f40f506c7ba82fb7d6a8ccedc399f1e133f97292084082ef4cb709926
|
||||
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
|
||||
F src/fkey.c 012dd7dba1a62fda6b76e633ab303b2232ee2874a685c915065227ab20ad6ae0
|
||||
F src/func.c 7c288b4ce309b5a8b8473514b88e1f8e69a80134509a8c0db8e39c858e367e7f
|
||||
@ -654,7 +654,7 @@ F test/auth2.test 9eb7fce9f34bf1f50d3f366fb3e606be5a2000a1
|
||||
F test/auth3.test db21405b95257c24d29273b6b31d0efc59e1d337e3d5804ba2d1fd4897b1ae49
|
||||
F test/autoanalyze1.test b9cc3f32a990fa56669b668d237c6d53e983554ae80c0604992e18869a0b2dec
|
||||
F test/autoinc.test 381f494fefa90acd999933829e2934efb6b40906db9d6a39e822e3f7b4c8bf61
|
||||
F test/autoindex1.test a09958fa756129af10b6582bcbf3cbdf11e305e027b393f393caef801159dee0
|
||||
F test/autoindex1.test efdc2ff5d369fa8acc12ca72db93cd4d67bc109b0ee8bfce48824a39965a47bf
|
||||
F test/autoindex2.test 12ef578928102baaa0dc23ad397601a2f4ecb0df
|
||||
F test/autoindex3.test 2dd997d6590438b53e4f715f9278aa91c9299cf3f81246a0915269c35beb790e
|
||||
F test/autoindex4.test 49d3cd791a9baa16fb461d7ea3de80d019a819cf
|
||||
@ -825,7 +825,7 @@ F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea
|
||||
F test/enc2.test 83437a79ba1545a55fb549309175c683fb334473
|
||||
F test/enc3.test 6807f7a7740a00361ca8d0ccd66bc60c8dc5f2b6
|
||||
F test/enc4.test c8f1ce3618508fd0909945beb8b8831feef2c020
|
||||
F test/eqp.test fc00ad1a7f5b90bf1bbccbf877ae9abef8bf5c7896174830d438c8f91a6ead88
|
||||
F test/eqp.test 5e8b1b2d8c45b0102703cece6f3b059435068b2df528b4b6dc489d6cd5afcd66
|
||||
F test/errmsg.test eae9f091eb39ce7e20305de45d8e5d115b68fa856fba4ea6757b6ca3705ff7f9
|
||||
F test/eval.test a64c9105d6ff163df7cf09d6ac29cdad5922078c
|
||||
F test/exclusive.test 1206b87e192497d78c7f35552e86a9d05421498da300fb1cce5ca5351ccde3c3
|
||||
@ -1225,7 +1225,7 @@ F test/rowid.test 5b7509f384f4f6fae1af3c8c104c8ca299fea18d
|
||||
F test/rowvalue.test b8680f07d19c8c5223b808bba998faffcec6d505f5689ff6070280119173bb51
|
||||
F test/rowvalue2.test 060d238b7e5639a7c5630cb5e63e311b44efef2b
|
||||
F test/rowvalue3.test 3068f508753af69884b12125995f023da0dbb256
|
||||
F test/rowvalue4.test 2b20468da3775aba971caf3158e9696a4d99c69a7623fb495f332a596daebbee
|
||||
F test/rowvalue4.test 02e35f7762371c2f57ebd856aa056eac56cb27ef7715a0bb31eac1895a745356
|
||||
F test/rowvalue5.test c81c7d8cf36711ab37675ad7376084ae2a359cb6
|
||||
F test/rowvalue6.test d19b54feb604d5601f8614b15e214e0774c01087
|
||||
F test/rowvalue7.test 5d06ff19d9e6969e574a2e662a531dd0c67801a8
|
||||
@ -1792,7 +1792,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 6c44838adbe5dc482bc010e91a6dd7a0f777c989f443dd600740d2c783208e0d
|
||||
R 6f0a94a77ca115e013dd9613f7a15558
|
||||
P 6b24d3fb94e787d25e49501714780dfb0c0c99077102056aa68445f4808cdd57
|
||||
R 9d52b67b04a6d4eaf1458dab0e1e9545
|
||||
U drh
|
||||
Z 99764aebcfc0079a08b35b46938a27b1
|
||||
Z c7c257173b7231c9a9251f7733ad2173
|
||||
|
@ -1 +1 @@
|
||||
6b24d3fb94e787d25e49501714780dfb0c0c99077102056aa68445f4808cdd57
|
||||
06de44ec9e173992ca9afb89dd2b4e40d2a7e35512c7959603cdceb606f5dfbd
|
38
src/expr.c
38
src/expr.c
@ -2865,20 +2865,7 @@ int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){
|
||||
Vdbe *v = pParse->pVdbe;
|
||||
assert( v!=0 );
|
||||
|
||||
/* If this routine has already been coded, then invoke it as a subroutine. */
|
||||
if( ExprHasProperty(pExpr, EP_Subrtn) ){
|
||||
sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn, pExpr->y.sub.iAddr);
|
||||
return pExpr->iTable;
|
||||
}
|
||||
|
||||
/* Begin coding the subroutine */
|
||||
ExprSetProperty(pExpr, EP_Subrtn);
|
||||
pExpr->y.sub.regReturn = ++pParse->nMem;
|
||||
pExpr->y.sub.iAddr =
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1;
|
||||
VdbeComment((v, "return address"));
|
||||
|
||||
/* The evaluation of the IN/EXISTS/SELECT must be repeated every time it
|
||||
/* The evaluation of the EXISTS/SELECT must be repeated every time it
|
||||
** is encountered if any of the following is true:
|
||||
**
|
||||
** * The right-hand side is a correlated subquery
|
||||
@ -2889,6 +2876,21 @@ int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){
|
||||
** save the results, and reuse the same result on subsequent invocations.
|
||||
*/
|
||||
if( !ExprHasProperty(pExpr, EP_VarSelect) ){
|
||||
/* If this routine has already been coded, then invoke it as a
|
||||
** subroutine. */
|
||||
if( ExprHasProperty(pExpr, EP_Subrtn) ){
|
||||
sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn,
|
||||
pExpr->y.sub.iAddr);
|
||||
return pExpr->iTable;
|
||||
}
|
||||
|
||||
/* Begin coding the subroutine */
|
||||
ExprSetProperty(pExpr, EP_Subrtn);
|
||||
pExpr->y.sub.regReturn = ++pParse->nMem;
|
||||
pExpr->y.sub.iAddr =
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1;
|
||||
VdbeComment((v, "return address"));
|
||||
|
||||
addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
|
||||
}
|
||||
|
||||
@ -2939,11 +2941,11 @@ int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){
|
||||
ExprSetVVAProperty(pExpr, EP_NoReduce);
|
||||
if( addrOnce ){
|
||||
sqlite3VdbeJumpHere(v, addrOnce);
|
||||
}
|
||||
|
||||
/* Subroutine return */
|
||||
sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);
|
||||
sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
|
||||
/* Subroutine return */
|
||||
sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);
|
||||
sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
|
||||
}
|
||||
|
||||
return rReg;
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ do_eqp_test autoindex1-500.1 {
|
||||
} {
|
||||
QUERY PLAN
|
||||
|--SEARCH TABLE t501 USING INTEGER PRIMARY KEY (rowid=?)
|
||||
`--LIST SUBQUERY
|
||||
`--LIST SUBQUERY xxxxxx
|
||||
`--SCAN TABLE t502
|
||||
}
|
||||
do_eqp_test autoindex1-501 {
|
||||
@ -193,7 +193,7 @@ do_eqp_test autoindex1-501 {
|
||||
} {
|
||||
QUERY PLAN
|
||||
|--SCAN TABLE t501
|
||||
`--CORRELATED LIST SUBQUERY
|
||||
`--CORRELATED LIST SUBQUERY xxxxxx
|
||||
`--SEARCH TABLE t502 USING AUTOMATIC COVERING INDEX (y=?)
|
||||
}
|
||||
do_eqp_test autoindex1-502 {
|
||||
@ -203,7 +203,7 @@ do_eqp_test autoindex1-502 {
|
||||
} {
|
||||
QUERY PLAN
|
||||
|--SEARCH TABLE t501 USING INTEGER PRIMARY KEY (rowid=?)
|
||||
`--CORRELATED LIST SUBQUERY
|
||||
`--CORRELATED LIST SUBQUERY xxxxxx
|
||||
`--SCAN TABLE t502
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ det 3.3.1 {
|
||||
} {
|
||||
QUERY PLAN
|
||||
|--SCAN TABLE t1
|
||||
`--LIST SUBQUERY
|
||||
`--LIST SUBQUERY xxxxxx
|
||||
`--SCAN TABLE t2
|
||||
}
|
||||
det 3.3.2 {
|
||||
@ -294,7 +294,7 @@ det 3.3.2 {
|
||||
} {
|
||||
QUERY PLAN
|
||||
|--SCAN TABLE t1
|
||||
`--CORRELATED LIST SUBQUERY
|
||||
`--CORRELATED LIST SUBQUERY xxxxxx
|
||||
`--SCAN TABLE t2
|
||||
}
|
||||
det 3.3.3 {
|
||||
|
@ -235,9 +235,9 @@ do_eqp_test 5.1 {
|
||||
} {
|
||||
QUERY PLAN
|
||||
|--SEARCH TABLE d2 USING INDEX d2ab (a=? AND b=?)
|
||||
|--LIST SUBQUERY
|
||||
|--LIST SUBQUERY xxxxxx
|
||||
| `--SCAN TABLE d1
|
||||
`--LIST SUBQUERY
|
||||
`--LIST SUBQUERY xxxxxx
|
||||
`--SCAN TABLE d1
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user