From: drh <> Date: Tue, 22 Jun 2021 23:24:58 +0000 (+0000) Subject: When an index is used by all branches of the WHERE_MULTI_OR optimization and X-Git-Tag: version-3.37.0~384 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=415ac68ae8a5c6c9a8806cc34b01101ca0891bd3;p=thirdparty%2Fsqlite.git When an index is used by all branches of the WHERE_MULTI_OR optimization and becomes a covering index, make sure the index has been created prior to NULLing it in the OP_NullRow opcode of a LEFT JOIN. See [forum:/forumpost/0575376e07|forum post 0575376e07]. The covering-index for WHERE_MULTI_OR optimization was added by [62678be3df35cdcb]. Test cases are in the orindex01.test module of TH3. FossilOrigin-Name: 787c76a865dc51dbca4f30432d64783199c2efb1df4619e4bbaf32182977321e --- diff --git a/manifest b/manifest index 9a44b2b29f..3832754d7b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\ssqlite3_changes64()\sand\ssqlite3_total_changes64()\sAPI\sfunctions. -D 2021-06-22T18:32:05.878 +C When\san\sindex\sis\sused\sby\sall\sbranches\sof\sthe\sWHERE_MULTI_OR\soptimization\sand\nbecomes\sa\scovering\sindex,\smake\ssure\sthe\sindex\shas\sbeen\screated\sprior\sto\nNULLing\sit\sin\sthe\sOP_NullRow\sopcode\sof\sa\sLEFT\sJOIN.\s\sSee\n[forum:/forumpost/0575376e07|forum\spost\s0575376e07].\sThe\scovering-index\sfor\nWHERE_MULTI_OR\soptimization\swas\sadded\sby\s[62678be3df35cdcb].\s\sTest\scases\sare\nin\sthe\sorindex01.test\smodule\sof\sTH3. +D 2021-06-22T23:24:58.974 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -631,7 +631,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c c8ec20a1ca161d5635a4f19c2a4efec2e006e19a8a61f272bf6bce1c80ab7436 F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a F src/walker.c 7342becedf3f8a26f9817f08436bdf8b56ad69af83705f6b9320a0ad3092c2ac -F src/where.c 4caf843825c6292440113258fefaa6f747fd570c6915628957e42e39529988f5 +F src/where.c 07a4097fe42a01b1f99d2a136598654051f0bdcd6c17cbef7fa285a9cf21e4d2 F src/whereInt.h 9248161dd004f625ce5d3841ca9b99fed3fc8d61522cf76340fc5217dbe1375b F src/wherecode.c 9f1f65d11437b25cd0a1497a170514c785f19ce6ad9d3e6fc73719cb5a49012f F src/whereexpr.c 5a9c9f5d2dac4bcdcaae3035034b4667523f731df228e0bb1d4efc669efa9da5 @@ -1919,7 +1919,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 f662ff4746aaa43e63e20710b8cbfeeceab3183e953ac1685c41846d2e9d124c -R d7ab321cd3717ae98c57b82526dde848 -U dan -Z 21b9ccfdea30ed9e9c32e68e5722010b +P 48fdec22c966003f5577e0bf52906ef90df11e4e395723a646304e67ed976f37 +R 0c3802e30d8eb8e5ba1262b0a9261706 +U drh +Z 4d743af5a71a6dfd210821eb424bdaa1 diff --git a/manifest.uuid b/manifest.uuid index a38d536818..667e267c8a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -48fdec22c966003f5577e0bf52906ef90df11e4e395723a646304e67ed976f37 \ No newline at end of file +787c76a865dc51dbca4f30432d64783199c2efb1df4619e4bbaf32182977321e \ No newline at end of file diff --git a/src/where.c b/src/where.c index 5315520db4..467963fda5 100644 --- a/src/where.c +++ b/src/where.c @@ -5528,6 +5528,12 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ if( (ws & WHERE_INDEXED) || ((ws & WHERE_MULTI_OR) && pLevel->u.pCovidx) ){ + if( ws & WHERE_MULTI_OR ){ + Index *pIx = pLevel->u.pCovidx; + int iDb = sqlite3SchemaToIndex(db, pIx->pSchema); + sqlite3VdbeAddOp3(v, OP_ReopenIdx, pLevel->iIdxCur, pIx->tnum, iDb); + sqlite3VdbeSetP4KeyInfo(pParse, pIx); + } sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur); } if( pLevel->op==OP_Return ){