/ Check-in [6cb80ae1]
Login

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

Overview
Comment:Rename all tests so that the first part of the test name corresponds to the file that contains that test. This makes it much easier to find a particular test after it fail. (CVS 749)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:6cb80ae10af60863cc25c22a6442ba1d43b7409c
User & Date: drh 2002-09-14 12:04:56
Context
2002-09-14
13:47
Do not put a write lock on the main database file when writing to a temporary table. (CVS 750) check-in: 3f253afe user: drh tags: trunk
12:04
Rename all tests so that the first part of the test name corresponds to the file that contains that test. This makes it much easier to find a particular test after it fail. (CVS 749) check-in: 6cb80ae1 user: drh tags: trunk
2002-09-12
14:08
Update the SQL language documentation to talk about SELECT DISTINCT. (CVS 748) check-in: ef711675 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/trigger1.test.

    26     26   # trig-1.13: Ensure that AFTER triggers cannot be created on views
    27     27   # trig-1.14: Ensure that BEFORE triggers cannot be created on views
    28     28   #
    29     29   
    30     30   set testdir [file dirname $argv0]
    31     31   source $testdir/tester.tcl
    32     32   
    33         -do_test trig_cd-1.1 {
           33  +do_test trigger1-1.1 {
    34     34      catchsql {
    35     35        CREATE TRIGGER trig UPDATE ON no_such_table BEGIN
    36     36          SELECT * from sqlite_master;
    37     37        END;
    38     38      } 
    39     39   } {1 {no such table: no_such_table}}
    40     40   
................................................................................
    42     42       CREATE TABLE t1(a);
    43     43   }
    44     44   execsql {
    45     45   	CREATE TRIGGER tr1 INSERT ON t1 BEGIN
    46     46   	  INSERT INTO t1 values(1);
    47     47    	END;
    48     48   }
    49         -do_test trig_cd-1.2 {
           49  +do_test trigger1-1.2 {
    50     50       catchsql {
    51     51   	CREATE TRIGGER tr1 DELETE ON t1 BEGIN
    52     52   	    SELECT * FROM sqlite_master;
    53     53    	END
    54     54        }
    55     55   } {1 {trigger tr1 already exists}}
    56     56   
    57         -do_test trig_cd-1.3 {
           57  +do_test trigger1-1.3 {
    58     58       catchsql {
    59     59   	BEGIN;
    60     60   	CREATE TRIGGER tr2 INSERT ON t1 BEGIN
    61     61   	    SELECT * from sqlite_master; END;
    62     62           ROLLBACK;
    63     63   	CREATE TRIGGER tr2 INSERT ON t1 BEGIN
    64     64   	    SELECT * from sqlite_master; END;
    65     65       }
    66     66   } {0 {}}
    67     67   
    68         -do_test trig_cd-1.4 {
           68  +do_test trigger1-1.4 {
    69     69       catchsql {
    70     70   	DROP TRIGGER tr1;
    71     71   	CREATE TRIGGER tr1 DELETE ON t1 BEGIN
    72     72   	    SELECT * FROM sqlite_master;
    73     73   	END
    74     74       }
    75     75   } {0 {}}
    76     76   
    77         -do_test trig_cd-1.5 {
           77  +do_test trigger1-1.5 {
    78     78       execsql {
    79     79   	BEGIN;
    80     80   	DROP TRIGGER tr2;
    81     81   	ROLLBACK;
    82     82   	DROP TRIGGER tr2;
    83     83       }
    84     84   } {}
    85     85   
    86         -do_test trig_cd-1.6 {
           86  +do_test trigger1-1.6 {
    87     87       catchsql {
    88     88   	DROP TRIGGER biggles;
    89     89       }
    90     90   } {1 {no such trigger: biggles}}
    91     91   
    92         -do_test trig_cd-1.7 {
           92  +do_test trigger1-1.7 {
    93     93       catchsql {
    94     94   	DROP TABLE t1;
    95     95   	DROP TRIGGER tr1;
    96     96       }
    97     97   } {1 {no such trigger: tr1}}
    98     98   
    99     99   execsql {
   100    100     CREATE TEMP TABLE temp_table(a);
   101    101   }
   102         -do_test trig_cd-1.8 {
          102  +do_test trigger1-1.8 {
   103    103     execsql {
   104    104   	CREATE TRIGGER temp_trig UPDATE ON temp_table BEGIN
   105    105   	    SELECT * from sqlite_master;
   106    106   	END;
   107    107   	SELECT count(*) FROM sqlite_master WHERE name = 'temp_trig';
   108    108     } 
   109    109   } {0}
   110    110   
   111         -do_test trig_cd-1.9 {
          111  +do_test trigger1-1.9 {
   112    112     catchsql {
   113    113       CREATE TRIGGER tr1 AFTER UPDATE ON sqlite_master BEGIN
   114    114          SELECT * FROM sqlite_master;
   115    115       END;
   116    116     }
   117    117   } {1 {cannot create trigger on system table: sqlite_master}}
   118    118   
   119    119   # Check to make sure that a DELETE statement within the body of
   120    120   # a trigger does not mess up the DELETE that caused the trigger to
   121    121   # run in the first place.
   122    122   #
   123         -do_test trig_cd-1.10 {
          123  +do_test trigger1-1.10 {
   124    124     execsql {
   125    125       create table t1(a,b);
   126    126       insert into t1 values(1,'a');
   127    127       insert into t1 values(2,'b');
   128    128       insert into t1 values(3,'c');
   129    129       insert into t1 values(4,'d');
   130    130       create trigger r1 after delete on t1 for each row begin
................................................................................
   131    131         delete from t1 WHERE a=old.a+2;
   132    132       end;
   133    133       delete from t1 where a in (1,3);
   134    134       select * from t1;
   135    135       drop table t1;
   136    136     }
   137    137   } {2 b 4 d}
   138         -do_test trig_cd-1.11 {
          138  +do_test trigger1-1.11 {
   139    139     execsql {
   140    140       create table t1(a,b);
   141    141       insert into t1 values(1,'a');
   142    142       insert into t1 values(2,'b');
   143    143       insert into t1 values(3,'c');
   144    144       insert into t1 values(4,'d');
   145    145       create trigger r1 after update on t1 for each row begin
................................................................................
   148    148       update t1 set b='x-' || b where a in (1,3);
   149    149       select * from t1;
   150    150       drop table t1;
   151    151     }
   152    152   } {1 x-a 2 b 4 d}
   153    153   
   154    154   # Ensure that we cannot create INSTEAD OF triggers on tables
   155         -do_test trig_cd-1.12 {
          155  +do_test trigger1-1.12 {
   156    156     catchsql {
   157    157       create table t1(a,b);
   158    158       create trigger t1t instead of update on t1 for each row begin
   159    159         delete from t1 WHERE a=old.a+2;
   160    160       end;
   161    161     }
   162    162   } {1 {cannot create INSTEAD OF trigger on table: t1}}
   163    163   # Ensure that we cannot create BEFORE triggers on views
   164         -do_test trig_cd-1.13 {
          164  +do_test trigger1-1.13 {
   165    165     catchsql {
   166    166       create view v1 as select * from t1;
   167    167       create trigger v1t before update on v1 for each row begin
   168    168         delete from t1 WHERE a=old.a+2;
   169    169       end;
   170    170     }
   171    171   } {1 {cannot create BEFORE trigger on view: v1}}
   172    172   # Ensure that we cannot create AFTER triggers on views
   173         -do_test trig_cd-1.14 {
          173  +do_test trigger1-1.14 {
   174    174     catchsql {
   175    175       create table t1(a,b);
   176    176       create view v1 as select * from t1;
   177    177       create trigger v1t AFTER update on v1 for each row begin
   178    178         delete from t1 WHERE a=old.a+2;
   179    179       end;
   180    180     }
   181    181   } {1 {cannot create AFTER trigger on view: v1}}
   182    182   
   183    183   finish_test

Changes to test/trigger2.test.

     9      9   #
    10     10   # Regression testing of FOR EACH ROW table triggers
    11     11   #
    12     12   # 1. Trigger execution order tests. 
    13     13   # These tests ensure that BEFORE and AFTER triggers are fired at the correct
    14     14   # times relative to each other and the triggering statement. 
    15     15   #
    16         -# trig-1.1.*: ON UPDATE trigger execution model.
    17         -# trig-1.2.*: DELETE trigger execution model.
    18         -# trig-1.3.*: INSERT trigger execution model.
           16  +# trigger2-1.1.*: ON UPDATE trigger execution model.
           17  +# trigger2-1.2.*: DELETE trigger execution model.
           18  +# trigger2-1.3.*: INSERT trigger execution model.
    19     19   #
    20     20   # 2. Trigger program execution tests.
    21     21   # These tests ensure that trigger programs execute correctly (ie. that a
    22     22   # trigger program can correctly execute INSERT, UPDATE, DELETE * SELECT
    23     23   # statements, and combinations thereof).
    24     24   #
    25     25   # 3. Selective trigger execution 
    26     26   # This tests that conditional triggers (ie. UPDATE OF triggers and triggers
    27     27   # with WHEN clauses) are fired only fired when they are supposed to be.
    28     28   #
    29         -# trig-3.1: UPDATE OF triggers
    30         -# trig-3.2: WHEN clause
           29  +# trigger2-3.1: UPDATE OF triggers
           30  +# trigger2-3.2: WHEN clause
    31     31   #
    32     32   # 4. Cascaded trigger execution 
    33     33   # Tests that trigger-programs may cause other triggers to fire. Also that a 
    34     34   # trigger-program is never executed recursively.
    35     35   # 
    36         -# trig-4.1: Trivial cascading trigger
    37         -# trig-4.2: Trivial recursive trigger handling 
           36  +# trigger2-4.1: Trivial cascading trigger
           37  +# trigger2-4.2: Trivial recursive trigger handling 
    38     38   #
    39     39   # 5. Count changes behaviour.
    40     40   # Verify that rows altered by triggers are not included in the return value
    41     41   # of the "count changes" interface.
    42     42   #
    43     43   # 6. ON CONFLICT clause handling
    44         -# trig-6.1[a-f]: INSERT statements
    45         -# trig-6.2[a-f]: UPDATE statements
           44  +# trigger2-6.1[a-f]: INSERT statements
           45  +# trigger2-6.2[a-f]: UPDATE statements
    46     46   #
    47     47   # 7. Triggers on views fire correctly.
    48     48   #
    49     49   
    50     50   set testdir [file dirname $argv0]
    51     51   source $testdir/tester.tcl
    52     52   
................................................................................
    98     98         INSERT INTO clog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM clog), 
    99     99   	  old.a, old.b, 
   100    100   	  (SELECT sum(a) FROM tbl), (SELECT sum(b) FROM tbl), 
   101    101   	  new.a, new.b);
   102    102       END;
   103    103     }
   104    104   
   105         -  do_test trig-1.1.$ii {
          105  +  do_test trigger2-1.1.$ii {
   106    106       execsql {
   107    107         UPDATE tbl SET a = a * 10, b = b * 10;
   108    108         SELECT * FROM rlog ORDER BY idx;
   109    109         SELECT * FROM clog ORDER BY idx;
   110    110       }
   111    111     } [list 1 1 2  4  6 10 20 \
   112    112             2 1 2 13 24 10 20 \
................................................................................
   131    131         BEGIN
   132    132         INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), 
   133    133   	  old.a, old.b, 
   134    134   	  (SELECT sum(a) FROM tbl), (SELECT sum(b) FROM tbl), 
   135    135   	  0, 0);
   136    136       END;
   137    137     }
   138         -  do_test trig-1.2.$ii {
          138  +  do_test trigger2-1.2.$ii {
   139    139       execsql {
   140    140         DELETE FROM tbl;
   141    141         SELECT * FROM rlog;
   142    142       }
   143    143     } [list 1 100 100 400 300 0 0 \
   144    144             2 100 100 300 200 0 0 \
   145    145             3 300 200 300 200 0 0 \
................................................................................
   159    159         BEGIN
   160    160         INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), 
   161    161   	  0, 0,
   162    162   	  (SELECT sum(a) FROM tbl), (SELECT sum(b) FROM tbl), 
   163    163   	  new.a, new.b);
   164    164       END;
   165    165     }
   166         -  do_test trig-1.3.$ii {
          166  +  do_test trigger2-1.3.$ii {
   167    167       execsql {
   168    168   
   169    169         CREATE TABLE other_tbl(a, b);
   170    170         INSERT INTO other_tbl VALUES(1, 2);
   171    171         INSERT INTO other_tbl VALUES(3, 4);
   172    172         -- INSERT INTO tbl SELECT * FROM other_tbl;
   173    173         INSERT INTO tbl VALUES(5, 6);
................................................................................
   273    273   # Check execution of BEFORE programs:
   274    274   
   275    275       set before_data [ execsql "$prep $tr_program_cooked $statement $query" ]
   276    276   
   277    277       execsql "DELETE FROM tbl; DELETE FROM log; $prep";
   278    278       execsql "CREATE TRIGGER the_trigger BEFORE [string range $statement 0 6] ON tbl BEGIN $tr_program_fixed END;"
   279    279   
   280         -    do_test trig-2-$ii-before "execsql {$statement $query}" $before_data
          280  +    do_test trigger2-2-$ii-before "execsql {$statement $query}" $before_data
   281    281   
   282    282       execsql "DROP TRIGGER the_trigger;"
   283    283       execsql "DELETE FROM tbl; DELETE FROM log;"
   284    284   
   285    285   # Check execution of AFTER programs
   286    286       set after_data [ execsql "$prep $statement $tr_program_cooked $query" ]
   287    287   
   288    288       execsql "DELETE FROM tbl; DELETE FROM log; $prep";
   289    289   
   290    290       execsql "CREATE TRIGGER the_trigger AFTER [string range $statement 0 6] ON tbl BEGIN $tr_program_fixed END;"
   291    291   
   292         -    do_test trig-2-$ii-after "execsql {$statement $query}" $after_data
          292  +    do_test trigger2-2-$ii-after "execsql {$statement $query}" $after_data
   293    293       execsql "DROP TRIGGER the_trigger;"
   294    294     }
   295    295   }
   296    296   catchsql {
   297    297     DROP TABLE tbl;
   298    298     DROP TABLE log;
   299    299   }
   300    300   
   301    301   # 3.
   302    302   
   303         -# trig-3.1: UPDATE OF triggers
          303  +# trigger2-3.1: UPDATE OF triggers
   304    304   execsql {
   305    305     CREATE TABLE tbl (a, b, c, d);
   306    306     CREATE TABLE log (a);
   307    307     INSERT INTO log VALUES (0);
   308    308     INSERT INTO tbl VALUES (0, 0, 0, 0);
   309    309     INSERT INTO tbl VALUES (1, 0, 0, 0);
   310    310     CREATE TRIGGER tbl_after_update_cd BEFORE UPDATE OF c, d ON tbl
   311    311       BEGIN
   312    312         UPDATE log SET a = a + 1;
   313    313       END;
   314    314   }
   315         -do_test trig-3.1 {
          315  +do_test trigger2-3.1 {
   316    316     execsql {
   317    317       UPDATE tbl SET b = 1, c = 10; -- 2
   318    318       UPDATE tbl SET b = 10; -- 0
   319    319       UPDATE tbl SET d = 4 WHERE a = 0; --1
   320    320       UPDATE tbl SET a = 4, b = 10; --0
   321    321       SELECT * FROM log;
   322    322     }
   323    323   } {3}
   324    324   execsql {
   325    325     DROP TABLE tbl;
   326    326     DROP TABLE log;
   327    327   }
   328    328   
   329         -# trig-3.2: WHEN clause
          329  +# trigger2-3.2: WHEN clause
   330    330   set when_triggers [ list \
   331    331                {t1 BEFORE INSERT ON tbl WHEN new.a > 20} \
   332    332                {t2 BEFORE INSERT ON tbl WHEN (SELECT count(*) FROM tbl) = 0} ]
   333    333   
   334    334   execsql {
   335    335     CREATE TABLE tbl (a, b, c, d);
   336    336     CREATE TABLE log (a);
................................................................................
   337    337     INSERT INTO log VALUES (0);
   338    338   }
   339    339   
   340    340   foreach trig $when_triggers {
   341    341     execsql "CREATE TRIGGER $trig BEGIN UPDATE log set a = a + 1; END;"
   342    342   }
   343    343   
   344         -do_test trig-3.2 {
          344  +do_test trigger2-3.2 {
   345    345     execsql { 
   346    346   
   347    347       INSERT INTO tbl VALUES(0, 0, 0, 0);     -- 1
   348    348       SELECT * FROM log;
   349    349       UPDATE log SET a = 0;
   350    350   
   351    351       INSERT INTO tbl VALUES(0, 0, 0, 0);     -- 0
................................................................................
   372    372       INSERT INTO tblB values(new.a, new.b);
   373    373     END;
   374    374   
   375    375     CREATE TRIGGER tr2 BEFORE INSERT ON tblB BEGIN
   376    376       INSERT INTO tblC values(new.a, new.b);
   377    377     END;
   378    378   }
   379         -do_test trig-4.1 {
          379  +do_test trigger2-4.1 {
   380    380     execsql {
   381    381       INSERT INTO tblA values(1, 2);
   382    382       SELECT * FROM tblA;
   383    383       SELECT * FROM tblB;
   384    384       SELECT * FROM tblC;
   385    385     }
   386    386   } {1 2 1 2 1 2}
................................................................................
   394    394   execsql {
   395    395     CREATE TABLE tbl(a, b, c);
   396    396     CREATE TRIGGER tbl_trig BEFORE INSERT ON tbl 
   397    397       BEGIN
   398    398         INSERT INTO tbl VALUES (new.a, new.b, new.c);
   399    399       END;
   400    400   }
   401         -do_test trig-4.2 {
          401  +do_test trigger2-4.2 {
   402    402     execsql {
   403    403       INSERT INTO tbl VALUES (1, 2, 3);
   404    404       select * from tbl;
   405    405     }
   406    406   } {1 2 3 1 2 3}
   407    407   execsql {
   408    408     DROP TABLE tbl;
................................................................................
   416    416         INSERT INTO tbl VALUES (1, 2, 3);
   417    417         INSERT INTO tbl VALUES (2, 2, 3);
   418    418         UPDATE tbl set b = 10 WHERE a = 1;
   419    419         DELETE FROM tbl WHERE a = 1;
   420    420         DELETE FROM tbl;
   421    421       END;
   422    422   }
   423         -do_test trig-5 {
          423  +do_test trigger2-5 {
   424    424     execsql {
   425    425       INSERT INTO tbl VALUES(100, 200, 300);
   426    426     }
   427    427     db changes
   428    428   } {1}
   429    429   execsql {
   430    430     DROP TABLE tbl;
................................................................................
   433    433   # Handling of ON CONFLICT by INSERT statements inside triggers
   434    434   execsql {
   435    435     CREATE TABLE tbl (a primary key, b, c);
   436    436     CREATE TRIGGER ai_tbl AFTER INSERT ON tbl BEGIN
   437    437       INSERT OR IGNORE INTO tbl values (new.a, 0, 0);
   438    438     END;
   439    439   }
   440         -do_test trig-6.1a {
          440  +do_test trigger2-6.1a {
   441    441     execsql {
   442    442       BEGIN;
   443    443       INSERT INTO tbl values (1, 2, 3);
   444    444       SELECT * from tbl;
   445    445     }
   446    446   } {1 2 3}
   447         -do_test trig-6.1b {
          447  +do_test trigger2-6.1b {
   448    448     catchsql {
   449    449       INSERT OR ABORT INTO tbl values (2, 2, 3);
   450    450     }
   451    451   } {1 {constraint failed}}
   452         -do_test trig-6.1c {
          452  +do_test trigger2-6.1c {
   453    453     execsql {
   454    454       SELECT * from tbl;
   455    455     }
   456    456   } {1 2 3}
   457         -do_test trig-6.1d {
          457  +do_test trigger2-6.1d {
   458    458     catchsql {
   459    459       INSERT OR FAIL INTO tbl values (2, 2, 3);
   460    460     }
   461    461   } {1 {constraint failed}}
   462         -do_test trig-6.1e {
          462  +do_test trigger2-6.1e {
   463    463     execsql {
   464    464       SELECT * from tbl;
   465    465     }
   466    466   } {1 2 3 2 2 3}
   467         -do_test trig-6.1f {
          467  +do_test trigger2-6.1f {
   468    468     execsql {
   469    469       INSERT OR REPLACE INTO tbl values (2, 2, 3);
   470    470       SELECT * from tbl;
   471    471     }
   472    472   } {1 2 3 2 0 0}
   473         -do_test trig-6.1g {
          473  +do_test trigger2-6.1g {
   474    474     catchsql {
   475    475       INSERT OR ROLLBACK INTO tbl values (3, 2, 3);
   476    476     }
   477    477   } {1 {constraint failed}}
   478         -do_test trig-6.1h {
          478  +do_test trigger2-6.1h {
   479    479     execsql {
   480    480       SELECT * from tbl;
   481    481     }
   482    482   } {}
   483    483   
   484    484   
   485    485   # Handling of ON CONFLICT by UPDATE statements inside triggers
................................................................................
   486    486   execsql {
   487    487     INSERT INTO tbl values (4, 2, 3);
   488    488     INSERT INTO tbl values (6, 3, 4);
   489    489     CREATE TRIGGER au_tbl AFTER UPDATE ON tbl BEGIN
   490    490       UPDATE OR IGNORE tbl SET a = new.a, c = 10;
   491    491     END;
   492    492   }
   493         -do_test trig-6.2a {
          493  +do_test trigger2-6.2a {
   494    494     execsql {
   495    495       BEGIN;
   496    496       UPDATE tbl SET a = 1 WHERE a = 4;
   497    497       SELECT * from tbl;
   498    498     }
   499    499   } {1 2 10 6 3 4}
   500         -do_test trig-6.2b {
          500  +do_test trigger2-6.2b {
   501    501     catchsql {
   502    502       UPDATE OR ABORT tbl SET a = 4 WHERE a = 1;
   503    503     }
   504    504   } {1 {constraint failed}}
   505         -do_test trig-6.2c {
          505  +do_test trigger2-6.2c {
   506    506     execsql {
   507    507       SELECT * from tbl;
   508    508     }
   509    509   } {1 2 10 6 3 4}
   510         -do_test trig-6.2d {
          510  +do_test trigger2-6.2d {
   511    511     catchsql {
   512    512       UPDATE OR FAIL tbl SET a = 4 WHERE a = 1;
   513    513     }
   514    514   } {1 {constraint failed}}
   515         -do_test trig-6.2e {
          515  +do_test trigger2-6.2e {
   516    516     execsql {
   517    517       SELECT * from tbl;
   518    518     }
   519    519   } {4 2 10 6 3 4}
   520         -do_test trig-6.2f {
          520  +do_test trigger2-6.2f {
   521    521     execsql {
   522    522       UPDATE OR REPLACE tbl SET a = 1 WHERE a = 4;
   523    523       SELECT * from tbl;
   524    524     }
   525    525   } {1 3 10}
   526    526   execsql {
   527    527     INSERT INTO tbl VALUES (2, 3, 4);
   528    528   }
   529         -do_test trig-6.2g {
          529  +do_test trigger2-6.2g {
   530    530     catchsql {
   531    531       UPDATE OR ROLLBACK tbl SET a = 4 WHERE a = 1;
   532    532     }
   533    533   } {1 {constraint failed}}
   534         -do_test trig-6.2h {
          534  +do_test trigger2-6.2h {
   535    535     execsql {
   536    536       SELECT * from tbl;
   537    537     }
   538    538   } {4 2 3 6 3 4}
   539    539   execsql {
   540    540     DROP TABLE tbl;
   541    541   }
   542    542   
   543    543   # 7. Triggers on views
   544         -do_test trig-7.1 {
          544  +do_test trigger2-7.1 {
   545    545     execsql {
   546    546     CREATE TABLE ab(a, b);
   547    547     CREATE TABLE cd(c, d);
   548    548     INSERT INTO ab VALUES (1, 2);
   549    549     INSERT INTO ab VALUES (0, 0);
   550    550     INSERT INTO cd VALUES (3, 4);
   551    551   
................................................................................
   579    579      CREATE TRIGGER after_insert INSTEAD OF INSERT ON abcd BEGIN
   580    580       INSERT INTO tlog VALUES(NULL, 
   581    581   	0, 0, 0, 0, new.a, new.b, new.c, new.d);
   582    582      END;
   583    583     }
   584    584   } {}
   585    585   
   586         -do_test trig-7.2 {
          586  +do_test trigger2-7.2 {
   587    587     execsql {
   588    588       UPDATE abcd SET a = 100, b = 5*5 WHERE a = 1;
   589    589       DELETE FROM abcd WHERE a = 1;
   590    590       INSERT INTO abcd VALUES(10, 20, 30, 40);
   591    591       SELECT * FROM tlog;
   592    592     }
   593    593   } [ list 1 1 2 3 4 100 25 3 4 \

Changes to test/trigger3.test.

    25     25       CREATE TRIGGER after_tbl_insert AFTER INSERT ON tbl BEGIN SELECT CASE 
    26     26   	WHEN (new.a = 1) THEN RAISE(ABORT,    'Trigger abort') 
    27     27   	WHEN (new.a = 2) THEN RAISE(FAIL,     'Trigger fail') 
    28     28   	WHEN (new.a = 3) THEN RAISE(ROLLBACK, 'Trigger rollback') END;
    29     29       END;
    30     30   }
    31     31   # ABORT
    32         -do_test trig-raise-1.1 {
           32  +do_test trigger3-1.1 {
    33     33       catchsql {
    34     34   	BEGIN;
    35     35           INSERT INTO tbl VALUES (5, 5, 6);
    36     36           INSERT INTO tbl VALUES (1, 5, 6);
    37     37       }
    38     38   } {1 {Trigger abort}}
    39     39   
    40         -do_test trig-raise-1.2 {
           40  +do_test trigger3-1.2 {
    41     41       execsql {
    42     42   	SELECT * FROM tbl;
    43     43   	ROLLBACK;
    44     44       }
    45     45   } {5 5 6}
    46     46   
    47     47   # FAIL
    48         -do_test trig-raise-2.1 {
           48  +do_test trigger3-2.1 {
    49     49       catchsql {
    50     50   	BEGIN;
    51     51           INSERT INTO tbl VALUES (5, 5, 6);
    52     52           INSERT INTO tbl VALUES (2, 5, 6);
    53     53       }
    54     54   } {1 {Trigger fail}}
    55         -do_test trig-raise-2.2 {
           55  +do_test trigger3-2.2 {
    56     56       execsql {
    57     57   	SELECT * FROM tbl;
    58     58   	ROLLBACK;
    59     59       }
    60     60   } {5 5 6 2 5 6}
    61     61   # ROLLBACK
    62         -do_test trig-raise-3.1 {
           62  +do_test trigger3-3.1 {
    63     63       catchsql {
    64     64   	BEGIN;
    65     65           INSERT INTO tbl VALUES (5, 5, 6);
    66     66           INSERT INTO tbl VALUES (3, 5, 6);
    67     67       }
    68     68   } {1 {Trigger rollback}}
    69         -do_test trig-raise-3.2 {
           69  +do_test trigger3-3.2 {
    70     70       execsql {
    71     71   	SELECT * FROM tbl;
    72     72       }
    73     73   } {}
    74     74   # IGNORE
    75         -do_test trig-raise-4.1 {
           75  +do_test trigger3-4.1 {
    76     76       catchsql {
    77     77   	BEGIN;
    78     78           INSERT INTO tbl VALUES (5, 5, 6);
    79     79           INSERT INTO tbl VALUES (4, 5, 6);
    80     80       }
    81     81   } {0 {}}
    82         -do_test trig-raise-4.2 {
           82  +do_test trigger3-4.2 {
    83     83       execsql {
    84     84   	SELECT * FROM tbl;
    85     85   	ROLLBACK;
    86     86       }
    87     87   } {5 5 6}
    88     88   
    89     89   # Check that we can also do RAISE(IGNORE) for UPDATE and DELETE
................................................................................
    96     96   	SELECT CASE WHEN (old.a = 1) THEN RAISE(IGNORE) END;
    97     97       END;
    98     98   
    99     99       CREATE TRIGGER before_tbl_delete BEFORE DELETE ON tbl BEGIN
   100    100   	SELECT CASE WHEN (old.a = 1) THEN RAISE(IGNORE) END;
   101    101       END;
   102    102   }
   103         -do_test trig-raise-5.1 {
          103  +do_test trigger3-5.1 {
   104    104       execsql {
   105    105   	UPDATE tbl SET c = 10;
   106    106   	SELECT * FROM tbl;
   107    107       }
   108    108   } {1 2 3 4 5 10}
   109         -do_test trig-raise-5.2 {
          109  +do_test trigger3-5.2 {
   110    110       execsql {
   111    111   	DELETE FROM tbl;
   112    112   	SELECT * FROM tbl;
   113    113       }
   114    114   } {1 2 3}
   115    115   
   116    116   # Check that RAISE(IGNORE) works correctly for nested triggers:
................................................................................
   117    117   execsql {CREATE TABLE tbl2(a, b, c)}
   118    118   execsql {
   119    119       CREATE TRIGGER after_tbl2_insert AFTER INSERT ON tbl2 BEGIN
   120    120   	UPDATE tbl SET c = 10;
   121    121           INSERT INTO tbl2 VALUES (new.a, new.b, new.c);
   122    122       END;
   123    123   }
   124         -do_test trig-raise-6 {
          124  +do_test trigger3-6 {
   125    125       execsql {
   126    126   	INSERT INTO tbl2 VALUES (1, 2, 3);
   127    127   	SELECT * FROM tbl2;
   128    128   	SELECT * FROM tbl;
   129    129       }
   130    130   } {1 2 3 1 2 3 1 2 3}
   131    131   
................................................................................
   135    135       CREATE TRIGGER tbl_view_insert INSTEAD OF INSERT ON tbl_view BEGIN
   136    136   	SELECT CASE WHEN (new.a = 1) THEN RAISE(ROLLBACK, 'View rollback')
   137    137   	            WHEN (new.a = 2) THEN RAISE(IGNORE) 
   138    138   	            WHEN (new.a = 3) THEN RAISE(ABORT, 'View abort') END;
   139    139       END;
   140    140   }
   141    141   
   142         -do_test trig-raise-7.1 {
          142  +do_test trigger3-7.1 {
   143    143       catchsql {
   144    144   	INSERT INTO tbl_view VALUES(1, 2, 3);
   145    145       }
   146    146   } {1 {View rollback}}
   147         -do_test trig-raise-7.2 {
          147  +do_test trigger3-7.2 {
   148    148       catchsql {
   149    149   	INSERT INTO tbl_view VALUES(2, 2, 3);
   150    150       }
   151    151   } {0 {}}
   152         -do_test trig-raise-7.3 {
          152  +do_test trigger3-7.3 {
   153    153       catchsql {
   154    154   	INSERT INTO tbl_view VALUES(3, 2, 3);
   155    155       }
   156    156   } {1 {View abort}}
   157    157   
   158    158   catchsql { DROP TABLE tbl; } 
   159    159   catchsql { DROP TABLE tbl2; } 
   160    160   catchsql { DROP VIEW tbl_view; }
   161    161   
   162    162   finish_test