From: drh <> Date: Wed, 8 Jun 2022 12:20:49 +0000 (+0000) Subject: Update the routine that determines whether or not a partial index can be used X-Git-Tag: version-3.39.0~50 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=644817721edc316fddc1b2059415479ca49dc167;p=thirdparty%2Fsqlite.git Update the routine that determines whether or not a partial index can be used so that it is not specific to LEFT JOIN. FossilOrigin-Name: 5a107fd7fa01554d73fefc0611e5797b8c23e782ce0df3aeba7e2f288675b2ce --- diff --git a/manifest b/manifest index b33a06de2e..371cdbffe8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\squery\sflattener\sto\sdeal\swith\sa\sRIGHT\sJOIN\scorner\scase\sdescribed\nby\s[forum:/forumpost/323f86cc30|forum\spost\s323f86cc30]. -D 2022-06-07T13:09:58.839 +C Update\sthe\sroutine\sthat\sdetermines\swhether\sor\snot\sa\spartial\sindex\scan\sbe\sused\nso\sthat\sit\sis\snot\sspecific\sto\sLEFT\sJOIN. +D 2022-06-08T12:20:49.467 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -657,7 +657,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c b9df133a705093da8977da5eb202eaadb844839f1c7297c08d33471f5491843d F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a F src/walker.c f890a3298418d7cba3b69b8803594fdc484ea241206a8dfa99db6dd36f8cbb3b -F src/where.c 01eea25cefc6fb5a081213749cfa29f14ed3092206f18ebb38abbb31c137f594 +F src/where.c d0fcb3ae11f3bd5bb65ad64fec947c89280ebdd399135818292ad0ccd9d34b8e F src/whereInt.h b48ca529ffe293c18cbfa8326af18a09e39910de66fb3e96ef788c7cbf8ef3a7 F src/wherecode.c 0b09abfcb88c61c6a6984a3e065786631ff35495e9bdf865e6b74ab0a1299c5b F src/whereexpr.c 20255cf03e0b765b742301197d165511ff99e95da0d7ee9c8a2ebc1e888dd049 @@ -1975,8 +1975,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7f97cb67d01a11f1b7e5b5f05824f9adbc6e4689d1809d60ceda50a595ba6d4a -R 413a4b040170a880590160583cee3c05 +P 3f45007d544e5f787d5837b4d9f484ba473d69cdba83c229228e9c2f6b972b75 +R 59bfe00807aec47ed2053787823cbd72 U drh -Z 0662644a85d84e671b5268c6a964cd54 +Z c20ac49fc300aade71842785e438fa8e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index bec5ee0b5d..3fa0c98d33 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3f45007d544e5f787d5837b4d9f484ba473d69cdba83c229228e9c2f6b972b75 \ No newline at end of file +5a107fd7fa01554d73fefc0611e5797b8c23e782ce0df3aeba7e2f288675b2ce \ No newline at end of file diff --git a/src/where.c b/src/where.c index 58aec128ed..ce32f8bfcb 100644 --- a/src/where.c +++ b/src/where.c @@ -3210,7 +3210,7 @@ static int indexMightHelpWithOrderBy( */ static int whereUsablePartialIndex( int iTab, /* The table for which we want an index */ - int isLeft, /* True if iTab is the right table of a LEFT JOIN */ + u8 jointype, /* The JT_* flags on the join */ WhereClause *pWC, /* The WHERE clause of the query */ Expr *pWhere /* The WHERE clause from the partial index */ ){ @@ -3218,7 +3218,7 @@ static int whereUsablePartialIndex( WhereTerm *pTerm; Parse *pParse = pWC->pWInfo->pParse; while( pWhere->op==TK_AND ){ - if( !whereUsablePartialIndex(iTab,isLeft,pWC,pWhere->pLeft) ) return 0; + if( !whereUsablePartialIndex(iTab,jointype,pWC,pWhere->pLeft) ) return 0; pWhere = pWhere->pRight; } if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0; @@ -3226,7 +3226,7 @@ static int whereUsablePartialIndex( Expr *pExpr; pExpr = pTerm->pExpr; if( (!ExprHasProperty(pExpr, EP_OuterON) || pExpr->w.iJoin==iTab) - && (isLeft==0 || ExprHasProperty(pExpr, EP_OuterON)) + && ((jointype & JT_OUTER)==0 || ExprHasProperty(pExpr, EP_OuterON)) && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab) && (pTerm->wtFlags & TERM_VNULL)==0 ){ @@ -3392,9 +3392,8 @@ static int whereLoopAddBtree( for(; rc==SQLITE_OK && pProbe; pProbe=(pSrc->fg.isIndexedBy ? 0 : pProbe->pNext), iSortIdx++ ){ - int isLeft = (pSrc->fg.jointype & JT_OUTER)!=0; if( pProbe->pPartIdxWhere!=0 - && !whereUsablePartialIndex(pSrc->iCursor, isLeft, pWC, + && !whereUsablePartialIndex(pSrc->iCursor, pSrc->fg.jointype, pWC, pProbe->pPartIdxWhere) ){ testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */