SQLite

Check-in [56539e1c]
Login

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

Overview
Comment:Fix to the optimization of check-in [a47efb7c8520a011] that reads the values of expressions used in an index-on-expression directly from the index rather than recomputing the value. If the expression has a top-level COLLATE or unlikely() operator, be sure to clear the corresponding flags prior to converting it into a TK_COLUMN expression. Failure to do this is most likely harmless in production, but might cause an assertion fault in debugging builds. Ticket [b0cb8aff561a6dcd]. Test cases in TH3.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 56539e1c132632c075efc217ad5951a35e4459605ac128914aec3a7be1e25718
User & Date: drh 2019-12-22 18:55:04
Context
2019-12-22
19:41
In the WHERE clause debugging output (the .wheretrace output) show the parent index of any WhereTerm that is a child. (check-in: 7fc73332 user: drh tags: trunk)
18:55
Fix to the optimization of check-in [a47efb7c8520a011] that reads the values of expressions used in an index-on-expression directly from the index rather than recomputing the value. If the expression has a top-level COLLATE or unlikely() operator, be sure to clear the corresponding flags prior to converting it into a TK_COLUMN expression. Failure to do this is most likely harmless in production, but might cause an assertion fault in debugging builds. Ticket [b0cb8aff561a6dcd]. Test cases in TH3. (check-in: 56539e1c user: drh tags: trunk)
18:23
Back out the asserts of check-ins [a500893b6f64aced] and [d9c9fe9f5ad3fc91] as ticket [1b06916e01c82b66] demonstrates a case that refutes them. (check-in: ddb17d92 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/wherecode.c.

1141
1142
1143
1144
1145
1146
1147



1148
1149
1150
1151
1152
1153
1154
  IdxExprTrans *pX = p->u.pIdxTrans;
  if( sqlite3ExprCompare(0, pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){
    pExpr->affExpr = sqlite3ExprAffinity(pExpr);
    pExpr->op = TK_COLUMN;
    pExpr->iTable = pX->iIdxCur;
    pExpr->iColumn = pX->iIdxCol;
    pExpr->y.pTab = 0;



    return WRC_Prune;
  }else{
    return WRC_Continue;
  }
}

#ifndef SQLITE_OMIT_GENERATED_COLUMNS







>
>
>







1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
  IdxExprTrans *pX = p->u.pIdxTrans;
  if( sqlite3ExprCompare(0, pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){
    pExpr->affExpr = sqlite3ExprAffinity(pExpr);
    pExpr->op = TK_COLUMN;
    pExpr->iTable = pX->iIdxCur;
    pExpr->iColumn = pX->iIdxCol;
    pExpr->y.pTab = 0;
    testcase( ExprHasProperty(pExpr, EP_Skip) );
    testcase( ExprHasProperty(pExpr, EP_Unlikely) );
    ExprClearProperty(pExpr, EP_Skip|EP_Unlikely);
    return WRC_Prune;
  }else{
    return WRC_Continue;
  }
}

#ifndef SQLITE_OMIT_GENERATED_COLUMNS