/ Check-in [a3ffd283]
Login

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

Overview
Comment:Improvements to the vector comparison splitter in exprAnalyze().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rowvalue
Files: files | file ages | folders
SHA1: a3ffd283bc931b04170ef737e56bced33d27f06d
User & Date: drh 2016-08-20 12:00:05
Context
2016-08-20
15:01
Fix a segfault that could occur if a query that used a vector comparison contained certain types of syntax errors. check-in: 203f07c5 user: dan tags: rowvalue
12:00
Improvements to the vector comparison splitter in exprAnalyze(). check-in: a3ffd283 user: drh tags: rowvalue
01:06
Improvements to comments. No code changes. check-in: 4165d20f user: drh tags: rowvalue
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/whereexpr.c.

  1169   1169         pTerm->wtFlags |= TERM_COPIED;
  1170   1170         pNewTerm->prereqAll = pTerm->prereqAll;
  1171   1171       }
  1172   1172     }
  1173   1173   #endif /* SQLITE_OMIT_VIRTUALTABLE */
  1174   1174   
  1175   1175     /* If there is a vector == or IS term - e.g. "(a, b) == (?, ?)" - create
  1176         -  ** a virtual term for each component comparison - "a = ?" and "b = ?".
         1176  +  ** new terms for each component comparison - "a = ?" and "b = ?".  The
         1177  +  ** new terms completely replace the original vector comparison, which is
         1178  +  ** no longer used.
         1179  +  **
  1177   1180     ** This is only required if at least one side of the comparison operation
  1178   1181     ** is not a sub-select.  */
  1179   1182     if( pWC->op==TK_AND 
  1180   1183     && (pExpr->op==TK_EQ || pExpr->op==TK_IS)
  1181   1184     && sqlite3ExprIsVector(pExpr->pLeft)
  1182   1185     && ( (pExpr->pLeft->flags & EP_xIsSelect)==0 
  1183   1186       || (pExpr->pRight->flags & EP_xIsSelect)==0
................................................................................
  1190   1193           Expr *pNew;
  1191   1194           Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);
  1192   1195           Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);
  1193   1196   
  1194   1197           pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight, 0);
  1195   1198           idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);
  1196   1199           exprAnalyze(pSrc, pWC, idxNew);
  1197         -        markTermAsChild(pWC, idxNew, idxTerm);
  1198   1200         }
  1199   1201         pTerm = &pWC->a[idxTerm];
  1200         -      pTerm->wtFlags = TERM_CODED;
         1202  +      pTerm->wtFlags = TERM_CODED|TERM_VIRTUAL;  /* Disable the original */
  1201   1203         pTerm->eOperator = 0;
  1202   1204       }
  1203   1205     }
  1204   1206   
  1205   1207     /* If there is a vector IN term - e.g. "(a, b) IN (SELECT ...)" - create
  1206   1208     ** a virtual term for each vector component. The expression object
  1207   1209     ** used by each such virtual term is pExpr (the full vector IN(...)