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

Fix a problem with processing a "vtab.col IS NULL" expression within

the WHERE clause of a query when "vtab" is a virtual table on the rhs of a
LEFT JOIN.

FossilOrigin-Name: 83da4d4104ee1870a2a95bb5fa15ee6584c655d8b314b6b8ab97592dad4ee811
This commit is contained in:
dan
2018-09-10 12:17:16 +00:00
parent f7ded14792
commit eb3fe0b9d4
4 changed files with 130 additions and 8 deletions

View File

@@ -966,6 +966,18 @@ static sqlite3_index_info *allocateIndexInfo(
testcase( pTerm->eOperator & WO_ALL );
if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
if( pTerm->wtFlags & TERM_VNULL ) continue;
if( (pSrc->fg.jointype & JT_LEFT)!=0
&& !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" */
continue;
}
assert( pTerm->u.leftColumn>=(-1) );
pIdxCons[j].iColumn = pTerm->u.leftColumn;
pIdxCons[j].iTermOffset = i;