aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordan <dan@noemail.net>2020-04-03 19:37:14 +0000
committerdan <dan@noemail.net>2020-04-03 19:37:14 +0000
commitc59b4acf5d188b8a18a83a576ad53b4212f4a62c (patch)
tree0340262c0b7bc8116d59b2d9a2d89f63ef3d725d /src/expr.c
parenta96a69b7dbbb9d933d27af8516cb7c5245956bb0 (diff)
downloadsqlite-c59b4acf5d188b8a18a83a576ad53b4212f4a62c.tar.gz
sqlite-c59b4acf5d188b8a18a83a576ad53b4212f4a62c.zip
Avoid factoring out constant expressions on the LHS of an IN(...) operator, as the IN(...) operation may affect the affinity of these values.
FossilOrigin-Name: 98d56b4a34fddcbaecd953a045ae0270b4d78c1edf34cc73522fb4e12743af80
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/expr.c b/src/expr.c
index e58889737..bcabc38b6 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -3181,6 +3181,7 @@ static void sqlite3ExprCodeIN(
int destNotNull; /* Jump here if a comparison is not true in step 6 */
int addrTop; /* Top of the step-6 loop */
int iTab = 0; /* Index to use */
+ u8 okConstFactor = pParse->okConstFactor;
assert( !ExprHasVVAProperty(pExpr,EP_Immutable) );
pLeft = pExpr->pLeft;
@@ -3225,8 +3226,14 @@ static void sqlite3ExprCodeIN(
** so that the fields are in the same order as an existing index. The
** aiMap[] array contains a mapping from the original LHS field order to
** the field order that matches the RHS index.
- */
+ **
+ ** Avoid factoring the LHS of the IN(...) expression out of the loop,
+ ** even if it is constant, as OP_Affinity may be used on the register
+ ** by code generated below. */
+ assert( pParse->okConstFactor==okConstFactor );
+ pParse->okConstFactor = 0;
rLhsOrig = exprCodeVector(pParse, pLeft, &iDummy);
+ pParse->okConstFactor = okConstFactor;
for(i=0; i<nVector && aiMap[i]==i; i++){} /* Are LHS fields reordered? */
if( i==nVector ){
/* LHS fields are not reordered */