]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Additional simplifications of the WHERE loop code generator logic for
authordrh <drh@noemail.net>
Fri, 23 Aug 2019 17:00:22 +0000 (17:00 +0000)
committerdrh <drh@noemail.net>
Fri, 23 Aug 2019 17:00:22 +0000 (17:00 +0000)
NULLS LAST.

FossilOrigin-Name: 1383680d927d7d703933be7653c0019199845e7f7e82bcc76d9ca3808093e9d8

manifest
manifest.uuid
src/wherecode.c

index 46a935e6098c16180b2a7f7778cbfd0bc615a562..3fb90c26844fb211be6c2e5a49f1141d28d9ed54 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Simplification\sof\sthe\sWHERE\sloop\scode\sgenerator\sfor\sNULLS\sLAST\ssaves\sa\nfew\sCPU\scycles\sand\sabout\sa\shundred\sbytes\sof\scode\sspace.
-D 2019-08-23T16:12:20.533
+C Additional\ssimplifications\sof\sthe\sWHERE\sloop\scode\sgenerator\slogic\sfor\nNULLS\sLAST.
+D 2019-08-23T17:00:22.277
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -611,7 +611,7 @@ F src/wal.h 606292549f5a7be50b6227bd685fa76e3a4affad71bb8ac5ce4cb5c79f6a176a
 F src/walker.c d5a94907dcac990e31976be9dc769d17f6a806782593d6aec9d760ee01ec22cd
 F src/where.c 10e21ac338582a4f87b2d09f09dd812c9bda0a0c4c456f54daeeee355afae733
 F src/whereInt.h 4a296fd4fa79fdcbc2b5e8c1b898901617655811223e1082b899c23ecb092217
-F src/wherecode.c f8ba85888b8a6843bce84e7e21f61d6c043c21c888871ad84fb911f45671e95d
+F src/wherecode.c 3bed0f377aacff188575bccc2f01d45ed5df353b52e8b2c39a22ff88ae3cfc25
 F src/whereexpr.c 2757afbd5cfdbb420f9d0392e1bd5f5c0e33dee50a8c692befc7e502308e449f
 F src/window.c 3ea716bb0dd5ffc8cdbaa48baffc525958b51bc61b2afd73a56baccfcd7ceb2f
 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
@@ -1837,7 +1837,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 bf875e1a259a4167694e06349458452dc36c1d38aa6843518d9ae46ce74e5559
-R f34508d6bf0c4c450df67caf81b0a3ce
+P e3ed2f496f51234a8f81d90d47ba603b06dbed38b8bd8f1934294379cde74d3a
+R 1ab18b69b8d15ca4e03875cc0023fa2f
 U drh
-Z 77866c600215002b5dd6dd0eeafd861f
+Z e7fe19284bcd51997b007393da65f48c
index c464a63a9768a7478049c2458d923d4859620cfb..80c0a7a60e62f5beaf0a6c91510b75f32aea7149 100644 (file)
@@ -1 +1 @@
-e3ed2f496f51234a8f81d90d47ba603b06dbed38b8bd8f1934294379cde74d3a
\ No newline at end of file
+1383680d927d7d703933be7653c0019199845e7f7e82bcc76d9ca3808093e9d8
\ No newline at end of file
index c1304c8af19a21e62409cbfef1eac1029cfeb0d9..9868428c5bfc9a171267379c71521abd2d1c5b3e 100644 (file)
@@ -1708,6 +1708,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
       assert( bSeekPastNull==0 || bStopAtNull==0 );
       if( regBignull ){
         assert( bSeekPastNull==1 || bStopAtNull==1 );
+        assert( bSeekPastNull==!bStopAtNull );
         assert( bStopAtNull==startEq );
         sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+2);
         op = aStartOp[(nConstraint>1)*4 + 2 + bRev];
@@ -1766,6 +1767,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
     /* Check if the index cursor is past the end of the range. */
     if( nConstraint ){
       if( regBignull ){
+        /* Except, skip the end-of-range check while doing the NULL-scan */
         sqlite3VdbeAddOp2(v, OP_IfNot, regBignull, sqlite3VdbeCurrentAddr(v)+3);
         VdbeComment((v, "If NULL-scan active"));
         VdbeCoverage(v);
@@ -1778,23 +1780,21 @@ Bitmask sqlite3WhereCodeOneLoopStart(
       testcase( op==OP_IdxLE );  VdbeCoverageIf(v, op==OP_IdxLE );
     }
     if( regBignull ){
+      /* During a NULL-scan, check to see if we have reached the end of
+      ** the NULLs */
+      assert( bSeekPastNull==!bStopAtNull );
+      assert( bSeekPastNull+bStopAtNull==1 );
+      assert( nConstraint+bSeekPastNull>0 );
       sqlite3VdbeAddOp2(v, OP_If, regBignull, sqlite3VdbeCurrentAddr(v)+2);
       VdbeComment((v, "If NULL-scan pending"));
       VdbeCoverage(v);
-      if( bStopAtNull ){
-        op = aEndOp[bRev*2 + 0];
-        assert( op==OP_IdxGE || op==OP_IdxLE );
-        sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
-        testcase( op==OP_IdxGE );  VdbeCoverageIf(v, op==OP_IdxGE );
-        testcase( op==OP_IdxLE );  VdbeCoverageIf(v, op==OP_IdxLE );
-      }else{
-        op = aEndOp[bRev*2 + endEq];
-        sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint+1);
-        testcase( op==OP_IdxGT );  VdbeCoverageIf(v, op==OP_IdxGT );
-        testcase( op==OP_IdxGE );  VdbeCoverageIf(v, op==OP_IdxGE );
-        testcase( op==OP_IdxLT );  VdbeCoverageIf(v, op==OP_IdxLT );
-        testcase( op==OP_IdxLE );  VdbeCoverageIf(v, op==OP_IdxLE );
-      }
+      op = aEndOp[bRev*2 + bSeekPastNull];
+      sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase,
+                           nConstraint+bSeekPastNull);
+      testcase( op==OP_IdxGT );  VdbeCoverageIf(v, op==OP_IdxGT );
+      testcase( op==OP_IdxGE );  VdbeCoverageIf(v, op==OP_IdxGE );
+      testcase( op==OP_IdxLT );  VdbeCoverageIf(v, op==OP_IdxLT );
+      testcase( op==OP_IdxLE );  VdbeCoverageIf(v, op==OP_IdxLE );
     }
 
     if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){