1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-18 10:21:03 +03:00

Strengthen check-in [83da4d4104ee1870] by ignoring *all* WHERE-clause

constraints for a virtual table that is the right table of a LEFT JOIN, 
as such constraints are never useful.
This fixes an issue discovered by Manuel Rigger.

FossilOrigin-Name: 840de36df1aaeb4bad9a7c18e97cc560ba3b8c629c4520a05bc456d67b3347b9
This commit is contained in:
drh
2019-12-11 16:22:53 +00:00
parent a1ca00edd5
commit d4dae75f79
3 changed files with 14 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
C When\strying\sto\sdrop\sa\svirtual\stable\sthat\shas\sno\sxDestroy\smethod,\sinvoke\nthe\sxDisconnect\smethod\srather\sthan\sdoing\snothing,\sto\savoid\sa\smemory\sleak. C Strengthen\scheck-in\s[83da4d4104ee1870]\sby\signoring\s*all*\sWHERE-clause\nconstraints\sfor\sa\svirtual\stable\sthat\sis\sthe\sright\stable\sof\sa\sLEFT\sJOIN,\s\nas\ssuch\sconstraints\sare\snever\suseful.\nThis\sfixes\san\sissue\sdiscovered\sby\sManuel\sRigger.
D 2019-12-11T15:07:09.012 D 2019-12-11T16:22:53.344
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -613,7 +613,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
F src/wal.c 15a2845769f51ba132f9cf0b2c7a6887a91fc8437892dbcce9fcdc68b66d60a1 F src/wal.c 15a2845769f51ba132f9cf0b2c7a6887a91fc8437892dbcce9fcdc68b66d60a1
F src/wal.h 606292549f5a7be50b6227bd685fa76e3a4affad71bb8ac5ce4cb5c79f6a176a F src/wal.h 606292549f5a7be50b6227bd685fa76e3a4affad71bb8ac5ce4cb5c79f6a176a
F src/walker.c a137468bf36c92e64d2275caa80c83902e3a0fc59273591b96c6416d3253d05d F src/walker.c a137468bf36c92e64d2275caa80c83902e3a0fc59273591b96c6416d3253d05d
F src/where.c bb2d3c08de9ae57f6ff17459cefd9e38e82d3e7aaa544bc49503b6fdaaf2c800 F src/where.c c51ebd505c8417285ca1db8f94933a12224bf636ad93f27d821c07f93d59c035
F src/whereInt.h 4a296fd4fa79fdcbc2b5e8c1b898901617655811223e1082b899c23ecb092217 F src/whereInt.h 4a296fd4fa79fdcbc2b5e8c1b898901617655811223e1082b899c23ecb092217
F src/wherecode.c 7efa97f4dc2f95548611deba68f0210ab357725899a9bae5391a525e48271875 F src/wherecode.c 7efa97f4dc2f95548611deba68f0210ab357725899a9bae5391a525e48271875
F src/whereexpr.c 39b6a538804c6e1248c22b33e09d00f89ae6a099c849c4d841ce3995562287b4 F src/whereexpr.c 39b6a538804c6e1248c22b33e09d00f89ae6a099c849c4d841ce3995562287b4
@@ -1852,7 +1852,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 0457e7d1961ab1f63e31d9028a9064a895f5c3fcfb56ba25e4f37e90197e3a9f P 1fa29a5f2a89b6a1ee067f9cb86de1b66455126349efe3502599fc7ad224170c
R dfec9545ec065160dafed7d961680e93 R 1705b0f74ba75d9e6c5b4546a5dce87c
U drh U drh
Z 42480cb067277792c63c10d88dc25575 Z 019e789a4ccea6f1cebc90f58acb2b95

View File

@@ -1 +1 @@
1fa29a5f2a89b6a1ee067f9cb86de1b66455126349efe3502599fc7ad224170c 840de36df1aaeb4bad9a7c18e97cc560ba3b8c629c4520a05bc456d67b3347b9

View File

@@ -979,18 +979,13 @@ static sqlite3_index_info *allocateIndexInfo(
testcase( pTerm->eOperator & WO_ALL ); testcase( pTerm->eOperator & WO_ALL );
if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue; if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
if( pTerm->wtFlags & TERM_VNULL ) continue; if( pTerm->wtFlags & TERM_VNULL ) continue;
/* tag-20191211-002: WHERE-clause constraints are not useful to the
** right-hand table of a LEFT JOIN. See tag-20191211-001 for the
** equivalent restriction for ordinary tables. */
if( (pSrc->fg.jointype & JT_LEFT)!=0 if( (pSrc->fg.jointype & JT_LEFT)!=0
&& !ExprHasProperty(pTerm->pExpr, EP_FromJoin) && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
&& (pTerm->eOperator & (WO_IS|WO_ISNULL))
){ ){
/* An "IS" term in the WHERE clause where the virtual table is the rhs
** of a LEFT JOIN. Do not pass this term to the virtual table
** implementation, as this can lead to incorrect results from SQL such
** as:
**
** "LEFT JOIN vtab WHERE vtab.col IS NULL" */
testcase( pTerm->eOperator & WO_ISNULL );
testcase( pTerm->eOperator & WO_IS );
continue; continue;
} }
assert( pTerm->u.leftColumn>=(-1) ); assert( pTerm->u.leftColumn>=(-1) );
@@ -2472,9 +2467,9 @@ static int whereLoopAddBtreeIndex(
** to mix with a lower range bound from some other source */ ** to mix with a lower range bound from some other source */
if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue; if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue;
/* Do not allow constraints from the WHERE clause to be used by the /* tag-20191211-001: Do not allow constraints from the WHERE clause to
** right table of a LEFT JOIN. Only constraints in the ON clause are ** be used by the right table of a LEFT JOIN. Only constraints in the
** allowed */ ** ON clause are allowed. See tag-20191211-002 for the vtab equivalent. */
if( (pSrc->fg.jointype & JT_LEFT)!=0 if( (pSrc->fg.jointype & JT_LEFT)!=0
&& !ExprHasProperty(pTerm->pExpr, EP_FromJoin) && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
){ ){