/ 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 Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/parse.y.

  1175   1175         **
  1176   1176         ** Or, if this is part of an ALTER TABLE RENAME command, instead
  1177   1177         ** change the expression to "+(expr1)". The unary + is required to
  1178   1178         ** workaround the obscure case where expr1 is a string literal, as
  1179   1179         ** SQLite treats simple string literals in CREATE INDEX statements
  1180   1180         ** as column names, not constant expressions.
  1181   1181         */
  1182         -      if( IN_RENAME_OBJECT==0 ){
  1183         -        sqlite3ExprDelete(pParse->db, A);
  1184         -        A = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[N],1);
  1185         -      }else{
  1186         -        A = sqlite3PExpr(pParse, TK_UPLUS, A, 0);
  1187         -      }
         1182  +      sqlite3ExprDelete(pParse->db, A);
         1183  +      A = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[N],1);
  1188   1184       }else if( Y->nExpr==1 ){
  1189   1185         /* Expressions of the form:
  1190   1186         **
  1191   1187         **      expr1 IN (?1)
  1192   1188         **      expr1 NOT IN (?2)
  1193   1189         **
  1194   1190         ** with exactly one value on the RHS can be simplified to something

Changes to test/altertab3.test.

    75     75   
    76     76   do_execsql_test 3.1 {
    77     77     ALTER TABLE t1 RENAME b TO bbb;
    78     78   }
    79     79   
    80     80   do_execsql_test 3.2 {
    81     81     SELECT sql FROM sqlite_master WHERE name = 'v1'
    82         -} {{CREATE VIEW v1 AS SELECT * FROM t1 WHERE a=1 OR (bbb IN ())}}
           82  +} {{CREATE VIEW v1 AS SELECT * FROM t1 WHERE a=1 OR (b IN ())}}
    83     83   
    84     84   #-------------------------------------------------------------------------
    85     85   reset_db
    86     86   do_execsql_test 4.0 {
    87     87     CREATE TABLE t1(a, b);
    88     88     CREATE TABLE t3(e, f);
    89     89     CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
................................................................................
   184    184   do_execsql_test 8.1 {
   185    185     ALTER TABLE t0 RENAME TO t1;
   186    186     SELECT sql FROM sqlite_master;
   187    187   } {
   188    188     {CREATE TABLE "t1"(c0)}
   189    189     {CREATE INDEX i0 ON "t1"('1' IN ())}
   190    190   }
          191  +
          192  +do_execsql_test 8.2.1 {
          193  +  CREATE TABLE t2 (c0);
          194  +  CREATE INDEX i2 ON t2((LIKELIHOOD(c0, 100) IN ()));
          195  +  ALTER TABLE t2 RENAME COLUMN c0 TO c1;
          196  +}
          197  +do_execsql_test 8.2.2 {
          198  +  SELECT sql FROM sqlite_master WHERE tbl_name = 't2';
          199  +} {
          200  +  {CREATE TABLE t2 (c1)} 
          201  +  {CREATE INDEX i2 ON t2((LIKELIHOOD(c0, 100) IN ()))}
          202  +}
          203  +do_test 8.2.3 {
          204  +  sqlite3 db2 test.db
          205  +  db2 eval { INSERT INTO t2 VALUES (1), (2), (3) }
          206  +  db close
          207  +} {}
          208  +
   191    209   
   192    210   
   193    211   finish_test
   194    212   
   195    213