diff options
Diffstat (limited to 'src/sqliteInt.h')
-rw-r--r-- | src/sqliteInt.h | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 4fb8953d7..2bdbdb021 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.214 2004/02/20 14:50:58 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.215 2004/02/20 22:53:39 rdc Exp $ */ #include "config.h" #include "sqlite.h" @@ -309,6 +309,24 @@ struct Db { ** are stored. If 1, then a file is created to hold those tables. If ** 2, then they are held in memory. 0 means use the default value in ** the TEMP_STORE macro. +** +** The sqlite.lastRowid records the last insert rowid generated by an +** insert statement. Inserts on views do not affect its value. Each +** trigger has its own context, so that lastRowid can be updated inside +** triggers as usual. The previous value will be restored once the trigger +** exits. Upon entering a before or instead of trigger, lastRowid is no +** longer (since after version 2.8.12) reset to -1. +** +** The sqlite.nChange does not count changes within triggers and keeps no +** context. It is reset at start of sqlite_exec. +** The sqlite.lsChange represents the number of changes made by the last +** insert, update, or delete statement. It remains constant throughout the +** length of a statement and is then updated by OP_SetCounts. It keeps a +** context stack just like lastRowid so that the count of changes +** within a trigger is not seen outside the trigger. Changes to views do not +** affect the value of lsChange. +** The sqlite.csChange keeps track of the number of current changes (since +** the last statement) and is used to update sqlite_lsChange. */ struct sqlite { int nDb; /* Number of backends currently in use */ @@ -328,10 +346,12 @@ struct sqlite { void *pCommitArg; /* Argument to xCommitCallback() */ int (*xCommitCallback)(void*);/* Invoked at every commit. */ Hash aFunc; /* All functions that can be in SQL exprs */ - int lastRowid; /* ROWID of most recent insert */ + int lastRowid; /* ROWID of most recent insert (see above) */ int priorNewRowid; /* Last randomly generated ROWID */ int magic; /* Magic number for detect library misuse */ - int nChange; /* Number of rows changed */ + int nChange; /* Number of rows changed (see above) */ + int lsChange; /* Last statement change count (see above) */ + int csChange; /* Current statement change count (see above) */ struct sqliteInitInfo { /* Information used during initialization */ int iDb; /* When back is being initialized */ int newTnum; /* Rootpage of table being initialized */ @@ -908,6 +928,13 @@ struct AuthContext { }; /* +** Bitfield flags for P2 value in OP_PutIntKey and OP_Delete +*/ +#define OPFLAG_NCHANGE 1 /* Set to update db->nChange */ +#define OPFLAG_LASTROWID 2 /* Set to update db->lastRowid */ +#define OPFLAG_CSCHANGE 4 /* Set to update db->csChange */ + +/* * Each trigger present in the database schema is stored as an instance of * struct Trigger. * |