diff options
author | dan <Dan Kennedy> | 2021-01-15 15:32:09 +0000 |
---|---|---|
committer | dan <Dan Kennedy> | 2021-01-15 15:32:09 +0000 |
commit | e8f7fcf6f4a3655334251ad638db47bcdde37a9c (patch) | |
tree | 2ed958c574d00160c32ffb0abbc98be0ce777d1e /src | |
parent | 9d326d67937b23217718cc64e67d214351691a2a (diff) | |
download | sqlite-e8f7fcf6f4a3655334251ad638db47bcdde37a9c.tar.gz sqlite-e8f7fcf6f4a3655334251ad638db47bcdde37a9c.zip |
Ensure the EXISTS->IN transformation preserves the collation sequence of the comparison operation.
FossilOrigin-Name: a373baae12c914e48fd84de77998e301fdd3da43b06b9d64ac24a14418ed48cd
Diffstat (limited to 'src')
-rw-r--r-- | src/whereexpr.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/whereexpr.c b/src/whereexpr.c index 0359babc5..82a9759f3 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -1175,12 +1175,18 @@ static void exprAnalyzeExists( pInLhs = exprAnalyzeExistsFindEq(pSel, &pEq, &ppAnd); assert( pInLhs && pEq ); assert( pEq==pSel->pWhere || ppAnd ); + if( pInLhs==pEq->pLeft ){ + pRet = pEq->pRight; + }else{ + CollSeq *p = sqlite3ExprCompareCollSeq(pParse, pEq); + pInLhs = sqlite3ExprAddCollateString(pParse, pInLhs, p?p->zName:"BINARY"); + pRet = pEq->pLeft; + } assert( pDup->pLeft==0 ); pDup->op = TK_IN; pDup->pLeft = pInLhs; pDup->flags &= ~EP_VarSelect; - pRet = (pInLhs==pEq->pLeft) ? pEq->pRight : pEq->pLeft; pSel->pEList = sqlite3ExprListAppend(pParse, 0, pRet); pEq->pLeft = 0; pEq->pRight = 0; |