SQLite

Check-in [89a9dad6]
Login

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

Overview
Comment:Make a hard copy of strings in constraint checks prior to applying OP_RealAffinity, to avoid problems with a pointer accounting assert. This change is not strictly necessary - the correct answer is obtained without it and no UB occurs - however the pointer accounting asserts are useful to prevent other problems so it is a simple matter to bring this piece into compliance. Ticket [5ad2aa6921faa1ee]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 89a9dad6330270a4c3b962f86a208088d2ea9883c7d291351a77f058e0ed8b0c
User & Date: drh 2019-12-22 20:29:25
Context
2019-12-22
23:48
Change the code generator for the IN operator so that it avoids creating OP_Eq and OP_Ne opcode with the same P1 and P3 arguments. This enables us to back out check-in [ddb17d92df194337] and also fix ticket [188f912b51cd802]. (check-in: 9ab985a9 user: drh tags: trunk)
20:29
Make a hard copy of strings in constraint checks prior to applying OP_RealAffinity, to avoid problems with a pointer accounting assert. This change is not strictly necessary - the correct answer is obtained without it and no UB occurs - however the pointer accounting asserts are useful to prevent other problems so it is a simple matter to bring this piece into compliance. Ticket [5ad2aa6921faa1ee] (check-in: 89a9dad6 user: drh tags: trunk)
20:03
When constructing the virtual MATCH term of the WHERE clause for a virtual table that is in a LEFT JOIN, be sure to set the correct Expr.iRightJoinTable value. This value does not appear to ever be used, except inside of a single assert(). But it is good to set it correctly, nevertheless. This fixes ticket [7929c1efb2d67e98], which as far as I can tell is completely harmless. (check-in: ef604882 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/expr.c.

3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
              sqlite3ExprCodeGeneratedColumn(pParse, pCol, iSrc);
            }
            pCol->colFlags &= ~(COLFLAG_BUSY|COLFLAG_NOTAVAIL);
            return iSrc;
          }else
#endif /* SQLITE_OMIT_GENERATED_COLUMNS */
          if( pCol->affinity==SQLITE_AFF_REAL ){
            sqlite3VdbeAddOp2(v, OP_SCopy, iSrc, target);
            sqlite3VdbeAddOp1(v, OP_RealAffinity, target);
            return target;
          }else{
            return iSrc;
          }
        }else{
          /* Coding an expression that is part of an index where column names







|







3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
              sqlite3ExprCodeGeneratedColumn(pParse, pCol, iSrc);
            }
            pCol->colFlags &= ~(COLFLAG_BUSY|COLFLAG_NOTAVAIL);
            return iSrc;
          }else
#endif /* SQLITE_OMIT_GENERATED_COLUMNS */
          if( pCol->affinity==SQLITE_AFF_REAL ){
            sqlite3VdbeAddOp2(v, OP_Copy, iSrc, target);
            sqlite3VdbeAddOp1(v, OP_RealAffinity, target);
            return target;
          }else{
            return iSrc;
          }
        }else{
          /* Coding an expression that is part of an index where column names

Changes to test/update.test.

652
653
654
655
656
657
658




659










660
661
  CREATE TABLE t1(x,y);
  INSERT INTO t1(x) VALUES(1);
  CREATE INDEX t1x1 ON t1(1) WHERE 3;
  UPDATE t1 SET x=2, y=3 WHERE 3;
  SELECT * FROM t1;
} {2 3}

















finish_test







>
>
>
>
|
>
>
>
>
>
>
>
>
>
>


652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
  CREATE TABLE t1(x,y);
  INSERT INTO t1(x) VALUES(1);
  CREATE INDEX t1x1 ON t1(1) WHERE 3;
  UPDATE t1 SET x=2, y=3 WHERE 3;
  SELECT * FROM t1;
} {2 3}

# 2019-12-22 ticket 5ad2aa6921faa1ee
# Make a hard-copy of values that need to be run through OP_RealAffinity
# rather than a soft-copy.  This is not strictly necessary, but it avoids
# a memory-accounting assert().
#
reset_db
do_execsql_test update-18.10 {
  PRAGMA encoding = 'UTF16';
  CREATE TABLE t0(c0 REAL, c1);
  INSERT INTO t0(c0,c1) VALUES('xyz',11),('uvw',22);
  CREATE INDEX i0 ON t0(c1) WHERE c0 GLOB 3;
  CREATE INDEX i1 ON t0(c0,c1) WHERE typeof(c0)='text' AND typeof(c1)='integer';
  UPDATE t0 SET c1=345;
  SELECT * FROM t0;
} {xyz 345 uvw 345}

finish_test