/ Check-in [17890292]
Login

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

Overview
Comment:Ensure that automatic indexes are *not* considered when doing the the subqueries of the OR-optimization.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 17890292cf1776b3334fca7eff693cdbea458304
User & Date: drh 2015-03-02 17:25:00
Context
2015-03-02
22:06
Changes so that the amalgamation and the command-line shell build without modifications on VxWorks 7. Still gives a few compiler warnings, and still mostly untested on that platform. check-in: 7d92f1f1 user: drh tags: trunk
17:25
Ensure that automatic indexes are *not* considered when doing the the subqueries of the OR-optimization. check-in: 17890292 user: drh tags: trunk
2015-02-28
14:03
In the command-line shell, the inability to read ~/.sqliterc is no longer a fatal error. A warning is issued, but processing continues. check-in: 6bf62463 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/sqliteInt.h.

  2246   2246   #define WHERE_ORDERBY_MIN      0x0001 /* ORDER BY processing for min() func */
  2247   2247   #define WHERE_ORDERBY_MAX      0x0002 /* ORDER BY processing for max() func */
  2248   2248   #define WHERE_ONEPASS_DESIRED  0x0004 /* Want to do one-pass UPDATE/DELETE */
  2249   2249   #define WHERE_DUPLICATES_OK    0x0008 /* Ok to return a row more than once */
  2250   2250   #define WHERE_OMIT_OPEN_CLOSE  0x0010 /* Table cursors are already open */
  2251   2251   #define WHERE_FORCE_TABLE      0x0020 /* Do not use an index-only search */
  2252   2252   #define WHERE_ONETABLE_ONLY    0x0040 /* Only code the 1st table in pTabList */
  2253         -                          /*   0x0080 // not currently used */
         2253  +#define WHERE_NO_AUTOINDEX     0x0080 /* Disallow automatic indexes */
  2254   2254   #define WHERE_GROUPBY          0x0100 /* pOrderBy is really a GROUP BY */
  2255   2255   #define WHERE_DISTINCTBY       0x0200 /* pOrderby is really a DISTINCT clause */
  2256   2256   #define WHERE_WANT_DISTINCT    0x0400 /* All output needs to be distinct */
  2257   2257   #define WHERE_SORTBYGROUP      0x0800 /* Support sqlite3WhereIsSorted() */
  2258   2258   #define WHERE_REOPEN_IDX       0x1000 /* Try to use OP_ReopenIdx */
  2259   2259   
  2260   2260   /* Allowed return values from sqlite3WhereIsDistinct()

Changes to src/where.c.

  3610   3610   
  3611   3611       /* Run a separate WHERE clause for each term of the OR clause.  After
  3612   3612       ** eliminating duplicates from other WHERE clauses, the action for each
  3613   3613       ** sub-WHERE clause is to to invoke the main loop body as a subroutine.
  3614   3614       */
  3615   3615       wctrlFlags =  WHERE_OMIT_OPEN_CLOSE
  3616   3616                   | WHERE_FORCE_TABLE
  3617         -                | WHERE_ONETABLE_ONLY;
         3617  +                | WHERE_ONETABLE_ONLY
         3618  +                | WHERE_NO_AUTOINDEX;
  3618   3619       for(ii=0; ii<pOrWc->nTerm; ii++){
  3619   3620         WhereTerm *pOrTerm = &pOrWc->a[ii];
  3620   3621         if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
  3621   3622           WhereInfo *pSubWInfo;           /* Info for single OR-term scan */
  3622   3623           Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
  3623   3624           int j1 = 0;                     /* Address of jump operation */
  3624   3625           if( pAndExpr && !ExprHasProperty(pOrExpr, EP_FromJoin) ){
................................................................................
  4804   4805     }
  4805   4806     rSize = pTab->nRowLogEst;
  4806   4807     rLogSize = estLog(rSize);
  4807   4808   
  4808   4809   #ifndef SQLITE_OMIT_AUTOMATIC_INDEX
  4809   4810     /* Automatic indexes */
  4810   4811     if( !pBuilder->pOrSet
         4812  +   && (pWInfo->wctrlFlags & WHERE_NO_AUTOINDEX)==0
  4811   4813      && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0
  4812   4814      && pSrc->pIndex==0
  4813   4815      && !pSrc->viaCoroutine
  4814   4816      && !pSrc->notIndexed
  4815   4817      && HasRowid(pTab)
  4816   4818      && !pSrc->isCorrelated
  4817   4819      && !pSrc->isRecursive