/ Check-in [03e464be]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:When coding a trigger, assume that the "oldmask" requires all columns until we know otherwise. That pessimistic assumption assures that all necessary parameters are available on a cascading delete trigger. Ticket [e25d9ea771f]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 03e464be51a1c36fc02cf31178ae91f736dfddd6
User & Date: drh 2009-09-17 00:41:20
References
2009-09-17
00:47 Fixed ticket [e25d9ea7]: Cascading delete trigger fails. plus 4 other changes artifact: df2f80f3 user: drh
Context
2009-09-19
17:00
Check in implementation of foreign key constraints. check-in: d5d39981 user: dan tags: trunk
2009-09-17
00:41
When coding a trigger, assume that the "oldmask" requires all columns until we know otherwise. That pessimistic assumption assures that all necessary parameters are available on a cascading delete trigger. Ticket [e25d9ea771f] check-in: 03e464be user: drh tags: trunk
2009-09-14
23:47
Make sure sufficient space is allocated for at least one VDBE cursor when autoincrement is used. Ticket [a696379c1f088]. check-in: 2b2a1ef7 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/trigger.c.

805
806
807
808
809
810
811

812
813
814
815
816
817
818
  pPrg->pNext = pTop->pTriggerPrg;
  pTop->pTriggerPrg = pPrg;
  pPrg->pProgram = pProgram = sqlite3DbMallocZero(db, sizeof(SubProgram));
  if( !pProgram ) return 0;
  pProgram->nRef = 1;
  pPrg->pTrigger = pTrigger;
  pPrg->orconf = orconf;


  /* Allocate and populate a new Parse context to use for coding the 
  ** trigger sub-program.  */
  pSubParse = sqlite3StackAllocZero(db, sizeof(Parse));
  if( !pSubParse ) return 0;
  memset(&sNC, 0, sizeof(sNC));
  sNC.pParse = pSubParse;







>







805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
  pPrg->pNext = pTop->pTriggerPrg;
  pTop->pTriggerPrg = pPrg;
  pPrg->pProgram = pProgram = sqlite3DbMallocZero(db, sizeof(SubProgram));
  if( !pProgram ) return 0;
  pProgram->nRef = 1;
  pPrg->pTrigger = pTrigger;
  pPrg->orconf = orconf;
  pPrg->oldmask = 0xffffffff;

  /* Allocate and populate a new Parse context to use for coding the 
  ** trigger sub-program.  */
  pSubParse = sqlite3StackAllocZero(db, sizeof(Parse));
  if( !pSubParse ) return 0;
  memset(&sNC, 0, sizeof(sNC));
  sNC.pParse = pSubParse;

Changes to test/triggerC.test.

756
757
758
759
760
761
762
763

764

























765
    BEGIN;
      DELETE FROM t7 WHERE a = 1;
      SELECT rowid, * FROM t7;
      SELECT * FROM t8;
    ROLLBACK;
  }
} {2 3 4 3 5 6 8 1 2}




























finish_test








>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
    BEGIN;
      DELETE FROM t7 WHERE a = 1;
      SELECT rowid, * FROM t7;
      SELECT * FROM t8;
    ROLLBACK;
  }
} {2 3 4 3 5 6 8 1 2}

# Ticket [e25d9ea771febc9c311928c1c01c3163dcb26643]
# 
do_test triggerC-9.1 {
  execsql {
    CREATE TABLE t9(a,b);
    CREATE INDEX t9b ON t9(b);
    INSERT INTO t9 VALUES(1,0);
    INSERT INTO t9 VALUES(2,1);
    INSERT INTO t9 VALUES(3,2);
    INSERT INTO t9 SELECT a+3, a+2 FROM t9;
    INSERT INTO t9 SELECT a+6, a+5 FROM t9;
    SELECT a FROM t9 ORDER BY a;
  }
} {1 2 3 4 5 6 7 8 9 10 11 12}
do_test triggerC-9.2 {
  execsql {
    CREATE TRIGGER t9r1 AFTER DELETE ON t9 BEGIN
      DELETE FROM t9 WHERE b=old.a;
    END;
    DELETE FROM t9 WHERE b=4;
    SELECT a FROM t9 ORDER BY a;
  }
} {1 2 3 4}
 



finish_test