Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix the transitive constraint processing to only allow transitivity if the operands of the == or IS operator have compatible affinities. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | transitive-constraints |
Files: | files | file ages | folders |
SHA1: |
a46a247fbcfe6e63b12cef3135383529 |
User & Date: | drh 2015-05-16 19:17:17.907 |
Context
2015-05-16
| ||
20:51 | Further restrictions on the use of the transitive property in WHERE clauses. (check-in: 8c886c43ff user: drh tags: transitive-constraints) | |
19:17 | Fix the transitive constraint processing to only allow transitivity if the operands of the == or IS operator have compatible affinities. (check-in: a46a247fbc user: drh tags: transitive-constraints) | |
18:31 | Fix a typo in a comment. No changes to code. (check-in: ee4b74250a user: drh tags: trunk) | |
Changes
Changes to src/where.c.
︙ | ︙ | |||
1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 | sqlite3ExprDelete(db, pDup); return; } idxNew = whereClauseInsert(pWC, pDup, TERM_VIRTUAL|TERM_DYNAMIC); if( idxNew==0 ) return; pNew = &pWC->a[idxNew]; markTermAsChild(pWC, idxNew, idxTerm); pTerm = &pWC->a[idxTerm]; pTerm->wtFlags |= TERM_COPIED; if( (op==TK_EQ || op==TK_IS) && !ExprHasProperty(pExpr, EP_FromJoin) && OptimizationEnabled(db, SQLITE_Transitive) ){ | > > > > > > > > > > > > > > > | | | < > | 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 | sqlite3ExprDelete(db, pDup); return; } idxNew = whereClauseInsert(pWC, pDup, TERM_VIRTUAL|TERM_DYNAMIC); if( idxNew==0 ) return; pNew = &pWC->a[idxNew]; markTermAsChild(pWC, idxNew, idxTerm); if( op==TK_IS ) pNew->wtFlags |= TERM_IS; pTerm = &pWC->a[idxTerm]; pTerm->wtFlags |= TERM_COPIED; /* Expressions of the form "A==B" or "A IS B" might be candidates ** for propagating constraints via the transitive property. In other ** words: "A==B AND B==$xyz" implies "A==$xyz". If this term ** qualifies, mark it with WO_EQUIV. Necessary preconditions: ** 1. The term is not in the ON clause of a LEFT JOIN ** 2. The affinities of A and B must be compatible ** 3. The SQLITE_Transitive optimization must be enabled */ if( (op==TK_EQ || op==TK_IS) && !ExprHasProperty(pExpr, EP_FromJoin) && OptimizationEnabled(db, SQLITE_Transitive) ){ char aff1 = sqlite3ExprAffinity(pDup->pLeft); char aff2 = sqlite3ExprAffinity(pDup->pRight); if( aff1==aff2 || (sqlite3IsNumericAffinity(aff1) && sqlite3IsNumericAffinity(aff2)) ){ pTerm->eOperator |= WO_EQUIV; eExtraOp = WO_EQUIV; } } }else{ pDup = pExpr; pNew = pTerm; } exprCommute(pParse, pDup); pLeft = sqlite3ExprSkipCollate(pDup->pLeft); pNew->leftCursor = pLeft->iTable; |
︙ | ︙ |