/ Check-in [0d78ebb8]
Login

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

Overview
Comment:Fix ALTER TABLE RENAME so that it correctly handles triggers that attach to the table using the name in a different case. Ticket [ae6794effd404].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0d78ebb8e41ba08b446b44694d9433e1e90e0a7e
User & Date: drh 2012-02-01 01:13:10
Context
2012-02-01
19:03
Very small performance enhancement and reduction in size of the sqlite3_stmt object. check-in: a38d57a4 user: drh tags: trunk
01:13
Fix ALTER TABLE RENAME so that it correctly handles triggers that attach to the table using the name in a different case. Ticket [ae6794effd404]. check-in: 0d78ebb8 user: drh tags: trunk
2012-01-31
23:34
Fix a compiler warning in FTS4. check-in: b4cad1ce user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/alter.c.

   526    526   #endif
   527    527             "tbl_name = %Q, "
   528    528             "name = CASE "
   529    529               "WHEN type='table' THEN %Q "
   530    530               "WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN "
   531    531                "'sqlite_autoindex_' || %Q || substr(name,%d+18) "
   532    532               "ELSE name END "
   533         -      "WHERE tbl_name=%Q AND "
          533  +      "WHERE tbl_name=%Q COLLATE nocase AND "
   534    534             "(type='table' OR type='index' OR type='trigger');", 
   535    535         zDb, SCHEMA_TABLE(iDb), zName, zName, zName, 
   536    536   #ifndef SQLITE_OMIT_TRIGGER
   537    537         zName,
   538    538   #endif
   539    539         zName, nTabName, zTabName
   540    540     );

Changes to test/alter.test.

   345    345     set ::TRIGGER $args
   346    346   }
   347    347   db func trigfunc trigfunc
   348    348   
   349    349   do_test alter-3.1.0 {
   350    350     execsql {
   351    351       CREATE TABLE t6(a, b, c);
   352         -    CREATE TRIGGER trig1 AFTER INSERT ON t6 BEGIN
          352  +    -- Different case for the table name in the trigger.
          353  +    CREATE TRIGGER trig1 AFTER INSERT ON T6 BEGIN
   353    354         SELECT trigfunc('trig1', new.a, new.b, new.c);
   354    355       END;
   355    356     }
   356    357   } {}
   357    358   do_test alter-3.1.1 {
   358    359     execsql {
   359    360       INSERT INTO t6 VALUES(1, 2, 3);

Changes to test/tkt3838.test.

    33     33       ALTER TABLE t1 ADD COLUMN b INTEGER DEFAULT '999';
    34     34       ALTER TABLE t1 ADD COLUMN c REAL DEFAULT '9e99';
    35     35       ALTER TABLE t1 ADD COLUMN d TEXT DEFAULT 'xyzzy';
    36     36       UPDATE t1 SET x=x+1;
    37     37       SELECT * FROM t1;
    38     38     }
    39     39   } {2 999 9e+99 xyzzy}
           40  +
           41  +ifcapable trigger {
           42  +  do_test tkt3838-1.2 {
           43  +    db eval {
           44  +      CREATE TABLE log(y);
           45  +      CREATE TRIGGER r1 AFTER INSERT ON T1 BEGIN
           46  +        INSERT INTO log VALUES(new.x);
           47  +      END;
           48  +      INSERT INTO t1(x) VALUES(123);
           49  +      ALTER TABLE T1 RENAME TO XYZ2;
           50  +      INSERT INTO xyz2(x) VALUES(456);
           51  +      ALTER TABLE xyz2 RENAME TO pqr3;
           52  +      INSERT INTO pqr3(x) VALUES(789);
           53  +      SELECT * FROM log;
           54  +    }
           55  +  } {123 456 789}
           56  +}
    40     57   
    41     58   finish_test