/ Check-in [71643deb]
Login

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

Overview
Comment:Have ALTER TABLE commands ignore the lhs of "expr IN ()" and "expr NOT IN ()" expressions, just as other queries do. Fix for [533010b8ca].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 71643deb6bbad4b4a511bfd43b32245b50a555b508b90f33adf0656ae53292c6
User & Date: dan 2019-06-10 19:17:37
References
2019-06-11
01:30
Remove a comment made obsolete by check-in [71643deb6bbad4b4]. No changes to code. check-in: 211c8002 user: drh tags: trunk
2019-06-10
19:18 Closed ticket [533010b8]: Illegal argument to LIKELIHOOD() does not result in error when combined with "IN ()" plus 6 other changes artifact: 8f1e4544 user: dan
Context
2019-06-10
23:45
A string consisting of a single '.' is not a floating point literal with extra text at the end. Fix for ticket [412bba9b22c677da] check-in: 57050162 user: drh tags: trunk
19:17
Have ALTER TABLE commands ignore the lhs of "expr IN ()" and "expr NOT IN ()" expressions, just as other queries do. Fix for [533010b8ca]. check-in: 71643deb user: dan tags: trunk
19:07
Improvements to the documentation for the xAccess method of the VFS. Ticket [5e0423b058fa5adf] check-in: 7078d77e user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/parse.y.

1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
      **
      ** Or, if this is part of an ALTER TABLE RENAME command, instead
      ** change the expression to "+(expr1)". The unary + is required to
      ** workaround the obscure case where expr1 is a string literal, as
      ** SQLite treats simple string literals in CREATE INDEX statements
      ** as column names, not constant expressions.
      */
      if( IN_RENAME_OBJECT==0 ){
        sqlite3ExprDelete(pParse->db, A);
        A = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[N],1);
      }else{
        A = sqlite3PExpr(pParse, TK_UPLUS, A, 0);
      }
    }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







<
|
|
<
<
<







1175
1176
1177
1178
1179
1180
1181

1182
1183



1184
1185
1186
1187
1188
1189
1190
      **
      ** Or, if this is part of an ALTER TABLE RENAME command, instead
      ** change the expression to "+(expr1)". The unary + is required to
      ** workaround the obscure case where expr1 is a string literal, as
      ** SQLite treats simple string literals in CREATE INDEX statements
      ** as column names, not constant expressions.
      */

      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.

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
...
184
185
186
187
188
189
190


















191
192
193
194
195

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 ())}}

#-------------------------------------------------------------------------
reset_db
do_execsql_test 4.0 {
  CREATE TABLE t1(a, b);
  CREATE TABLE t3(e, f);
  CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
................................................................................
do_execsql_test 8.1 {
  ALTER TABLE t0 RENAME TO t1;
  SELECT sql FROM sqlite_master;
} {
  {CREATE TABLE "t1"(c0)}
  {CREATE INDEX i0 ON "t1"('1' IN ())}
}




















finish_test









|







 







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





75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
...
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213

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 (b IN ())}}

#-------------------------------------------------------------------------
reset_db
do_execsql_test 4.0 {
  CREATE TABLE t1(a, b);
  CREATE TABLE t3(e, f);
  CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
................................................................................
do_execsql_test 8.1 {
  ALTER TABLE t0 RENAME TO t1;
  SELECT sql FROM sqlite_master;
} {
  {CREATE TABLE "t1"(c0)}
  {CREATE INDEX i0 ON "t1"('1' IN ())}
}

do_execsql_test 8.2.1 {
  CREATE TABLE t2 (c0);
  CREATE INDEX i2 ON t2((LIKELIHOOD(c0, 100) IN ()));
  ALTER TABLE t2 RENAME COLUMN c0 TO c1;
}
do_execsql_test 8.2.2 {
  SELECT sql FROM sqlite_master WHERE tbl_name = 't2';
} {
  {CREATE TABLE t2 (c1)} 
  {CREATE INDEX i2 ON t2((LIKELIHOOD(c0, 100) IN ()))}
}
do_test 8.2.3 {
  sqlite3 db2 test.db
  db2 eval { INSERT INTO t2 VALUES (1), (2), (3) }
  db close
} {}



finish_test