From: drh Date: Sun, 22 Dec 2019 18:55:04 +0000 (+0000) Subject: Fix to the optimization of check-in [a47efb7c8520a011] that reads the values X-Git-Tag: version-3.31.0~178 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6c1c85ca483154aafa41883253a941f196fa6d03;p=thirdparty%2Fsqlite.git Fix to the optimization of check-in [a47efb7c8520a011] that reads the values of expressions used in an index-on-expression directly from the index rather than recomputing the value. If the expression has a top-level COLLATE or unlikely() operator, be sure to clear the corresponding flags prior to converting it into a TK_COLUMN expression. Failure to do this is most likely harmless in production, but might cause an assertion fault in debugging builds. Ticket [b0cb8aff561a6dcd]. Test cases in TH3. FossilOrigin-Name: 56539e1c132632c075efc217ad5951a35e4459605ac128914aec3a7be1e25718 --- diff --git a/manifest b/manifest index 5d6992fda0..ea8f8b7844 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Back\sout\sthe\sasserts\sof\scheck-ins\s[a500893b6f64aced]\sand\s[d9c9fe9f5ad3fc91]\nas\sticket\s[1b06916e01c82b66]\sdemonstrates\sa\scase\sthat\srefutes\sthem. -D 2019-12-22T18:23:30.350 +C Fix\sto\sthe\soptimization\sof\scheck-in\s[a47efb7c8520a011]\sthat\sreads\sthe\svalues\nof\sexpressions\sused\sin\san\sindex-on-expression\sdirectly\sfrom\sthe\sindex\srather\nthan\srecomputing\sthe\svalue.\s\sIf\sthe\sexpression\shas\sa\stop-level\sCOLLATE\sor\nunlikely()\soperator,\sbe\ssure\sto\sclear\sthe\scorresponding\sflags\sprior\sto\nconverting\sit\sinto\sa\sTK_COLUMN\sexpression.\s\sFailure\sto\sdo\sthis\sis\smost\slikely\nharmless\sin\sproduction,\sbut\smight\scause\san\sassertion\sfault\sin\sdebugging\sbuilds.\nTicket\s[b0cb8aff561a6dcd].\s\sTest\scases\sin\sTH3. +D 2019-12-22T18:55:04.170 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -615,7 +615,7 @@ F src/wal.h 606292549f5a7be50b6227bd685fa76e3a4affad71bb8ac5ce4cb5c79f6a176a F src/walker.c a137468bf36c92e64d2275caa80c83902e3a0fc59273591b96c6416d3253d05d F src/where.c c51ebd505c8417285ca1db8f94933a12224bf636ad93f27d821c07f93d59c035 F src/whereInt.h 4a296fd4fa79fdcbc2b5e8c1b898901617655811223e1082b899c23ecb092217 -F src/wherecode.c 9c274ea84ef8519b37852038fbd610b47f11cf8aaf7651f10125c445fa5a61bd +F src/wherecode.c c4cb79b7c93d0f4ec93d9d84d10deb61053c8563c12b244292c14f9ad1032093 F src/whereexpr.c 989235ee5fade9663a01d9443763a82ba5a72619bf3edda67ebd043936d33575 F src/window.c da010455914c81037dcb5b0c6f4273f8a32c94567865c46a60060b937b018a96 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -1852,7 +1852,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 a982e6434cd66bfbe94d455f538bcbc4360b91572062d92acae6b77e9560e65d -R 04ec53e6dc7d44d1c22aa14f44994155 +P ddb17d92df194337a103c561ef46ced00db5e67e4551e82de7cb5ad7f457dd5f +R 19b03f420b018ba3e702a8b1fc6e710f U drh -Z b849b4ce029d462a595dd5bf3b2ce973 +Z 7a13e581226b652e9598d2193dc4abae diff --git a/manifest.uuid b/manifest.uuid index eb1aa519b0..61d33c1966 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ddb17d92df194337a103c561ef46ced00db5e67e4551e82de7cb5ad7f457dd5f \ No newline at end of file +56539e1c132632c075efc217ad5951a35e4459605ac128914aec3a7be1e25718 \ No newline at end of file diff --git a/src/wherecode.c b/src/wherecode.c index a8ef581da3..2f2a27271b 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -1145,6 +1145,9 @@ static int whereIndexExprTransNode(Walker *p, Expr *pExpr){ pExpr->iTable = pX->iIdxCur; pExpr->iColumn = pX->iIdxCol; pExpr->y.pTab = 0; + testcase( ExprHasProperty(pExpr, EP_Skip) ); + testcase( ExprHasProperty(pExpr, EP_Unlikely) ); + ExprClearProperty(pExpr, EP_Skip|EP_Unlikely); return WRC_Prune; }else{ return WRC_Continue;