SQLite

Check-in [2d9cd06715]
Login

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

Overview
Comment:Fix a problem with running ALTER TABLE on a schema that contains expressions of the type "col IN ()" (empty set on RHS of IN operator).
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2d9cd06715092c312c8c0ec392696a0e90ed090b074e2082e0b830f1399aa941
User & Date: dan 2019-01-24 16:27:10.406
Context
2019-01-24
17:41
Fix a buffer overread in fts3 that could occur in a prefix query on a corrupted database. (check-in: d0d5689371 user: dan tags: trunk)
16:27
Fix a problem with running ALTER TABLE on a schema that contains expressions of the type "col IN ()" (empty set on RHS of IN operator). (check-in: 2d9cd06715 user: dan tags: trunk)
16:07
Omit deprecated PRAGMAs when compiling with the -DSQLITE_OMIT_DEPRECATED option. (check-in: 008112bcef user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/parse.y.
1162
1163
1164
1165
1166
1167
1168

1169
1170

1171
1172
1173
1174
1175
1176
1177
      **
      **      expr1 IN ()
      **      expr1 NOT IN ()
      **
      ** simplify to constants 0 (false) and 1 (true), respectively,
      ** regardless of the value of expr1.
      */

      sqlite3ExprDelete(pParse->db, A);
      A = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[N],1);

    }else if( Y->nExpr==1 ){
      /* Expressions of the form:
      **
      **      expr1 IN (?1)
      **      expr1 NOT IN (?2)
      **
      ** with exactly one value on the RHS can be simplified to something







>
|
|
>







1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
      **
      **      expr1 IN ()
      **      expr1 NOT IN ()
      **
      ** simplify to constants 0 (false) and 1 (true), respectively,
      ** regardless of the value of expr1.
      */
      if( IN_RENAME_OBJECT==0 ){
        sqlite3ExprDelete(pParse->db, A);
        A = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[N],1);
      }
    }else if( Y->nExpr==1 ){
      /* Expressions of the form:
      **
      **      expr1 IN (?1)
      **      expr1 NOT IN (?2)
      **
      ** with exactly one value on the RHS can be simplified to something
Changes to test/altertab3.test.
59
60
61
62
63
64
65


















66
67
68
  SELECT sql FROM sqlite_master WHERE name = 'r1';
} {{CREATE TRIGGER r1 AFTER INSERT ON "t1x" WHEN new.a NOT NULL BEGIN
    SELECT a,b, a name FROM "t1x" 
      INTERSECT 
    SELECT a,b,c FROM "t1x" WHERE b>='d' ORDER BY name;
    SELECT new.c;
  END}}


















finish_test









>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
  SELECT sql FROM sqlite_master WHERE name = 'r1';
} {{CREATE TRIGGER r1 AFTER INSERT ON "t1x" WHEN new.a NOT NULL BEGIN
    SELECT a,b, a name FROM "t1x" 
      INTERSECT 
    SELECT a,b,c FROM "t1x" WHERE b>='d' ORDER BY name;
    SELECT new.c;
  END}}

#-------------------------------------------------------------------------
reset_db
do_execsql_test 3.0 {
  CREATE TABLE t1(a, b, c, d);
  CREATE VIEW v1 AS SELECT * FROM t1 WHERE a=1 OR (b IN ());
}

do_execsql_test 3.1 {
  ALTER TABLE t1 RENAME b TO bbb;
}

do_execsql_test 3.2 {
  SELECT sql FROM sqlite_master WHERE name = 'v1'
} {{CREATE VIEW v1 AS SELECT * FROM t1 WHERE a=1 OR (bbb IN ())}}



finish_test