]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Enable SQLITE_INDEX_CONSTRAINT_LIMIT/OFFSET even if there are vector
authordrh <>
Fri, 28 Jan 2022 13:18:40 +0000 (13:18 +0000)
committerdrh <>
Fri, 28 Jan 2022 13:18:40 +0000 (13:18 +0000)
comparison operators in the WHERE clause.  Also:  Do not enable
sqlite3_vtab_rhs_value() for LIMIT/OFFSET if the value is negative, as this
violates an invariant on Expr.u.iValue.

FossilOrigin-Name: 140480b3ec5466513b165d4818f1180cff6e4a5edcd47efb54cbff74a7107507

manifest
manifest.uuid
src/whereexpr.c

index f1f49fa5021ed56633b04fe126e92b407fb2c624..278f5cdb0a80fbbbdc332265454afa7e0f792817 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Query\splanner\salways\shonors\sthe\saConstraintUsage[].omit\sflag\sfor\sthe\nSQLITE_INDEX_CONSTRAINT_OFFSET\sconstraint.
-D 2022-01-27T21:18:14.656
+C Enable\sSQLITE_INDEX_CONSTRAINT_LIMIT/OFFSET\seven\sif\sthere\sare\svector\ncomparison\soperators\sin\sthe\sWHERE\sclause.\s\sAlso:\s\sDo\snot\senable\nsqlite3_vtab_rhs_value()\sfor\sLIMIT/OFFSET\sif\sthe\svalue\sis\snegative,\sas\sthis\nviolates\san\sinvariant\son\sExpr.u.iValue.
+D 2022-01-28T13:18:40.313
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -642,7 +642,7 @@ F src/walker.c f890a3298418d7cba3b69b8803594fdc484ea241206a8dfa99db6dd36f8cbb3b
 F src/where.c f61ca6dbb4bbb7171aa5f5459982d8d98aac24852572bcee250f9c469a1963ba
 F src/whereInt.h 0748a6fce98b41862445906922a809146ff7ef4de16ed9022b0bc4e5c43aa60a
 F src/wherecode.c c313ccf5ed13dc7e88c64f93733f414dee369a212508a866878696d83c64fc36
-F src/whereexpr.c 391d04108e4a5a701d2fad374ff54db8629bce12b55a7ee30a478d440ea4bfe0
+F src/whereexpr.c 869596d69a498604fe3e00ff06475038560732227bc42de0cf5dc92248740a4f
 F src/window.c dfaec4abc6012cbc18e4a202ca3a5d5a0efcc4011d86a06d882ddaab8aedee4d
 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627
@@ -1942,8 +1942,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 b2d37c086c87fe4aee013bba4eab26f642207cd2a797fe4888a6ef868884c191
-R 87c4173ca514b2a053765a7d35c4d8eb
+P 38c5151eb8cc789ad082a1b40d16b2ddb55454219bd685b6e420995af6a15f55
+R 05c94023401bdef7db1e43fcf139e4c2
 U drh
-Z 05d67635fa5a91d132911c78dd294cd6
+Z b99686de01cbc6d8d45082533904b9d3
 # Remove this line to create a well-formed Fossil manifest.
index 5e209241f674d0239e0bbe92b743267cef01b4f3..a2fc43053650c12bd72446207559d13b77b31eba 100644 (file)
@@ -1 +1 @@
-38c5151eb8cc789ad082a1b40d16b2ddb55454219bd685b6e420995af6a15f55
\ No newline at end of file
+140480b3ec5466513b165d4818f1180cff6e4a5edcd47efb54cbff74a7107507
\ No newline at end of file
index 8381994e2b630d0a76197efa077b9613268463bf..d47cfd7e9247692fab6f55c0cc7668742a728518 100644 (file)
@@ -1379,7 +1379,10 @@ static void exprAnalyze(
   ** no longer used.
   **
   ** This is only required if at least one side of the comparison operation
-  ** is not a sub-select.  */
+  ** is not a sub-select.
+  **
+  ** tag-20220128a
+  */
   if( (pExpr->op==TK_EQ || pExpr->op==TK_IS)
    && (nLeft = sqlite3ExprVectorSize(pExpr->pLeft))>1
    && sqlite3ExprVectorSize(pExpr->pRight)==nLeft
@@ -1545,7 +1548,7 @@ void whereAddLimitExpr(
   Expr *pNew;
   int iVal = 0;
 
-  if( sqlite3ExprIsInteger(pExpr, &iVal) ){
+  if( sqlite3ExprIsInteger(pExpr, &iVal) && iVal>=0 ){
     Expr *pVal = sqlite3Expr(db, TK_INTEGER, 0);
     if( pVal==0 ) return;
     ExprSetProperty(pVal, EP_IntValue);
@@ -1598,6 +1601,13 @@ void sqlite3WhereAddLimit(WhereClause *pWC, Select *p){
 
     /* Check condition (4). Return early if it is not met. */
     for(ii=0; ii<pWC->nTerm; ii++){
+      if( pWC->a[ii].wtFlags & TERM_CODED ){
+        /* This term is a vector operation that has been decomposed into
+        ** other, subsequent terms.  It can be ignored. See tag-20220128a */
+        assert( pWC->a[ii].wtFlags & TERM_VIRTUAL );
+        assert( pWC->a[ii].eOperator==0 );
+        continue;
+      }
       if( pWC->a[ii].leftCursor!=iCsr ) return;
     }