1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Add API function sqlite3_preupdate_depth(), for determining the depth of the trigger stack from within a pre-update callback.

FossilOrigin-Name: bdea70895c2c686a4dd3f4bf0a475fd1501d9551
This commit is contained in:
dan
2011-03-22 18:45:29 +00:00
parent 245b49b203
commit 1e7a2d4315
6 changed files with 152 additions and 12 deletions

View File

@@ -1391,6 +1391,22 @@ int sqlite3_preupdate_count(sqlite3 *db){
return (p ? p->pCsr->nField : 0);
}
/*
** This function is designed to be called from within a pre-update callback
** only. It returns zero if the change that caused the callback was made
** immediately by a user SQL statement. Or, if the change was made by a
** trigger program, it returns the number of trigger programs currently
** on the stack (1 for a top-level trigger, 2 for a trigger fired by a
** top-level trigger etc.).
**
** For the purposes of the previous paragraph, a foreign key CASCADE, SET NULL
** or SET DEFAULT action is considered a trigger.
*/
int sqlite3_preupdate_depth(sqlite3 *db){
PreUpdate *p = db->pPreUpdate;
return (p ? p->v->nFrame : 0);
}
/*
** This function is called from within a pre-update callback to retrieve
** a field of the row currently being updated or inserted.