/ Check-in [aae38969]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Only disable the one-pass DELETE optimization if the WHERE clause contains a correlated subquery. Uncorrelated subqueries are allowed. This is a refinement of check-in [3f221f592a9a1] that is the fix for ticket [dc6ebeda9396087].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: aae389692a2ed2cc92151d51fb2cd5a16921c469
User & Date: drh 2016-05-04 14:45:30
Context
2016-05-04
19:04
Fix typo in comment. No changes to code. check-in: 6c43ba1c user: mistachkin tags: trunk
14:45
Only disable the one-pass DELETE optimization if the WHERE clause contains a correlated subquery. Uncorrelated subqueries are allowed. This is a refinement of check-in [3f221f592a9a1] that is the fix for ticket [dc6ebeda9396087]. check-in: aae38969 user: drh tags: trunk
14:20
Portability enhancements to the configure script on the amalgamation tarball. check-in: 7184c4b8 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/delete.c.

   370    370         assert( pIdx->pSchema==pTab->pSchema );
   371    371         sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);
   372    372       }
   373    373     }else
   374    374   #endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */
   375    375     {
   376    376       u16 wcf = WHERE_ONEPASS_DESIRED|WHERE_DUPLICATES_OK;
   377         -    if( pWhere && ExprHasProperty(pWhere, EP_Subquery) ) bComplex = 1;
          377  +    if( sNC.ncFlags & NC_VarSelect ) bComplex = 1;
   378    378       wcf |= (bComplex ? 0 : WHERE_ONEPASS_MULTIROW);
   379    379       if( HasRowid(pTab) ){
   380    380         /* For a rowid table, initialize the RowSet to an empty set */
   381    381         pPk = 0;
   382    382         nPk = 1;
   383    383         iRowSet = ++pParse->nMem;
   384    384         sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet);

Changes to src/resolve.c.

   759    759         if( ExprHasProperty(pExpr, EP_xIsSelect) ){
   760    760           int nRef = pNC->nRef;
   761    761           notValid(pParse, pNC, "subqueries", NC_IsCheck|NC_PartIdx|NC_IdxExpr);
   762    762           sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
   763    763           assert( pNC->nRef>=nRef );
   764    764           if( nRef!=pNC->nRef ){
   765    765             ExprSetProperty(pExpr, EP_VarSelect);
          766  +          pNC->ncFlags |= NC_VarSelect;
   766    767           }
   767    768         }
   768    769         break;
   769    770       }
   770    771       case TK_VARIABLE: {
   771    772         notValid(pParse, pNC, "parameters", NC_IsCheck|NC_PartIdx|NC_IdxExpr);
   772    773         break;

Changes to src/sqliteInt.h.

  2593   2593   */
  2594   2594   #define NC_AllowAgg  0x0001  /* Aggregate functions are allowed here */
  2595   2595   #define NC_PartIdx   0x0002  /* True if resolving a partial index WHERE */
  2596   2596   #define NC_IsCheck   0x0004  /* True if resolving names in a CHECK constraint */
  2597   2597   #define NC_InAggFunc 0x0008  /* True if analyzing arguments to an agg func */
  2598   2598   #define NC_HasAgg    0x0010  /* One or more aggregate functions seen */
  2599   2599   #define NC_IdxExpr   0x0020  /* True if resolving columns of CREATE INDEX */
         2600  +#define NC_VarSelect 0x0040  /* A correlated subquery has been seen */
  2600   2601   #define NC_MinMaxAgg 0x1000  /* min/max aggregates seen.  See note above */
  2601   2602   
  2602   2603   /*
  2603   2604   ** An instance of the following structure contains all information
  2604   2605   ** needed to generate code for a single SELECT statement.
  2605   2606   **
  2606   2607   ** nLimit is set to -1 if there is no LIMIT clause.  nOffset is set to 0.