mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Ensure the columns of views and sub-queries maintain their implicit collation sequences when the "push-down" optimization is applied. Fix for [18458b1a].
FossilOrigin-Name: 36997c4ade2ef3a274cd1ac52b44118fb3a05325adb650b7b338ecb43d060575
This commit is contained in:
@@ -3418,7 +3418,6 @@ typedef struct SubstContext {
|
||||
int iNewTable; /* New table number */
|
||||
int isLeftJoin; /* Add TK_IF_NULL_ROW opcodes on each replacement */
|
||||
ExprList *pEList; /* Replacement expressions */
|
||||
int bFlattener; /* True for query-flattener, false otherwise */
|
||||
} SubstContext;
|
||||
|
||||
/* Forward Declarations */
|
||||
@@ -3480,9 +3479,9 @@ static Expr *substExpr(
|
||||
sqlite3ExprDelete(db, pExpr);
|
||||
pExpr = pNew;
|
||||
|
||||
/* If this call is part of query-flattening, ensure that the
|
||||
** new expression has an implicit collation sequence. */
|
||||
if( pSubst->bFlattener && pExpr ){
|
||||
/* Ensure that the expression now has an implicit collation sequence,
|
||||
** just as it did when it was a column of a view or sub-query. */
|
||||
if( pExpr ){
|
||||
if( pExpr->op!=TK_COLUMN && pExpr->op!=TK_COLLATE ){
|
||||
CollSeq *pColl = sqlite3ExprCollSeq(pSubst->pParse, pExpr);
|
||||
pExpr = sqlite3ExprAddCollateString(pSubst->pParse, pExpr,
|
||||
@@ -4056,7 +4055,6 @@ static int flattenSubquery(
|
||||
x.iNewTable = iNewParent;
|
||||
x.isLeftJoin = isLeftJoin;
|
||||
x.pEList = pSub->pEList;
|
||||
x.bFlattener = 1;
|
||||
substSelect(&x, pParent, 0);
|
||||
}
|
||||
|
||||
@@ -4382,7 +4380,6 @@ static int pushDownWhereTerms(
|
||||
x.iNewTable = iCursor;
|
||||
x.isLeftJoin = 0;
|
||||
x.pEList = pSubq->pEList;
|
||||
x.bFlattener = 0;
|
||||
pNew = substExpr(&x, pNew);
|
||||
if( pSubq->selFlags & SF_Aggregate ){
|
||||
pSubq->pHaving = sqlite3ExprAnd(pParse, pSubq->pHaving, pNew);
|
||||
|
||||
Reference in New Issue
Block a user