/ Check-in [7def6c8e]
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 | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7def6c8edd85f19ee09038e01541f75b1f71ca39b9fb782b8f0fcac89207c353
User & Date: drh 2019-01-17 19:33:16
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
20:06
Fix another corruption related crash in fts5. check-in: 4538d9af user: dan tags: trunk
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
19:11
Fix a buffer overwrite that could occur when running an fts5 prefix query against a corrupt database. check-in: 3910b563 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

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