0
0
mirror of https://github.com/sqlite/sqlite.git synced 2024-11-24 16:18:08 +01:00

Add the SQLITE_ENABLE_PREUPDATE_HOOK compile-time option.

FossilOrigin-Name: 6634521461e6acff7cc778590e62d57831f9230d
This commit is contained in:
drh 2011-03-30 21:04:43 +00:00
parent 67c495ac20
commit 9b1c62d416
20 changed files with 95 additions and 39 deletions

View File

@ -16,6 +16,7 @@ if {![info exists testdir]} {
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix session1
@ -444,4 +445,3 @@ do_db2_test 6.3 "SELECT * FROM t2" {a b A B}
catch { db2 close }
finish_test

View File

@ -17,6 +17,7 @@ if {![info exists testdir]} {
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix session2

View File

@ -18,6 +18,7 @@ if {![info exists testdir]} {
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix session3
@ -177,4 +178,3 @@ test_sqlite3_log
sqlite3_initialize
finish_test

View File

@ -16,6 +16,7 @@ if {![info exists testdir]} {
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix session4

View File

@ -1,5 +1,5 @@
#ifdef SQLITE_ENABLE_SESSION
#if defined(SQLITE_ENABLE_SESSION) && defined(SQLITE_ENABLE_PREUPDATE_HOOK)
#include "sqlite3session.h"
#include <assert.h>
@ -2533,4 +2533,4 @@ int sqlite3changeset_apply(
return rc;
}
#endif /* #ifdef SQLITE_ENABLE_SESSION */
#endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */

View File

@ -1,5 +1,6 @@
#if defined(SQLITE_TEST) && defined(SQLITE_ENABLE_SESSION)
#if defined(SQLITE_TEST) && defined(SQLITE_ENABLE_SESSION) \
&& defined(SQLITE_ENABLE_PREUPDATE_HOOK)
#include "sqlite3session.h"
#include <assert.h>
@ -519,5 +520,4 @@ int TestSession_Init(Tcl_Interp *interp){
return TCL_OK;
}
#endif
#endif /* SQLITE_TEST && SQLITE_SESSION && SQLITE_PREUPDATE_HOOK */

View File

@ -1,5 +1,5 @@
C Disable\sthe\struncate\soptimization\sif\sthere\sis\sa\spreupdate\shook.
D 2011-03-30T17:25:35.303
C Add\sthe\sSQLITE_ENABLE_PREUPDATE_HOOK\scompile-time\soption.
D 2011-03-30T21:04:43.055
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -99,15 +99,15 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea
F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0
F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de
F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024
F ext/session/session1.test b2da15b9d727d7f4e5fe95599b32b92d93b5a970
F ext/session/session2.test e36222e1f48bc9b1d80eacd001994d307c107e73
F ext/session/session3.test 919f7e2e07fa5a166a0ea5d8ac3fbe7f38f7e447
F ext/session/session4.test a37bc9d8891ea1f3e120056c978f66c925f040b9
F ext/session/session1.test 7a92a2a6f531aef1e9764ffb7f983fb8b315376d
F ext/session/session2.test c3e5f78d5eb988e35cc2ba9ce3678f706283cfdb
F ext/session/session3.test bfa2376db7cbb2ac69496f84d93a8d81b13110d3
F ext/session/session4.test a6ed685da7a5293c5d6f99855bcf41dbc352ca84
F ext/session/session_common.tcl fb91560b6dbd086010df8b3a137a452f1ac21a28
F ext/session/sessionfault.test 2544a2e2ecad56e3c07a32c09799871d243c114c
F ext/session/sqlite3session.c 9be8ccee4248681700659b89a81ae5c6cb8afacc
F ext/session/sqlite3session.c eaf093c81f076301cfd04f794d047cf7beffd290
F ext/session/sqlite3session.h f284bac51c12de0e0096fc986e61f5ae6b9e5be5
F ext/session/test_session.c f8fdf5c110898b2bbc20c475fca879664c77fb5a
F ext/session/test_session.c 82e3fd7d94f485ea63bcfb15d636c95a01db97a9
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F main.mk e283752f215b7055cdc48399da82033b67024e42
@ -138,7 +138,7 @@ F src/callback.c 5069f224882cbdccd559f591271d28d7f37745bc
F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac
F src/ctime.c 52ff72f966cee3087e0138a3ec69371c22be3c01
F src/date.c 1548fdac51377e4e7833251de878b4058c148e1b
F src/delete.c 4aebb9ccea435701c137bf25e07fe93ad8e9346d
F src/delete.c 44800af91a90f9d9445a266129313f27487614d8
F src/expr.c 00817c672af554321fd67c44325afd7cef0e4648
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
F src/fkey.c 418b840007c873975fd0d071746d952f8bca20ce
@ -147,12 +147,12 @@ F src/global.c 02335177cf6946fe5525c6f0755cf181140debf3
F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af
F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970
F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08
F src/insert.c c46747b4bdde2ae4c2815526a151fefb66ba64a6
F src/insert.c e354eadb2ca3e8d939ba928f229e2268974f380c
F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
F src/loadext.c 8af9fcc75708d60b88636ccba38b4a7b3c155c3e
F src/main.c 2563bd9ca8430c7677d375c566b54b890aaf508f
F src/main.c bed41512fabb19492b61d37fd988d79f6225e624
F src/malloc.c 92d59a007d7a42857d4e9454aa25b6b703286be1
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206
@ -187,13 +187,13 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
F src/select.c d24406c45dd2442eb2eeaac413439066b149c944
F src/shell.c 9dc0b4bb59290c0a35256d278cab0f314987ad6a
F src/sqlite.h.in 3fef17a4201b068291da874b42599b9e61c0cf68
F src/sqlite.h.in 235300cdca517ce148385d3ab816e7e8cf9e1ff3
F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754
F src/sqliteInt.h 7c11f9a648cf82e87330fd2185fcaa1f7c46dfba
F src/sqliteInt.h 14325fe41ee564f064adacda02ab64837fa905c4
F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44
F src/status.c 4997380fbb915426fef9e500b4872e79c99267fc
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
F src/tclsqlite.c c233c25153b6fa3b511bc65df352cb8f97a0f81d
F src/tclsqlite.c 8376ae45f7e28d521ad708a0086771fab3c96475
F src/test1.c 9020310c7617234b33fd1c3064f89524db25f290
F src/test2.c 80d323d11e909cf0eb1b6fbb4ac22276483bcf31
F src/test3.c 056093cfef69ff4227a6bdb9108564dc7f45e4bc
@ -207,7 +207,7 @@ F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad
F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e
F src/test_backup.c c129c91127e9b46e335715ae2e75756e25ba27de
F src/test_btree.c 47cd771250f09cdc6e12dda5bc71bc0b3abc96e2
F src/test_config.c e9a4ce02dec5bcced1c13e0cf8b72edfd5903d74
F src/test_config.c 3050df9faf023fb52937f7e9998004c2415d4122
F src/test_demovfs.c 0aed671636735116fc872c5b03706fd5612488b5
F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc
F src/test_func.c cbdec5cededa0761daedde5baf06004a9bf416b5
@ -237,15 +237,15 @@ F src/test_vfstrace.c 2265c9895f350c8d3c39b079998fbe7481505cc1
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
F src/tokenize.c 604607d6813e9551cf5189d899e0a25c12681080
F src/trigger.c ec4813709e990a169b6923293e839fa5dfd64282
F src/update.c f81e9b326cafba3fbe493141e396f3bbfba1d99b
F src/update.c 3f3f3bb734a0da1dffd0ed33e504642b35ed3605
F src/utf.c d83650c3ea08f7407bd9d0839d9885241c209c60
F src/util.c cd997077bad039efc0597eb027c929658f93c018
F src/vacuum.c 924bd1bcee2dfb05376f79845bd3b4cec7b54b2f
F src/vdbe.c 175a42d0f12b92093a7335402dbb46bfe7e360b0
F src/vdbe.c 4784ded3d2c97f8084a17cacbeea490a0dccf75e
F src/vdbe.h edef9c4f0be83e1f1dccd049da37b40e021b63d9
F src/vdbeInt.h b6748a8ac9be169d83585a0f5daf747863c6b8db
F src/vdbeapi.c e472b3e5985175e948e70025cb3bffa8a2e185c8
F src/vdbeaux.c 051a1609e578418d1bfc6d2420b8eb412a7aea97
F src/vdbeapi.c 7ef519083e3420bf7793d8b4eae2961d894d98ab
F src/vdbeaux.c b526e30d7a5d5b8b18408b2ec077e7286df2f6dc
F src/vdbeblob.c c3ccb7c8732858c680f442932e66ad06bb036562
F src/vdbemem.c 0498796b6ffbe45e32960d6a1f5adfb6e419883b
F src/vdbetrace.c 3ba13bc32bdf16d2bdea523245fd16736bed67b5
@ -485,7 +485,7 @@ F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167
F test/fuzz3.test aec64345184d1662bd30e6a17851ff659d596dc5
F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b
F test/fuzz_malloc.test dd7001ac86d09c154a7dff064f4739c60e2b312c
F test/hook.test 29a0b6a18111835bdca827f62a7975a8e30a1dd5
F test/hook.test 040cf2ca263f192c66b358e095138dad0a9d75bb
F test/icu.test 70df4faca133254c042d02ae342c0a141f2663f4
F test/in.test 19b642bb134308980a92249750ea4ce3f6c75c2d
F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75
@ -929,7 +929,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 8180f2881fa970429e28d4f3258a56cfaabbcabd
R 7bdc0a7971e68baabbe152ea44f74530
P d051694e024c590e4687cae1368f900799b7442d
R c057f780dc1cba178107219ab6b28dc8
U drh
Z a923e72061e5acce879b548f79bb9c49
Z 598e11d1b0eff48f657d073c9eb1f2dc

View File

@ -1 +1 @@
d051694e024c590e4687cae1368f900799b7442d
6634521461e6acff7cc778590e62d57831f9230d

View File

@ -344,7 +344,9 @@ void sqlite3DeleteFrom(
&& pWhere==0
&& !pTrigger
&& !IsVirtual(pTab)
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
&& db->xPreUpdateCallback==0
#endif
&& 0==sqlite3FkRequired(pParse, pTab, 0, 0)
){
assert( !isView );

View File

@ -1286,12 +1286,14 @@ void sqlite3GenerateConstraintChecks(
pParse, pTab, baseCur, regRowid, 0, pTrigger, OE_Replace
);
}else{
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/* This OP_Delete opcode fires the pre-update-hook only. It does
** not modify the b-tree. It is more efficient to let the coming
** OP_Insert replace the existing entry than it is to delete the
** existing entry and then insert a new one. */
sqlite3VdbeAddOp2(v, OP_Delete, baseCur, OPFLAG_ISNOOP);
sqlite3VdbeChangeP4(v, -1, (char *)pTab, P4_TABLE);
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
if( pTab->pIndex ){
sqlite3MultiWrite(pParse);
sqlite3GenerateRowIndexDelete(pParse, pTab, baseCur, 0);

View File

@ -1306,6 +1306,7 @@ void *sqlite3_rollback_hook(
return pRet;
}
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/*
** Register a callback to be invoked each time a row is updated,
** inserted or deleted using this database connection.
@ -1324,6 +1325,7 @@ void *sqlite3_preupdate_hook(
sqlite3_mutex_leave(db->mutex);
return pRet;
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
#ifndef SQLITE_OMIT_WAL
/*

View File

@ -6392,6 +6392,9 @@ int sqlite3_wal_checkpoint_v2(
** CAPI3REF: The pre-update hook.
** EXPERIMENTAL
**
** ^These interfaces are only available if SQLite is compiled using the
** [SQLITE_ENABLE_UPDATE_HOOK] compile-time option.
**
** ^The [sqlite3_preupdate_hook()] interface registers a callback function
** that is invoked prior to each [INSERT], [UPDATE], and [DELETE] operation.
** ^At most one preupdate hook may be registered at a time on a single

View File

@ -829,11 +829,13 @@ struct sqlite3 {
void (*xRollbackCallback)(void*); /* Invoked at every commit. */
void *pUpdateArg;
void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64);
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
void *pPreUpdateArg; /* First argument to xPreUpdateCallback */
void (*xPreUpdateCallback)( /* Registered using sqlite3_preupdate_hook() */
void*,sqlite3*,int,char const*,char const*,sqlite3_int64,sqlite3_int64
);
PreUpdate *pPreUpdate; /* Context for active pre-update callback */
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
#ifndef SQLITE_OMIT_WAL
int (*xWalCallback)(void *, sqlite3 *, const char *, int);
void *pWalArg;

View File

@ -653,6 +653,7 @@ static void DbUnlockNotify(void **apArg, int nArg){
}
#endif
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/*
** Pre-update hook callback.
*/
@ -686,6 +687,7 @@ static void DbPreUpdateHandler(
Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT);
Tcl_DecrRefCount(pCmd);
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
static void DbUpdateHandler(
void *p,
@ -1624,7 +1626,9 @@ static void DbHookCmd(
}
}
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
sqlite3_preupdate_hook(db, (pDb->pPreUpdateHook?DbPreUpdateHandler:0), pDb);
#endif
sqlite3_update_hook(db, (pDb->pUpdateHook?DbUpdateHandler:0), pDb);
sqlite3_rollback_hook(db, (pDb->pRollbackHook?DbRollbackHandler:0), pDb);
sqlite3_wal_hook(db, (pDb->pWalHook?DbWalHandler:0), pDb);
@ -2851,6 +2855,10 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
** $db preupdate_hook old INDEX
*/
case DB_PREUPDATE: {
#ifndef SQLITE_ENABLE_PREUPDATE_HOOK
Tcl_AppendResult(interp, "preupdate_hook was omitted at compile-time");
rc = TCL_ERROR;
#else
static const char *azSub[] = {"count", "depth", "hook", "new", "old", 0};
enum DbPreupdateSubCmd {
PRE_COUNT, PRE_DEPTH, PRE_HOOK, PRE_NEW, PRE_OLD
@ -2920,7 +2928,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
}
}
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
break;
}
@ -3720,7 +3728,7 @@ static void init_all(Tcl_Interp *interp){
extern int Sqlitemultiplex_Init(Tcl_Interp*);
extern int SqliteSuperlock_Init(Tcl_Interp*);
extern int SqlitetestSyscall_Init(Tcl_Interp*);
#ifdef SQLITE_ENABLE_SESSION
#if defined(SQLITE_ENABLE_SESSION) && defined(SQLITE_ENABLE_PREUPDATE_HOOK)
extern int TestSession_Init(Tcl_Interp*);
#endif
#ifdef SQLITE_ENABLE_ZIPVFS
@ -3760,7 +3768,7 @@ static void init_all(Tcl_Interp *interp){
Sqlitemultiplex_Init(interp);
SqliteSuperlock_Init(interp);
SqlitetestSyscall_Init(interp);
#ifdef SQLITE_ENABLE_SESSION
#if defined(SQLITE_ENABLE_SESSION) && defined(SQLITE_ENABLE_PREUPDATE_HOOK)
TestSession_Init(interp);
#endif

View File

@ -85,6 +85,12 @@ static void set_options(Tcl_Interp *interp){
Tcl_SetVar2(interp, "sqlite_options", "mem5", "0", TCL_GLOBAL_ONLY);
#endif
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
Tcl_SetVar2(interp, "sqlite_options", "preupdate", "1", TCL_GLOBAL_ONLY);
#else
Tcl_SetVar2(interp, "sqlite_options", "preupdate", "0", TCL_GLOBAL_ONLY);
#endif
#ifdef SQLITE_MUTEX_OMIT
Tcl_SetVar2(interp, "sqlite_options", "mutex", "0", TCL_GLOBAL_ONLY);
#else

View File

@ -487,13 +487,13 @@ void sqlite3Update(
/* Delete the index entries associated with the current record. */
j1 = sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regOldRowid);
sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, aRegIdx);
/* If changing the rowid value, or if there are foreign key constraints
** to process, delete the old record. Otherwise, add a noop OP_Delete
** to invoke the pre-update hook.
**
** That (regNew==regnewRowid+1) is true is also important for the
** pre-update hook. If hte caller invokes preupdate_new(), the returned
** pre-update hook. If the caller invokes preupdate_new(), the returned
** value is copied from memory cell (regNewRowid+1+iCol), where iCol
** is the column index supplied by the user.
*/

View File

@ -107,6 +107,16 @@ static void updateMaxBlobsize(Mem *p){
}
#endif
/*
** This macro evaluates to true if either the update hook or the preupdate
** hook are enabled for database connect DB.
*/
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
# define HAS_UPDATE_HOOK(DB) ((DB)->xPreUpdateCallback||(DB)->xUpdateCallback)
#else
# define HAS_UPDATE_HOOK(DB) ((DB)->xUpdateCallback)
#endif
/*
** The next global variable is incremented each type the OP_Found opcode
** is executed. This is used to test whether or not the foreign key
@ -3890,7 +3900,7 @@ case OP_InsertInt: {
iKey = pOp->p3;
}
if( pOp->p4type==P4_TABLE && (db->xPreUpdateCallback||db->xUpdateCallback) ){
if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){
assert( pC->isTable );
assert( pC->iDb>=0 );
zDb = db->aDb[pC->iDb].zName;
@ -3898,6 +3908,7 @@ case OP_InsertInt: {
op = ((pOp->p5 & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_INSERT);
}
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/* Invoke the pre-update hook, if any */
if( db->xPreUpdateCallback
&& pOp->p4type==P4_TABLE
@ -3905,6 +3916,7 @@ case OP_InsertInt: {
){
sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, iKey, pOp->p2);
}
#endif
if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;
if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = iKey;
@ -3991,7 +4003,7 @@ case OP_Delete: {
/* If the update-hook or pre-update-hook will be invoked, set iKey to
** the rowid of the row being deleted. Set zDb and zTab as well.
*/
if( pOp->p4.z && (db->xPreUpdateCallback || db->xUpdateCallback) ){
if( pOp->p4.z && HAS_UPDATE_HOOK(db) ){
assert( pC->iDb>=0 );
assert( pC->isTable );
assert( pC->rowidIsValid ); /* lastRowid set by previous OP_NotFound */
@ -4000,6 +4012,7 @@ case OP_Delete: {
pTab = pOp->p4.pTab;
}
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/* Invoke the pre-update-hook if required. */
if( db->xPreUpdateCallback && pOp->p4.z ){
assert( !(opflags & OPFLAG_ISUPDATE) || (aMem[pOp->p3].flags & MEM_Int) );
@ -4009,6 +4022,7 @@ case OP_Delete: {
pOp->p3
);
}
#endif
if( opflags & OPFLAG_ISNOOP ) break;

View File

@ -1327,6 +1327,7 @@ int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
return v;
}
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/*
** This function is called from within a pre-update callback to retrieve
** a field of the row currently being updated or deleted.
@ -1381,7 +1382,9 @@ int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){
sqlite3Error(db, rc, 0);
return sqlite3ApiExit(db, rc);
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/*
** This function is called from within a pre-update callback to retrieve
** the number of columns in the row being updated, deleted or inserted.
@ -1390,7 +1393,9 @@ int sqlite3_preupdate_count(sqlite3 *db){
PreUpdate *p = db->pPreUpdate;
return (p ? p->pCsr->nField : 0);
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/*
** 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
@ -1406,7 +1411,9 @@ int sqlite3_preupdate_depth(sqlite3 *db){
PreUpdate *p = db->pPreUpdate;
return (p ? p->v->nFrame : 0);
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/*
** This function is called from within a pre-update callback to retrieve
** a field of the row currently being updated or inserted.
@ -1481,3 +1488,4 @@ int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){
sqlite3Error(db, rc, 0);
return sqlite3ApiExit(db, rc);
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */

View File

@ -2812,7 +2812,7 @@ UnpackedRecord *sqlite3VdbeRecordUnpack(
pMem->enc = pKeyInfo->enc;
pMem->db = pKeyInfo->db;
pMem->flags = 0;
pMem->zMalloc = pMem->z = 0;
pMem->zMalloc = 0;
pMem->z = 0;
d += sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);
pMem++;
@ -3171,6 +3171,7 @@ void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){
}
}
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
/*
** Invoke the pre-update hook. If this is an UPDATE or DELETE pre-update call,
** then cursor passed as the second argument should point to the row about
@ -3228,3 +3229,4 @@ void sqlite3VdbePreUpdateHook(
sqlite3DbFree(db, preupdate.aNew);
}
}
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */

View File

@ -365,6 +365,11 @@ unset ::hooks
#----------------------------------------------------------------------------
# The following tests - hook-7.* - test the pre-update hook.
#
ifcapable !preupdate {
finish_test
return
}
#
# 7.1.1 - INSERT statement.
# 7.1.2 - INSERT INTO ... SELECT statement.
# 7.1.3 - REPLACE INTO ... (rowid conflict)