#
LIBOBJ = btree.o build.o delete.o expr.o func.o hash.o insert.o \
main.o os.o pager.o parse.o printf.o random.o select.o table.o \
- tokenize.o update.o util.o vdbe.o where.o tclsqlite.o
+ tokenize.o trigger.o update.o util.o vdbe.o where.o tclsqlite.o
# All of the source code files.
#
$(TOP)/src/table.c \
$(TOP)/src/tclsqlite.c \
$(TOP)/src/tokenize.c \
+ $(TOP)/src/trigger.c \
$(TOP)/src/update.c \
$(TOP)/src/util.c \
$(TOP)/src/vdbe.c \
tokenize.o: $(TOP)/src/tokenize.c $(HDR)
$(TCCX) -c $(TOP)/src/tokenize.c
+trigger.o: $(TOP)/src/trigger.c $(HDR)
+ $(TCCX) -c $(TOP)/src/trigger.c
+
util.o: $(TOP)/src/util.c $(HDR)
$(TCCX) -c $(TOP)/src/util.c
-C Remove\sall\stabs\sfrom\sthe\sbeginning\sof\ssource\scode\slines.\s\sReplace\stabs\swith\nthe\sappropriate\snumber\sof\sspaces.\s(CVS\s565)
-D 2002-05-15T11:44:14
+C Beginning\sto\sclean\sup\sthe\strigger\scode.\s\sStill\slots\sof\swork\sto\sdo.\s(CVS\s566)
+D 2002-05-15T12:45:43
F Makefile.in 6291a33b87d2a395aafd7646ee1ed562c6f2c28c
-F Makefile.template 89e373b2dad0321df00400fa968dc14b61a03296
+F Makefile.template 4e11752e0b5c7a043ca50af4296ec562857ba495
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
F VERSION 45e2ae5cf63867a750b544c539f79a076d53a9a0
F aclocal.m4 11faa843caa38fd451bc6aeb43e248d1723a269d
F src/TODO af7f3cab0228e34149cf98e073aa83d45878e7e6
F src/btree.c c01b404b9373ae1c0daf7d1f9211c72ead67638e
F src/btree.h 8abeabfe6e0b1a990b64fa457592a6482f6674f3
-F src/build.c 74f19f9001ee3708b451faf8fc8a6b36024a9be7
+F src/build.c 705ebd993ac708bb3d04f4b9019d42dc205408cc
F src/delete.c 48e4c533b39d6edfcfca23fb500129b80b7cad30
F src/encode.c 346b12b46148506c32038524b95c4631ab46d760
F src/expr.c 6888e37e4eecdc20567aedd442328df752465723
F src/shell.c 5acbe59e137d60d8efd975c683dbea74ab626530
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
F src/sqlite.h.in 0038faa6d642de06b91143ee65a131bd831d020b
-F src/sqliteInt.h a96603825503c5bbd095f1ac34ce1023f89a908e
+F src/sqliteInt.h 26f8cefb76e9393413ac22468c8dd0ed41abf67c
F src/table.c eed2098c9b577aa17f8abe89313a9c4413f57d63
F src/tclsqlite.c 9300c9606a38bc0c75d6c0bc8a6197ab979353d1
F src/test1.c 09d95048b66ce6dcd2bae90f443589043d7d631e
F src/test3.c 4e52fff8b01f08bd202f7633feda5639b7ba2b5e
F src/threadtest.c 81f0598e0f031c1bd506af337fdc1b7e8dff263f
F src/tokenize.c f12f78c58b2a79ea4eee880efad63a328e103c62
-F src/trigger.c 768b895cf09382db4e2d1ce5aace7e6a4cbf7e4d
+F src/trigger.c 491d5d3b40d737365a1ade7d4039277991208dc3
F src/update.c f9b53d46cc651b9630fc53342b9e792031f6fc5c
F src/util.c 707c30f8c13cddace7c08556ac450c0b786660b3
F src/vdbe.c 42281b4e0e0c4a089018a14d6840ada5a1896e51
F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P d1d8642b57bd0765ade730248012d58b0859c12c
-R 7c8b29631adcec690efa7e7338377d43
+P 690f9a163173c4c7af7e8e92e942cee4184c7974
+R 2c7fa77b8b0294150616cb3ad535e3be
U drh
-Z 13f7f043962d157cad884aca33ba63e6
+Z 2f79a3bdfbaced77f180a80585eae438
-690f9a163173c4c7af7e8e92e942cee4184c7974
\ No newline at end of file
+b10346818b25940c6dc85e94de8e36d20954161c
\ No newline at end of file
** ROLLBACK
** PRAGMA
**
-** $Id: build.c,v 1.89 2002/05/15 11:44:14 drh Exp $
+** $Id: build.c,v 1.90 2002/05/15 12:45:43 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
Table * tab = sqliteFindTable(db, pTrigger->table);
sqliteHashInsert(&db->trigHash, pTrigger->name,
strlen(pTrigger->name) + 1, pTrigger);
-
pTrigger->pNext = tab->pTrigger;
tab->pTrigger = pTrigger;
}
** and the probability of hitting the same cookie value is only
** 1 chance in 2^32. So we're safe enough.
*/
-void changeCookie(sqlite *db){
+void sqliteChangeCookie(sqlite *db){
if( db->next_cookie==db->schema_cookie ){
db->next_cookie = db->schema_cookie + sqliteRandomByte() + 1;
db->flags |= SQLITE_InternChanges;
}
sqliteVdbeAddOp(v, OP_MakeRecord, 5, 0);
sqliteVdbeAddOp(v, OP_PutIntKey, 0, 0);
- changeCookie(db);
+ sqliteChangeCookie(db);
sqliteVdbeAddOp(v, OP_Integer, db->next_cookie, 0);
sqliteVdbeAddOp(v, OP_SetCookie, 0, 0);
sqliteVdbeAddOp(v, OP_Close, 0, 0);
Index *pIdx;
sqliteBeginWriteOperation(pParse);
/* Drop all triggers associated with the table being dropped */
- while (pTable->pTrigger) {
+ while( pTable->pTrigger ){
Token tt;
tt.z = pTable->pTrigger->name;
tt.n = strlen(pTable->pTrigger->name);
if( !pTable->isTemp ){
base = sqliteVdbeAddOpList(v, ArraySize(dropTable), dropTable);
sqliteVdbeChangeP3(v, base+2, pTable->zName, 0);
- changeCookie(db);
+ sqliteChangeCookie(db);
sqliteVdbeChangeP1(v, base+9, db->next_cookie);
}
if( !isView ){
}
if( pTable!=0 ){
if( !isTemp ){
- changeCookie(db);
+ sqliteChangeCookie(db);
sqliteVdbeAddOp(v, OP_Integer, db->next_cookie, 0);
sqliteVdbeAddOp(v, OP_SetCookie, 0, 0);
sqliteVdbeAddOp(v, OP_Close, 0, 0);
if( !pTab->isTemp ){
base = sqliteVdbeAddOpList(v, ArraySize(dropIndex), dropIndex);
sqliteVdbeChangeP3(v, base+2, pIndex->zName, P3_STATIC);
- changeCookie(db);
+ sqliteChangeCookie(db);
sqliteVdbeChangeP1(v, base+10, db->next_cookie);
}
sqliteVdbeAddOp(v, OP_Destroy, pIndex->tnum, pTab->isTemp);
** Generate VDBE code that prepares for doing an operation that
** might change the database. The operation will be atomic in the
** sense that it will either do its changes completely or not at
-** all. So there is not need to set a checkpoint is a transaction
+** all. So there is no need to set a checkpoint is a transaction
** is already in effect.
*/
void sqliteBeginWriteOperation(Parse *pParse){
Vdbe *v;
v = sqliteGetVdbe(pParse);
if( v==0 ) return;
- if (pParse->trigStack) return; /* if this is in a trigger */
+ if( pParse->trigStack ) return; /* if this is in a trigger */
if( (pParse->db->flags & SQLITE_InTrans)==0 ){
sqliteVdbeAddOp(v, OP_Transaction, 0, 0);
sqliteVdbeAddOp(v, OP_VerifyCookie, pParse->db->schema_cookie, 0);
Vdbe *v;
v = sqliteGetVdbe(pParse);
if( v==0 ) return;
- if (pParse->trigStack) return; /* if this is in a trigger */
+ if( pParse->trigStack ) return; /* if this is in a trigger */
if( (pParse->db->flags & SQLITE_InTrans)==0 ){
sqliteVdbeAddOp(v, OP_Transaction, 0, 0);
sqliteVdbeAddOp(v, OP_VerifyCookie, pParse->db->schema_cookie, 0);
*************************************************************************
** Internal interface definitions for SQLite.
**
-** @(#) $Id: sqliteInt.h,v 1.108 2002/05/15 08:30:14 danielk1977 Exp $
+** @(#) $Id: sqliteInt.h,v 1.109 2002/05/15 12:45:43 drh Exp $
*/
#include "sqlite.h"
#include "hash.h"
** while generating expressions. Normally false */
int schemaVerified; /* True if an OP_VerifySchema has been coded someplace
** other than after an OP_Transaction */
-
- TriggerStack * trigStack;
+ TriggerStack *trigStack;
};
struct TriggerStack {
- Trigger * pTrigger;
- Table * pTab; /* Table that triggers are currently being coded as */
- int newIdx; /* Index of "new" temp table */
- int oldIdx; /* Index of "old" temp table */
- int orconf; /* Current orconf policy */
- struct TriggerStack * pNext;
+ Trigger *pTrigger;
+ Table *pTab; /* Table that triggers are currently being coded as */
+ int newIdx; /* Index of "new" temp table */
+ int oldIdx; /* Index of "old" temp table */
+ int orconf; /* Current orconf policy */
+ TriggerStack *pNext;
};
struct TriggerStep {
int op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */
int orconf;
- Select * pSelect; /* Valid for SELECT and sometimes
+ Select *pSelect; /* Valid for SELECT and sometimes
INSERT steps (when pExprList == 0) */
Token target; /* Valid for DELETE, UPDATE, INSERT steps */
- Expr * pWhere; /* Valid for DELETE, UPDATE steps */
- ExprList * pExprList; /* Valid for UPDATE statements and sometimes
+ Expr *pWhere; /* Valid for DELETE, UPDATE steps */
+ ExprList *pExprList; /* Valid for UPDATE statements and sometimes
INSERT steps (when pSelect == 0) */
IdList *pIdList; /* Valid for INSERT statements only */
TriggerStep * pNext; /* Next in the link-list */
};
struct Trigger {
- char * name; /* The name of the trigger */
- char * table; /* The table or view to which the trigger applies */
- int op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT */
- int tr_tm; /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */
- Expr * pWhen; /* The WHEN clause of the expresion (may be NULL) */
- IdList * pColumns; /* If this is an UPDATE OF <column-list> trigger,
- the column names are stored in this list */
- int foreach; /* One of TK_ROW or TK_STATEMENT */
-
- TriggerStep * step_list; /* Link list of trigger program steps */
-
- char * strings; /* pointer to the allocation of Token strings */
- Trigger * pNext; /* Next trigger associated with the table */
+ char *name; /* The name of the trigger */
+ char *table; /* The table or view to which the trigger applies */
+ int op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT */
+ int tr_tm; /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */
+ Expr *pWhen; /* The WHEN clause of the expresion (may be NULL) */
+ IdList *pColumns; /* If this is an UPDATE OF <column-list> trigger,
+ the column names are stored in this list */
+ int foreach; /* One of TK_ROW or TK_STATEMENT */
+
+ TriggerStep *step_list; /* Link list of trigger program steps */
+ char *strings; /* pointer to allocation of Token strings */
+ Trigger *pNext; /* Next trigger associated with the table */
int isCommit;
};
-TriggerStep * sqliteTriggerSelectStep(Select *);
-TriggerStep * sqliteTriggerInsertStep(Token *, IdList *, ExprList *,
- Select *, int);
-TriggerStep * sqliteTriggerUpdateStep(Token *, ExprList *, Expr *, int);
-TriggerStep * sqliteTriggerDeleteStep(Token *, Expr *);
-
extern int always_code_trigger_setup;
-void sqliteCreateTrigger(Parse * ,Token *, int, int, IdList *, Token *, int, Expr *, TriggerStep *, char const *,int);
-void sqliteDropTrigger(Parse *, Token *, int);
-int sqliteTriggersExist( Parse * , Trigger * , int , int , int, ExprList * );
-int sqliteCodeRowTrigger( Parse * pParse, int op, ExprList *, int tr_tm, Table * tbl, int newTable, int oldTable, int onError);
-
-void sqliteViewTriggers(Parse *, Table *, Expr *, int, ExprList *);
/*
** Internal function prototypes
int sqliteSafetyOn(sqlite*);
int sqliteSafetyOff(sqlite*);
int sqliteSafetyCheck(sqlite*);
-
-void changeCookie(sqlite *);
+void sqliteChangeCookie(sqlite *);
+void sqliteCreateTrigger(Parse*, Token*, int, int, IdList*, Token*,
+ int, Expr*, TriggerStep*, char const*,int);
+void sqliteDropTrigger(Parse*, Token*, int);
+int sqliteTriggersExist(Parse* , Trigger* , int , int , int, ExprList*);
+int sqliteCodeRowTrigger(Parse*, int, ExprList*, int, Table *, int, int, int);
+void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);
+TriggerStep *sqliteTriggerSelectStep(Select*);
+TriggerStep *sqliteTriggerInsertStep(Token*, IdList*, ExprList*, Select*, int);
+TriggerStep *sqliteTriggerUpdateStep(Token*, ExprList*, Expr*, int);
+TriggerStep *sqliteTriggerDeleteStep(Token*, Expr*);
sqliteVdbeAddOp(pParse->pVdbe, OP_PutIntKey, 0, 1);
/* Change the cookie, since the schema is changed */
- changeCookie(pParse->db);
+ sqliteChangeCookie(pParse->db);
sqliteVdbeAddOp(pParse->pVdbe, OP_Integer, pParse->db->next_cookie, 0);
sqliteVdbeAddOp(pParse->pVdbe, OP_SetCookie, 0, 0);
{ OP_Close, 0, 0, 0},
};
- if (!nested)
+ if( !nested ){
sqliteBeginWriteOperation(pParse);
-
+ }
base = sqliteVdbeAddOpList(pParse->pVdbe,
ArraySize(dropTrigger), dropTrigger);
sqliteVdbeChangeP3(pParse->pVdbe, base+2, tmp_name, 0);
-
- if (!nested)
- changeCookie(pParse->db);
-
+ if( !nested ){
+ sqliteChangeCookie(pParse->db);
+ }
sqliteVdbeChangeP1(pParse->pVdbe, base+9, pParse->db->next_cookie);
-
- if (!nested)
+ if( !nested ){
sqliteEndWriteOperation(pParse);
+ }
}
sqliteFree(tmp_name);