Home | History | Annotate | Download | only in dist

Lines Matching defs:Trigger

1913 ** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].
1920 ** which case the trigger setting is not reported back. </dd>
1957 ** ^(If an [INSERT] occurs within a trigger or within a [virtual table]
1959 ** row as long as the trigger or virtual table method is running.
1960 ** But once the trigger or virtual table method ends, the value returned
1961 trigger or virtual
2001 ** ^Changes to a view that are simulated by an [INSTEAD OF trigger]
2010 ** A "trigger context" is a scope of execution that begins and
2011 ** ends with the script of a [CREATE TRIGGER | trigger].
2013 ** evaluated outside of any trigger. This is the "top level"
2014 ** trigger context. If a trigger fires from the top level, a
2015 ** new trigger context is entered for the duration of that one
2016 ** trigger. Subtriggers create subcontexts for their duration.
2019 ** not create a new trigger context.
2023 ** trigger context.
2027 ** that also occurred at the top level. ^(Within the body of a trigger,
2030 ** statement within the body of the same trigger.
2049 ** from all [CREATE TRIGGER | trigger] contexts and changes made by
2053 ** count does not include rows of views that fire an [INSTEAD OF trigger],
2054 ** though if the INSTEAD OF trigger makes changes of its own, those changes
2117 ** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within
2644 ** is the name of the inner-most trigger or view that is responsible for
2653 #define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */
2655 #define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */
2662 #define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */
2664 #define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */
2696 ** contain a UTF-8 SQL comment that identifies the trigger.)^
7825 ** A value of 1 means that a trigger program will not be able to itself
7826 ** fire any triggers. A value of 0 means that no trigger programs at all
8815 typedef struct Trigger Trigger;
9170 ** A sub-routine used to implement a trigger program.
10465 u8 orphanTrigger; /* Last statement is orphaned TEMP trigger */
10967 Trigger *pTrigger; /* List of triggers stored in pSchema */
11037 Trigger *apTrigger[2];/* Triggers for aAction[] actions */
11504 ** CREATE TRIGGER trig BEFORE UPDATE ON t(a,b,c) ...;
11848 ** trigger that may be fired while parsing an INSERT, UPDATE or DELETE
11853 ** A Vdbe sub-program that implements the body and WHEN clause of trigger
11865 Trigger *pTrigger; /* Trigger this program was coded from */
11958 /* Information used while coding trigger programs. */
11967 u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */
11996 Trigger *pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */
12043 * Each trigger present in the database schema is stored as an instance of
12044 * struct Trigger.
12046 * Pointers to instances of struct Trigger are stored in two ways.
12048 * database). This allows Trigger structures to be retrieved by name.
12050 * pNext member of struct Trigger. A pointer to the first element of the
12055 * containing the SQL statements specified as the trigger program.
12057 struct Trigger {
12058 char *zName; /* The name of the trigger */
12059 char *table; /* The table or view to which the trigger applies */
12063 IdList *pColumns; /* If this is an UPDATE OF <column-list> trigger,
12065 Schema *pSchema; /* Schema containing the trigger */
12067 TriggerStep *step_list; /* Link list of trigger program steps */
12068 Trigger *pNext; /* Next trigger associated with the table */
12072 ** A trigger is either a BEFORE or an AFTER trigger. The following constants
12083 * that is a part of a trigger-program.
12087 * associated struct Trigger instance. The first element of the linked list is
12088 * the first step of the trigger-program.
12122 Trigger *pTrig; /* The trigger that this step is a part of */
12667 SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8);
12704 SQLITE_PRIVATE void sqlite3DropTriggerPtr(Parse*, Trigger*);
12705 SQLITE_PRIVATE Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask);
12706 SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *, Table *);
12707 SQLITE_PRIVATE void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *,
12709 SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);
12717 SQLITE_PRIVATE void sqlite3DeleteTrigger(sqlite3*, Trigger*);
12719 SQLITE_PRIVATE u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);
14515 sqlite3DeleteTrigger(db, (Trigger*)sqliteHashData(p));
19983 ** Trigger the alarm
24593 ** On some systems, calls to fchown() will trigger a message in a security
63534 ** the trigger subprograms are listed one by one.
63569 ** the sum of the number of rows in all trigger subprograms encountered
63570 ** so far. The nRow value will increase as new trigger subprograms are
63577 ** to trigger subprograms. The VDBE is guaranteed to have at least 9
63995 ** is used, for example, when a trigger sub-program is halted to restore
72282 ** This is used by trigger programs.
73203 ** the trigger named P4 in database P1. This is called after a trigger
73385 ** Execute the trigger program passed as P4 (type P4_SUBPROGRAM).
73394 ** P4 is a pointer to the VM containing the trigger program.
73406 void *t; /* Token identifying trigger */
73414 ** is really a trigger, not a foreign key action, and the flag set
73418 ** disabled. In some cases a single trigger may generate more than one
73419 ** SubProgram (if the trigger may be executed with more than one different
73421 ** single trigger all have the same value for the SubProgram.token
73431 sqlite3SetString(&p->zErrMsg, db, "too many levels of trigger recursion");
73437 ** the trigger program. If this trigger has been fired before, then pRt
73509 ** address space. This is used by trigger programs to access the new.*
77016 int isTrigger = 0; /* True if resolved to a trigger column */
77116 ** it is a new.* or old.* trigger argument reference
78100 ** Y: The name of a table in a FROM clause. Or in a trigger
80001 ** * We are inside a trigger
81188 ** trigger programs. In this case Expr.iTable is set to 1 for the
81330 "RAISE() may only be used within a trigger-program");
81676 ** trigger programs. In this case Expr.iTable is set to 1 for the
82752 ** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER
82754 ** TRIGGER statement is replaced with the third argument and the result
82756 ** TRIGGER, not CREATE INDEX and CREATE TABLE.
82776 /* The principle used to locate the table name in the CREATE TRIGGER
82809 ** "CREATE TRIGGER ... ON ON.ON BEGIN ..." etc.
82818 ** in the CREATE TRIGGER statement.
82900 Trigger *pTrig;
82905 ** returned, loop through the tables list of triggers. For each trigger
82918 char *zNew = sqlite3MPrintf(pParse->db, "type='trigger' AND (%s)", zWhere);
82938 Trigger *pTrig;
82959 /* Reload the table, index and permanent trigger schemas. */
83125 "WHEN type = 'trigger' THEN sqlite_rename_trigger(sql, %Q)"
83135 "(type='table' OR type='index' OR type='trigger');",
85705 const char *zType, /* "view", "trigger", or "index" */
85706 const Token *pName /* Name of the view, trigger, or index */
85726 ** These routines are used to make sure that an index, trigger, or
85842 TriggerStep *pStep /* The trigger step be fixed to one database */
85987 ** is in pTabList or else it is the NEW or OLD table of a trigger.
86458 ** non-NULL if it is part of a view or trigger program definition. See
86817 /* The table or view or trigger name is passed to this routine via tokens
86866 ** trigger). All names are legal except those that begin with the string
88051 sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName));
88440 Trigger *pTrigger;
88482 ** dropped. Triggers are handled separately because a trigger can be
88487 "DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'",
90812 sqlite3DeleteTrigger(0, (Trigger*)sqliteHashData(pElem));
91107 Trigger *pTrigger; /* List of table triggers, if required */
91442 Trigger *pTrigger, /* List of triggers to (potentially) fire */
91462 ** (this can happen if a trigger program has already deleted it), do
91477 int addrStart; /* Start of BEFORE trigger programs */
91499 /* Invoke BEFORE DELETE trigger programs. */
91538 /* Invoke AFTER DELETE trigger programs. */
91544 ** trigger programs were invoked. Or if a trigger program throws a
94107 ** The second argument is a Trigger structure allocated by the
94108 ** fkActionTrigger() routine. This function deletes the Trigger structure
94111 ** The Trigger structure or any of its sub-components may be allocated from
94114 static void fkTriggerDelete(sqlite3 *dbMem, Trigger *p){
94434 ** deferred trigger. That's what RESTRICT means. To defer checking
94527 ** It returns a pointer to a Trigger structure containing a trigger
94539 ** then the returned trigger structure is equivalent to:
94541 ** CREATE TRIGGER ... DELETE ON p BEGIN
94549 static Trigger *fkActionTrigger(
94557 Trigger *pTrigger; /* Trigger definition to return */
94569 TriggerStep *pStep = 0; /* First (only) step of trigger program */
94570 Expr *pWhere = 0; /* WHERE clause of trigger step */
94574 Expr *pWhen = 0; /* WHEN clause for the trigger */
94676 pTrigger = (Trigger *)sqlite3DbMallocZero(db,
94677 sizeof(Trigger) + /* struct Trigger */
94678 sizeof(TriggerStep) + /* Single step in trigger program */
94746 ** trigger sub-program. */
94751 Trigger *pAct = fkActionTrigger(pParse, pTab, pFKey, pChanges);
95055 /* This routine is never called during trigger-generation. It is
95284 Trigger *pTrigger; /* List of triggers on pTab, if required */
95285 int tmask; /* Mask of trigger times */
95599 ** translated into a unique ID for the row. But on a BEFORE trigger,
95645 /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger,
96132 Trigger *pTrigger = 0;
96306 Trigger *pTrigger = 0;
100630 ** argv[1] = root page number for table or index. 0 for trigger or view.
102377 ** the body of a TRIGGER. The purpose of such selects is to call
102773 /* At one time, code such as "SELECT new.x" within a trigger would
102775 ** trigger code is generated and so this condition is no longer
106143 ** a trigger, then we only need to compute the value of the subquery
107079 /************** Begin file trigger.c *****************************************/
107113 ** the table. The list is connected by Trigger.pNext pointers.
107125 SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){
107127 Trigger *pList = 0; /* List of triggers to return */
107137 Trigger *pTrig = (Trigger *)sqliteHashData(p);
107151 ** This is called by the parser when it sees a CREATE TRIGGER statement
107152 ** up to the point of the BEGIN before the trigger actions. A Trigger
107154 ** in pParse->pNewTrigger. After the trigger actions have been parsed, the
107155 ** sqlite3FinishTrigger() function is called to complete the trigger
107159 Parse *pParse, /* The parse context of the CREATE TRIGGER statement */
107160 Token *pName1, /* The name of the trigger */
107161 Token *pName2, /* The name of the trigger */
107164 IdList *pColumns, /* column list if this is an UPDATE OF trigger */
107165 SrcList *pTableName,/* The name of the table/view the trigger applies to */
107168 int noErr /* Suppress errors if the trigger already exists */
107170 Trigger *pTrigger = 0; /* The new trigger */
107171 Table *pTab; /* Table that the trigger fires off of */
107172 char *zName = 0; /* Name of the trigger */
107174 int iDb; /* The database to store the trigger in */
107184 /* If TEMP was specified, then the trigger name may not be qualified. */
107186 sqlite3ErrorMsg(pParse, "temporary trigger may not have qualified name");
107192 /* Figure out the db that the trigger will be created in */
107204 ** CREATE TRIGGER attached.demo AFTER INSERT ON attached.tab ....
107215 /* If the trigger name was unqualified, and the table is a temp table,
107216 ** then set iDb to 1 to create the trigger in the temporary database.
107229 sqlite3FixInit(&sFix, pParse, iDb, "trigger", pName);
107239 ** dropped too. But if a TEMP trigger is created on a non-TEMP table
107241 ** trigger is not visible to the database connection that does the
107242 ** drop so the trigger cannot be dropped. This results in an
107243 ** "orphaned trigger" - a trigger whose associated table is missing.
107254 /* Check that the trigger name is not reserved and that no trigger of the
107264 sqlite3ErrorMsg(pParse, "trigger %T already exists", pName);
107272 /* Do not create a trigger on a system table */
107274 sqlite3ErrorMsg(pParse, "cannot create trigger on system table");
107283 sqlite3ErrorMsg(pParse, "cannot create %s trigger on view: %S",
107289 " trigger on table: %S", pTableName, 0);
107311 ** INSTEAD OF trigger into a BEFORE trigger. It simplifies code
107318 /* Build the Trigger object */
107319 pTrigger = (Trigger*)sqlite3DbMallocZero(db, sizeof(Trigger));
107346 ** This routine is called after all of the trigger actions have been parsed
107347 ** in order to complete the process of building the trigger.
107352 Token *pAll /* Token that describes the complete CREATE TRIGGER */
107354 Trigger *pTrig = pParse->pNewTrigger; /* Trigger being finished */
107355 char *zName; /* Name of trigger */
107358 int iDb; /* Database containing the trigger */
107359 Token nameToken; /* Trigger name for error reporting */
107372 sqlite3FixInit(&sFix, pParse, iDb, "trigger", &nameToken);
107392 "INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')",
107398 sqlite3MPrintf(db, "type='trigger' AND name='%q'", zName));
107402 Trigger *pLink = pTrig;
107426 ** a trigger step. Return a pointer to a TriggerStep structure.
107429 ** body of a TRIGGER.
107444 ** Allocate space to hold a new trigger step. The allocated space
107451 u8 op, /* Trigger opcode */
107468 ** Build a trigger step out of an INSERT statement. Return a pointer
107469 ** to the new trigger step.
107472 ** body of a trigger.
107499 ** Construct a trigger step that implements an UPDATE statement and return
107500 ** a pointer to that trigger step. The parser calls this routine when it
107501 ** sees an UPDATE statement inside the body of a CREATE TRIGGER.
107524 ** Construct a trigger step that implements a DELETE statement and return
107525 ** a pointer to that trigger step. The parser calls this routine when it
107526 ** sees a DELETE statement inside the body of a CREATE TRIGGER.
107545 ** Recursively delete a Trigger structure
107547 SQLITE_PRIVATE void sqlite3DeleteTrigger(sqlite3 *db, Trigger *pTrigger){
107558 ** This function is called to drop a trigger from the database schema.
107561 ** the trigger by name. The sqlite3DropTriggerPtr() routine does the
107562 ** same job as this routine except it takes a pointer to the trigger
107563 ** instead of the trigger name.
107566 Trigger *pTrigger = 0;
107592 sqlite3ErrorMsg(pParse, "no such trigger: %S", pName, 0);
107606 ** Return a pointer to the Table structure for the table that a trigger
107609 static Table *tableOfTrigger(Trigger *pTrigger){
107616 ** Drop a trigger given a pointer to that trigger.
107618 SQLITE_PRIVATE void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){
107642 /* Generate code to destroy the database record of the trigger.
107653 { OP_String8, 0, 1, 0}, /* 4: "trigger" */
107664 sqlite3VdbeChangeP4(v, base+4, "trigger", P4_STATIC);
107675 ** Remove a trigger from the hash tables of the sqlite* pointer.
107678 Trigger *pTrigger;
107687 Trigger **pp;
107716 ** one trigger that must be fired when an operation of type 'op' is
107720 SQLITE_PRIVATE Trigger *sqlite3TriggersExist(
107728 Trigger *pList = 0;
107729 Trigger *p;
107751 ** forming the SrcList. This prevents a trigger in one database from
107753 ** trigger is in TEMP in which case it can refer to any other database it
107758 TriggerStep *pStep /* The trigger containing the target token */
107779 ** trigger.
107783 TriggerStep *pStepList, /* List of statements inside the trigger body */
107795 ** of the trigger program. If the statement that caused this trigger
107797 ** the ON CONFLICT policy that was specified as part of the trigger
107800 ** CREATE TRIGGER AFTER INSERT ON t1 BEGIN;
107873 ** (trigger program). If an error has occurred, transfer error information
107889 ** implementing trigger pTrigger with ON CONFLICT policy orconf.
107893 Trigger *pTrigger, /* Trigger to code */
107895 int orconf /* ON CONFLICT policy to code trigger program with */
107900 Expr *pWhen = 0; /* Duplicate of trigger WHEN expression */
107903 SubProgram *pProgram = 0; /* Sub-vdbe for trigger program */
107926 ** trigger sub-program. */
107950 sqlite3MPrintf(db, "-- TRIGGER %s", pTrigger->zName), P4_DYNAMIC
107968 /* Code the trigger program into the sub-vdbe. */
108001 ** trigger pTrigger with default ON CONFLICT algorithm orconf. If no such
108007 Trigger *pTrigger, /* Trigger to code */
108008 Table *pTab, /* The table trigger pTrigger is attached to */
108016 /* It may be that this trigger has already been coded (or is in the
108034 ** Generate code for the trigger program associated with trigger p on
108041 Trigger *p, /* Trigger to code */
108053 ** is a pointer to the sub-vdbe containing the trigger program. */
108063 ** recursive invocation of this trigger program is disallowed. Recursive
108064 ** invocation is disallowed if (a) the sub-program is really a trigger,
108083 ** in the trigger program. If N is the number of columns in table pTab
108098 ** never be accessed by the trigger program, so they are not allocated or
108102 ** ON INSERT trigger, the value passed to this function as parameter reg
108107 ** trigger program to use (REPLACE, IGNORE etc.). Parameter ignoreJump
108108 ** is the instruction that control should jump to if a trigger program
108113 Trigger *pTrigger, /* List of triggers on table pTab */
108122 Trigger *p; /* Used to iterate through pTrigger list */
108130 /* Sanity checking: The schema for the trigger and for the table are
108131 ** always defined. The trigger must be in the same schema as the table
108132 ** or else it must be a TEMP trigger. */
108138 /* Determine whether we should code this trigger */
108175 Trigger *pTrigger, /* List of triggers on table pTab */
108180 int orconf /* Default ON CONFLICT policy for trigger steps */
108184 Trigger *p;
108204 /************** End of trigger.c *********************************************/
108330 int isView; /* True when updating a view (INSTEAD OF trigger) */
108331 Trigger *pTrigger; /* List of triggers on pTab, if required */
108703 ** the database after the BEFORE triggers are fired anyway (as the trigger
108722 ** a new.* reference in a trigger program.
108741 /* The row-trigger may have deleted the row being updated. In this
108744 ** is deleted or renamed by a BEFORE trigger - is left undefined in the
108755 /* If it did not delete it, the row-trigger may still have modified
109265 " WHERE type='view' OR type='trigger'"
117515 ** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT,
118286 27, /* TRIGGER => ID */
118387 "RESTRICT", "ROW", "TRIGGER", "VACUUM",
118708 /* 265 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
118736 /* 293 */ "cmd ::= DROP TRIGGER ifexists fullname",
120529 case 265: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
120635 case 293: /* cmd ::= DROP TRIGGER ifexists fullname */
121252 testcase( i==36 ); /* TRIGGER */
121863 ** Special handling is require for CREATE TRIGGER statements.
121864 ** Whenever the CREATE TRIGGER keywords are seen, the statement
121885 ** (5) TRIGGERtrigger definition that must be
121889 ** the end of a trigger definition.
121892 ** of a trigger difinition.
121903 ** (6) tkTRIGGER The "trigger" keyword.
121910 ** to recognize the end of a trigger can be omitted. All we have to do
121918 /* A complex statement machine used to detect the end of a CREATE TRIGGER
121923 /* State: ** SEMI WS OTHER EXPLAIN CREATE TEMP TRIGGER END */
121929 /* 5 TRIGGER: */ { 6, 5, 5, 5, 5, 5, 5, 5, },
122020 if( nId==7 && sqlite3StrNICmp(zSql, "trigger", 7)==0 ){
124606 ** do not block illegal combinations here, it could trigger