/ Check-in [91aab32e71]
Login

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

Overview
Comment:Fix a problem with ALTER TABLE when there are views or triggers in the schema that contain "<expr> IS NULL" expressions.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5d3c3
User & Date: dan 2018-09-06 18:56:36
Context
2018-09-06
19:36
Fix a harmless compiler warning in os_unix.c. check-in: b9d1fb5d44 user: drh tags: trunk
18:56
Fix a problem with ALTER TABLE when there are views or triggers in the schema that contain "<expr> IS NULL" expressions. check-in: 91aab32e71 user: dan tags: trunk
17:47
Fix a problem in ALTER TABLE with SQLITE_OMIT_VIRTUALTABLE builds. check-in: fa835145e6 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/parse.y.

  1100   1100   expr(A) ::= expr(A) NOT NULL.    {A = sqlite3PExpr(pParse,TK_NOTNULL,A,0);}
  1101   1101   
  1102   1102   %include {
  1103   1103     /* A routine to convert a binary TK_IS or TK_ISNOT expression into a
  1104   1104     ** unary TK_ISNULL or TK_NOTNULL expression. */
  1105   1105     static void binaryToUnaryIfNull(Parse *pParse, Expr *pY, Expr *pA, int op){
  1106   1106       sqlite3 *db = pParse->db;
  1107         -    if( pA && pY && pY->op==TK_NULL ){
         1107  +    if( pA && pY && pY->op==TK_NULL && !IN_RENAME_OBJECT ){
  1108   1108         pA->op = (u8)op;
  1109   1109         sqlite3ExprDelete(db, pA->pRight);
  1110   1110         pA->pRight = 0;
  1111   1111       }
  1112   1112     }
  1113   1113   }
  1114   1114   

Changes to test/altertab.test.

   290    290   } {1 {error in trigger tr: no such table: main.t2}}
   291    291   
   292    292   forcedelete test.db2
   293    293   do_execsql_test 9.4 {
   294    294     DROP TRIGGER tr;
   295    295   
   296    296     ATTACH 'test.db2' AS aux;
   297         -  CREATE TRIGGER tr AFTER INSERT ON t1 BEGIN SELECT 1, 2, 3; END;
          297  +  CREATE TRIGGER tr AFTER INSERT ON t1 WHEN new.a IS NULL BEGIN SELECT 1, 2, 3; END;
   298    298   
   299    299     CREATE TABLE aux.t1(x);
   300    300     CREATE TEMP TRIGGER tr AFTER INSERT ON aux.t1 BEGIN SELECT 1, 2, 3; END;
   301    301   }
   302    302   do_execsql_test 9.5 {
   303    303     ALTER TABLE main.t1 RENAME TO t3;
   304    304   }
   305    305   do_execsql_test 9.6 {
   306    306     SELECT sql FROM sqlite_temp_master;
   307    307     SELECT sql FROM sqlite_master WHERE type='trigger';
   308    308   } {
   309    309     {CREATE TRIGGER tr AFTER INSERT ON aux.t1 BEGIN SELECT 1, 2, 3; END}
   310         -  {CREATE TRIGGER tr AFTER INSERT ON "t3" BEGIN SELECT 1, 2, 3; END}
          310  +  {CREATE TRIGGER tr AFTER INSERT ON "t3" WHEN new.a IS NULL BEGIN SELECT 1, 2, 3; END}
   311    311   }
   312    312   
   313    313   #-------------------------------------------------------------------------
   314    314   reset_db
   315    315   ifcapable fts5 {
   316    316     do_execsql_test 10.0 {
   317    317       CREATE VIRTUAL TABLE fff USING fts5(x, y, z);