aboutsummaryrefslogtreecommitdiff
path: root/src/wherecode.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2019-12-20 22:46:41 +0000
committerdrh <drh@noemail.net>2019-12-20 22:46:41 +0000
commited0c34857ae209d2272e9f625359196fd4342e58 (patch)
tree44e769cc73c59327dd67a835c1ce0fce9c6fe4b3 /src/wherecode.c
parent67b9ba1732c7ed1c561ed124b4eaaaa0b7081c2e (diff)
downloadsqlite-ed0c34857ae209d2272e9f625359196fd4342e58.tar.gz
sqlite-ed0c34857ae209d2272e9f625359196fd4342e58.zip
Do not try to access a generated column through an index if the collating
sequence for the generated column is non-standard. Part 2 of ticket [e0a8120553f4b082] FossilOrigin-Name: 056bb8dcbdc45989c5c6e86d2966200062e3c01c382ec52aae37c828104b4496
Diffstat (limited to 'src/wherecode.c')
-rw-r--r--src/wherecode.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/wherecode.c b/src/wherecode.c
index 59546c43c..a054a930f 100644
--- a/src/wherecode.c
+++ b/src/wherecode.c
@@ -1190,7 +1190,17 @@ static void whereIndexExprTrans(
x.pIdxExpr = aColExpr->a[iIdxCol].pExpr;
w.xExprCallback = whereIndexExprTransNode;
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
- }else if( iRef>=0 && (pTab->aCol[iRef].colFlags & COLFLAG_VIRTUAL)!=0 ){
+ }else if( iRef>=0
+ && (pTab->aCol[iRef].colFlags & COLFLAG_VIRTUAL)!=0
+ && (pTab->aCol[iRef].zColl==0
+ || sqlite3StrICmp(pTab->aCol[iRef].zColl, sqlite3StrBINARY)==0)
+ ){
+ /* Check to see if there are direct references to generated columns
+ ** that are contained in the index. Pulling the generated column
+ ** out of the index is an optimization only - the main table is always
+ ** available if the index cannot be used. To avoid unnecessary
+ ** complication, omit this optimization if the collating sequence for
+ ** the column is non-standard */
x.iTabCol = iRef;
w.xExprCallback = whereIndexExprTransColumn;
#endif /* SQLITE_OMIT_GENERATED_COLUMNS */