/ Check-in [567b1309]
Login

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

Overview
Comment:Handle renaming a column or table when the schema contains a (meaningless) index on the constant expression ('text' IN ()) or ('text' NOT IN()). Fix for [fd76310a].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 567b13093956185b5d5e971b81ba4788fd9d26c03688f643b380f0f1c1a94da0
User & Date: dan 2019-06-10 15:34:16
Original Comment: Handle renaming a column or table when the schema contains a (meaningless) index on the constant expression ('text' IN ()) or ('text' NOT IN()).
Context
2019-06-10
18:33
Make sure a CAST to "NUMERIC" results in an integer if the value can be losslessly expressed as an integer, as the documentation requires. Ticket [dd6bffbfb6e61db9]. check-in: c0c90961 user: drh tags: trunk
15:34
Handle renaming a column or table when the schema contains a (meaningless) index on the constant expression ('text' IN ()) or ('text' NOT IN()). Fix for [fd76310a]. check-in: 567b1309 user: dan tags: trunk
13:46
Do not attempt the LIKE optimization on a column with numeric affinity if the rhs of the operator begins with whitespace. Fix for ticket [fd76310a5e]. check-in: 94b58ab0 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/parse.y.

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

Changes to test/altertab3.test.

   170    170       WINDOW w1 AS (PARTITION BY b, percent_rank() OVER w1 ORDER BY d);
   171    171     END;
   172    172   }
   173    173   
   174    174   do_catchsql_test 7.2.2 {
   175    175     ALTER TABLE t1x RENAME TO t1;
   176    176   } {1 {error in trigger AFTER: no such column: d}}
          177  +
          178  +#-------------------------------------------------------------------------
          179  +reset_db
          180  +do_execsql_test 8.0 {
          181  +  CREATE TABLE t0(c0);
          182  +  CREATE INDEX i0 ON t0('1' IN ());
          183  +}
          184  +do_execsql_test 8.1 {
          185  +  ALTER TABLE t0 RENAME TO t1;
          186  +  SELECT sql FROM sqlite_master;
          187  +} {
          188  +  {CREATE TABLE "t1"(c0)}
          189  +  {CREATE INDEX i0 ON "t1"('1' IN ())}
          190  +}
          191  +
   177    192   
   178    193   finish_test
   179    194   
   180    195