/ Check-in [8790368b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the SQLITE_ENABLE_EARLY_CURSOR_CLOSE compile-time option which causes read cursors to be closed after their usefulness ends during a two-pass UPDATE.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | branch-3.26
Files: files | file ages | folders
SHA3-256:8790368b4a96606f6c925db217a8e8badb800ed0da51d1c97aa38982cbbabd71
User & Date: mistachkin 2019-01-22 18:20:22
Context
2019-01-22
18:20
Add the SQLITE_ENABLE_EARLY_CURSOR_CLOSE compile-time option which causes read cursors to be closed after their usefulness ends during a two-pass UPDATE. Leaf check-in: 8790368b user: mistachkin tags: branch-3.26
2019-01-17
19:33
Add the SQLITE_ENABLE_EARLY_CURSOR_CLOSE compile-time option which causes read cursors to be closed after their usefulness ends during a two-pass UPDATE. check-in: 7def6c8e user: drh tags: trunk
2018-12-12
11:57
OSSFuzz found a case where an assert() inside sqlite3ExprCompare() can be true. Test case added to TH3. check-in: bc891ac6 user: drh tags: branch-3.26
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

  5254   5254       */
  5255   5255       if( pTabItem->fg.viaCoroutine ){
  5256   5256         testcase( pParse->db->mallocFailed );
  5257   5257         translateColumnToCopy(pParse, pLevel->addrBody, pLevel->iTabCur,
  5258   5258                               pTabItem->regResult, 0);
  5259   5259         continue;
  5260   5260       }
         5261  +
         5262  +#ifdef SQLITE_ENABLE_EARLY_CURSOR_CLOSE
         5263  +    /* Close all of the cursors that were opened by sqlite3WhereBegin.
         5264  +    ** Except, do not close cursors that will be reused by the OR optimization
         5265  +    ** (WHERE_OR_SUBCLAUSE).  And do not close the OP_OpenWrite cursors
         5266  +    ** created for the ONEPASS optimization.
         5267  +    */
         5268  +    if( (pTab->tabFlags & TF_Ephemeral)==0
         5269  +     && pTab->pSelect==0
         5270  +     && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0
         5271  +    ){
         5272  +      int ws = pLoop->wsFlags;
         5273  +      if( pWInfo->eOnePass==ONEPASS_OFF && (ws & WHERE_IDX_ONLY)==0 ){
         5274  +        sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor);
         5275  +      }
         5276  +      if( (ws & WHERE_INDEXED)!=0
         5277  +       && (ws & (WHERE_IPK|WHERE_AUTO_INDEX))==0 
         5278  +       && pLevel->iIdxCur!=pWInfo->aiCurOnePass[1]
         5279  +      ){
         5280  +        sqlite3VdbeAddOp1(v, OP_Close, pLevel->iIdxCur);
         5281  +      }
         5282  +    }
         5283  +#endif
  5261   5284   
  5262   5285       /* If this scan uses an index, make VDBE code substitutions to read data
  5263   5286       ** from the index instead of from the table where possible.  In some cases
  5264   5287       ** this optimization prevents the table from ever being read, which can
  5265   5288       ** yield a significant performance boost.
  5266   5289       ** 
  5267   5290       ** Calls to the code generator in between sqlite3WhereBegin and