/ Check-in [d4a5af69]
Login

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

Overview
Comment:Replace the magic number (-2) with its symbol XN_EXPR in the exprMightBeIndexed() routine. No logic changes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rowvalue
Files: files | file ages | folders
SHA1: d4a5af69cc3bde6f8c02075c07b4d47a0252392d
User & Date: drh 2016-08-19 19:58:06
Context
2016-08-20
00:07
Change the way TK_SELECT_COLUMN is handled so that the subquery is only generated once even if part of the vector comparison is used for indexing and the other part is now. This change also is a pathway to vector assignment in UPDATE statements. check-in: d8feea7d user: drh tags: rowvalue
2016-08-19
19:58
Replace the magic number (-2) with its symbol XN_EXPR in the exprMightBeIndexed() routine. No logic changes. check-in: d4a5af69 user: drh tags: rowvalue
19:12
Improved comments on sqlite3CodeSubquery(). No changes to code. check-in: acea4ee1 user: drh tags: rowvalue
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/whereexpr.c.

   819    819   
   820    820   /*
   821    821   ** Expression pExpr is one operand of a comparison operator that might
   822    822   ** be useful for indexing.  This routine checks to see if pExpr appears
   823    823   ** in any index.  Return TRUE (1) if pExpr is an indexed term and return
   824    824   ** FALSE (0) if not.  If TRUE is returned, also set *piCur to the cursor
   825    825   ** number of the table that is indexed and *piColumn to the column number
   826         -** of the column that is indexed, or -2 if an expression is being indexed.
          826  +** of the column that is indexed, or XN_EXPR (-2) if an expression is being
          827  +** indexed.
   827    828   **
   828    829   ** If pExpr is a TK_COLUMN column reference, then this routine always returns
   829    830   ** true even if that particular column is not indexed, because the column
   830    831   ** might be added to an automatic index later.
   831    832   */
   832    833   static int exprMightBeIndexed(
   833    834     SrcList *pFrom,        /* The FROM clause */
................................................................................
   857    858     if( mPrereq==0 ) return 0;                 /* No table references */
   858    859     if( (mPrereq&(mPrereq-1))!=0 ) return 0;   /* Refs more than one table */
   859    860     for(i=0; mPrereq>1; i++, mPrereq>>=1){}
   860    861     iCur = pFrom->a[i].iCursor;
   861    862     for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){
   862    863       if( pIdx->aColExpr==0 ) continue;
   863    864       for(i=0; i<pIdx->nKeyCol; i++){
   864         -      if( pIdx->aiColumn[i]!=(-2) ) continue;
          865  +      if( pIdx->aiColumn[i]!=XN_EXPR ) continue;
   865    866         if( sqlite3ExprCompare(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){
   866    867           *piCur = iCur;
   867         -        *piColumn = -2;
          868  +        *piColumn = XN_EXPR;
   868    869           return 1;
   869    870         }
   870    871       }
   871    872     }
   872    873     return 0;
   873    874   }
   874    875