Index: src/expr.c ================================================================== --- src/expr.c +++ src/expr.c @@ -3122,17 +3122,22 @@ CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft); int labelOk = sqlite3VdbeMakeLabel(pParse); int r2, regToFree; int regCkNull = 0; int ii; + int bLhsReal; /* True if the LHS of the IN has REAL affinity */ assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); if( destIfNull!=destIfFalse ){ regCkNull = sqlite3GetTempReg(pParse); sqlite3VdbeAddOp3(v, OP_BitAnd, rLhs, rLhs, regCkNull); } + bLhsReal = sqlite3ExprAffinity(pExpr->pLeft)==SQLITE_AFF_REAL; for(ii=0; iinExpr; ii++){ r2 = sqlite3ExprCodeTemp(pParse, pList->a[ii].pExpr, ®ToFree); + if( bLhsReal ){ + sqlite3VdbeAddOp4(v, OP_Affinity, r2, 1, 0, "E", P4_STATIC); + } if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){ sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull); } if( iinExpr-1 || destIfNull!=destIfFalse ){ sqlite3VdbeAddOp4(v, OP_Eq, rLhs, labelOk, r2, Index: test/in.test ================================================================== --- test/in.test +++ test/in.test @@ -757,7 +757,23 @@ CREATE TABLE t0(c0 INT UNIQUE); INSERT INTO t0(c0) VALUES (1); SELECT * FROM t0 WHERE '1' IN (t0.c0); } {} +# 2019-09-02 ticket https://www.sqlite.org/src/info/2841e99d104c6436 +# For the IN_INDEX_NOOP optimization, apply REAL affinity to the LHS +# values prior to comparison if the RHS has REAL affinity. +# +do_execsql_test in-19.1 { + DROP TABLE IF EXISTS t0; + CREATE TABLE t0(c0 REAL UNIQUE); + INSERT INTO t0(c0) VALUES(2.07093491255203046E18); + SELECT 1 FROM t0 WHERE c0 IN ('2070934912552030444'); +} {1} +do_execsql_test in-19.2 { + SELECT c0 IN ('2070934912552030444') FROM t0; +} {1} +do_execsql_test in-19.3 { + SELECT c0 IN ('2070934912552030444',2,3) FROM t0; +} {1} finish_test