/ Check-in [88833a9c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:When applying the IN_INDEX_NOOP optimization and the LHS has REAL affinity, also apply REAL affinity to each element of the RHS. Ticket [2841e99d104c6436].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 88833a9c2849c959a37a80e0e4d2b211ce3c83a48319724c89b172b060c876b4
User & Date: drh 2019-09-02 02:21:58
References
2019-09-02
22:13
Fix a bug introduced earlier today by check-in [88833a9c2849c959]. Ticket [29f635e0af71234b] check-in: 6e7b4527 user: drh tags: trunk
Context
2019-09-02
14:46
Fix a potential crash in fts5 caused by using an auxiliary function on a "special" query like '*id' or '*reads'. check-in: 9490683a user: dan tags: trunk
02:21
When applying the IN_INDEX_NOOP optimization and the LHS has REAL affinity, also apply REAL affinity to each element of the RHS. Ticket [2841e99d104c6436]. check-in: 88833a9c user: drh tags: trunk
01:25
Fix an obsolete comment that defines the meaning of one of the parameters to the sqlite3FindInIndex() subroutine. No changes to code. check-in: 0c946f08 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

  3120   3120     if( eType==IN_INDEX_NOOP ){
  3121   3121       ExprList *pList = pExpr->x.pList;
  3122   3122       CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
  3123   3123       int labelOk = sqlite3VdbeMakeLabel(pParse);
  3124   3124       int r2, regToFree;
  3125   3125       int regCkNull = 0;
  3126   3126       int ii;
         3127  +    int bLhsReal;  /* True if the LHS of the IN has REAL affinity */
  3127   3128       assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
  3128   3129       if( destIfNull!=destIfFalse ){
  3129   3130         regCkNull = sqlite3GetTempReg(pParse);
  3130   3131         sqlite3VdbeAddOp3(v, OP_BitAnd, rLhs, rLhs, regCkNull);
  3131   3132       }
         3133  +    bLhsReal = sqlite3ExprAffinity(pExpr->pLeft)==SQLITE_AFF_REAL;
  3132   3134       for(ii=0; ii<pList->nExpr; ii++){
  3133   3135         r2 = sqlite3ExprCodeTemp(pParse, pList->a[ii].pExpr, &regToFree);
         3136  +      if( bLhsReal ){
         3137  +        sqlite3VdbeAddOp4(v, OP_Affinity, r2, 1, 0, "E", P4_STATIC);
         3138  +      }
  3134   3139         if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){
  3135   3140           sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull);
  3136   3141         }
  3137   3142         if( ii<pList->nExpr-1 || destIfNull!=destIfFalse ){
  3138   3143           sqlite3VdbeAddOp4(v, OP_Eq, rLhs, labelOk, r2,
  3139   3144                             (void*)pColl, P4_COLLSEQ);
  3140   3145           VdbeCoverageIf(v, ii<pList->nExpr-1);

Changes to test/in.test.

   755    755   do_execsql_test in-18.1 {
   756    756     DROP TABLE IF EXISTS t0;
   757    757     CREATE TABLE t0(c0 INT UNIQUE);
   758    758     INSERT INTO t0(c0) VALUES (1);
   759    759     SELECT * FROM t0 WHERE '1' IN (t0.c0);
   760    760   } {}
   761    761   
          762  +# 2019-09-02 ticket https://www.sqlite.org/src/info/2841e99d104c6436
          763  +# For the IN_INDEX_NOOP optimization, apply REAL affinity to the LHS
          764  +# values prior to comparison if the RHS has REAL affinity.
          765  +#
          766  +do_execsql_test in-19.1 {
          767  +  DROP TABLE IF EXISTS t0;
          768  +  CREATE TABLE t0(c0 REAL UNIQUE);
          769  +  INSERT INTO t0(c0) VALUES(2.07093491255203046E18);
          770  +  SELECT 1 FROM t0 WHERE c0 IN ('2070934912552030444');
          771  +} {1}
          772  +do_execsql_test in-19.2 {
          773  +  SELECT c0 IN ('2070934912552030444') FROM t0;
          774  +} {1}
          775  +do_execsql_test in-19.3 {
          776  +  SELECT c0 IN ('2070934912552030444',2,3) FROM t0;
          777  +} {1}
   762    778   
   763    779   finish_test