/ Check-in [6937677c]
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:Add missing comments and make some code on this branch clearer.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rowvalue
Files: files | file ages | folders
SHA1: 6937677cc2c2db6b21f997559f88a339466cd15b
User & Date: dan 2016-08-02 16:18:35
Context
2016-08-02
16:24
Merge latest trunk changes into this branch. check-in: d468101b user: dan tags: rowvalue
16:18
Add missing comments and make some code on this branch clearer. check-in: 6937677c user: dan tags: rowvalue
2016-08-01
20:14
Fix a problem with vector range constraints involving the rowid column. And other issues. check-in: 3ef75d45 user: dan tags: rowvalue
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/whereexpr.c.

   827    827   **
   828    828   ** If pExpr is a TK_COLUMN column reference, then this routine always returns
   829    829   ** true even if that particular column is not indexed, because the column
   830    830   ** might be added to an automatic index later.
   831    831   */
   832    832   static int exprMightBeIndexed(
   833    833     SrcList *pFrom,        /* The FROM clause */
   834         -  int op,
          834  +  int op,                /* The specific comparison operator */
   835    835     Bitmask mPrereq,       /* Bitmask of FROM clause terms referenced by pExpr */
   836    836     Expr *pExpr,           /* An operand of a comparison operator */
   837    837     int *piCur,            /* Write the referenced table cursor number here */
   838    838     int *piColumn          /* Write the referenced table column number here */
   839    839   ){
   840    840     Index *pIdx;
   841    841     int i;
................................................................................
  1190   1190         pTerm = &pWC->a[idxTerm];
  1191   1191         pTerm->wtFlags |= TERM_COPIED;
  1192   1192         pNewTerm->prereqAll = pTerm->prereqAll;
  1193   1193       }
  1194   1194     }
  1195   1195   #endif /* SQLITE_OMIT_VIRTUALTABLE */
  1196   1196   
         1197  +  /* If there is a vector == or IS term - e.g. "(a, b) == (?, ?)" - create
         1198  +  ** a virtual term for each component comparison - "a = ?" and "b = ?".
         1199  +  ** This is only required if at least one side of the comparison operation
         1200  +  ** is not a sub-select.  */
  1197   1201     if( pWC->op==TK_AND 
  1198   1202     && (pExpr->op==TK_EQ || pExpr->op==TK_IS)
  1199   1203     && sqlite3ExprIsVector(pExpr->pLeft)
  1200   1204     && ( (pExpr->pLeft->flags & EP_xIsSelect)==0 
  1201   1205       || (pExpr->pRight->flags & EP_xIsSelect)==0
  1202   1206     )){
  1203   1207       int nLeft = sqlite3ExprVectorSize(pExpr->pLeft);
................................................................................
  1213   1217           idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);
  1214   1218           exprAnalyze(pSrc, pWC, idxNew);
  1215   1219           markTermAsChild(pWC, idxNew, idxTerm);
  1216   1220         }
  1217   1221       }
  1218   1222     }
  1219   1223   
         1224  +  /* If there is a vector IN term - e.g. "(a, b) IN (SELECT ...)" - create
         1225  +  ** a virtual term for each vector component. The expression object
         1226  +  ** used by each such virtual term is pExpr (the full vector IN(...) 
         1227  +  ** expression). The WhereTerm.iField variable identifies the index within
         1228  +  ** the vector on the LHS that the virtual term represents.  */
  1220   1229     if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0
  1221   1230      && pExpr->pLeft->op==TK_VECTOR
  1222   1231     ){
  1223   1232       int i;
  1224   1233       for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
  1225   1234         int idxNew;
  1226   1235         idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);