mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Remove the sqlite3_transaction_hook() API.
FossilOrigin-Name: b0015a1cfe63c924ee5f250aa08460522882009b
This commit is contained in:
28
manifest
28
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Fix\ssome\sbugs\sand\sother\scode\sissues\sin\sthe\ssession\smodule.
|
C Remove\sthe\ssqlite3_transaction_hook()\sAPI.
|
||||||
D 2011-03-15T16:37:28
|
D 2011-03-16T09:49:15
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f
|
F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -145,7 +145,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e
|
|||||||
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
|
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
|
||||||
F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
|
F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
|
||||||
F src/loadext.c 8af9fcc75708d60b88636ccba38b4a7b3c155c3e
|
F src/loadext.c 8af9fcc75708d60b88636ccba38b4a7b3c155c3e
|
||||||
F src/main.c 1a5cafdc1bee11f4322c837487bf6fa8e54b2f50
|
F src/main.c 9ab948225b8c362cdd6902c447abbf218607e0f3
|
||||||
F src/malloc.c 92d59a007d7a42857d4e9454aa25b6b703286be1
|
F src/malloc.c 92d59a007d7a42857d4e9454aa25b6b703286be1
|
||||||
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
||||||
F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206
|
F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206
|
||||||
@@ -180,13 +180,13 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706
|
|||||||
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
|
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
|
||||||
F src/select.c d24406c45dd2442eb2eeaac413439066b149c944
|
F src/select.c d24406c45dd2442eb2eeaac413439066b149c944
|
||||||
F src/shell.c 649c51979812f77f97507024a4cea480c6862b8b
|
F src/shell.c 649c51979812f77f97507024a4cea480c6862b8b
|
||||||
F src/sqlite.h.in 992688609e9a0274b56c156d4800be96364b3590
|
F src/sqlite.h.in 8da2897e3c9b251b29aa48d11bfb1f30f1de0733
|
||||||
F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754
|
F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754
|
||||||
F src/sqliteInt.h 85e635183013e806069320ffa6080a77183f9225
|
F src/sqliteInt.h db209477de559911d7f14c1d208cbf2bc46e9224
|
||||||
F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44
|
F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44
|
||||||
F src/status.c 4997380fbb915426fef9e500b4872e79c99267fc
|
F src/status.c 4997380fbb915426fef9e500b4872e79c99267fc
|
||||||
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
|
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
|
||||||
F src/tclsqlite.c b124fb73120d1bc4b78ae8153bce71dbd2d93db5
|
F src/tclsqlite.c 0aa7e768b3bd72bf4c4b0312c9a84d6cdedb7638
|
||||||
F src/test1.c 9020310c7617234b33fd1c3064f89524db25f290
|
F src/test1.c 9020310c7617234b33fd1c3064f89524db25f290
|
||||||
F src/test2.c 80d323d11e909cf0eb1b6fbb4ac22276483bcf31
|
F src/test2.c 80d323d11e909cf0eb1b6fbb4ac22276483bcf31
|
||||||
F src/test3.c 056093cfef69ff4227a6bdb9108564dc7f45e4bc
|
F src/test3.c 056093cfef69ff4227a6bdb9108564dc7f45e4bc
|
||||||
@@ -232,11 +232,11 @@ F src/update.c 1b9a82ede7df15e76ed86c6a3cbe4ce0f21eaa9b
|
|||||||
F src/utf.c 1baeeac91707a4df97ccc6141ec0f808278af685
|
F src/utf.c 1baeeac91707a4df97ccc6141ec0f808278af685
|
||||||
F src/util.c ab1c92426494f499f42b9e307537b03e923d75c1
|
F src/util.c ab1c92426494f499f42b9e307537b03e923d75c1
|
||||||
F src/vacuum.c 924bd1bcee2dfb05376f79845bd3b4cec7b54b2f
|
F src/vacuum.c 924bd1bcee2dfb05376f79845bd3b4cec7b54b2f
|
||||||
F src/vdbe.c 2c523bc17f915329f3db3745fc76ed9bfc5c26bb
|
F src/vdbe.c 117644088f89c40b01c917d06f7b2ed706ca125f
|
||||||
F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2
|
F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2
|
||||||
F src/vdbeInt.h 9dd04435bd5a68e30cd07e7a91c17b062bf1c23d
|
F src/vdbeInt.h 9dd04435bd5a68e30cd07e7a91c17b062bf1c23d
|
||||||
F src/vdbeapi.c 750dcdea999762adbac6eddde5bd790803911edf
|
F src/vdbeapi.c 256029b0a2ed2373ebbcce7a497b3a702a52689b
|
||||||
F src/vdbeaux.c 9ba08ed7de89e923ba6b95a5a75a460e6507a81f
|
F src/vdbeaux.c f789da7d55231d779c26deaf5a1e6ccb3e550c09
|
||||||
F src/vdbeblob.c 18955f0ee6b133cd08e1592010cb9a6b11e9984c
|
F src/vdbeblob.c 18955f0ee6b133cd08e1592010cb9a6b11e9984c
|
||||||
F src/vdbemem.c 0fa2ed786cd207d5b988afef3562a8e663a75b50
|
F src/vdbemem.c 0fa2ed786cd207d5b988afef3562a8e663a75b50
|
||||||
F src/vdbetrace.c 3ba13bc32bdf16d2bdea523245fd16736bed67b5
|
F src/vdbetrace.c 3ba13bc32bdf16d2bdea523245fd16736bed67b5
|
||||||
@@ -474,7 +474,7 @@ F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167
|
|||||||
F test/fuzz3.test aec64345184d1662bd30e6a17851ff659d596dc5
|
F test/fuzz3.test aec64345184d1662bd30e6a17851ff659d596dc5
|
||||||
F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b
|
F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b
|
||||||
F test/fuzz_malloc.test dd7001ac86d09c154a7dff064f4739c60e2b312c
|
F test/fuzz_malloc.test dd7001ac86d09c154a7dff064f4739c60e2b312c
|
||||||
F test/hook.test a90748e44c7ca53da46f857616fc7ce18bf7be13
|
F test/hook.test 85059721ef537317af679aca5435f94ab316d074
|
||||||
F test/icu.test 70df4faca133254c042d02ae342c0a141f2663f4
|
F test/icu.test 70df4faca133254c042d02ae342c0a141f2663f4
|
||||||
F test/in.test 19b642bb134308980a92249750ea4ce3f6c75c2d
|
F test/in.test 19b642bb134308980a92249750ea4ce3f6c75c2d
|
||||||
F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75
|
F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75
|
||||||
@@ -671,7 +671,7 @@ F test/superlock.test 5d7a4954b0059c903f82c7b67867bc5451a7c082
|
|||||||
F test/sync.test ded6b39d8d8ca3c0c5518516c6371b3316d3e3a3
|
F test/sync.test ded6b39d8d8ca3c0c5518516c6371b3316d3e3a3
|
||||||
F test/table.test 04ba066432430657712d167ebf28080fe878d305
|
F test/table.test 04ba066432430657712d167ebf28080fe878d305
|
||||||
F test/tableapi.test 7262a8cbaa9965d429f1cbd2747edc185fa56516
|
F test/tableapi.test 7262a8cbaa9965d429f1cbd2747edc185fa56516
|
||||||
F test/tclsqlite.test 550f2268281d186b767b3ee14dd0be5f9e3ff25d
|
F test/tclsqlite.test 1ce9b6340d6d412420634e129a2e3722c651056a
|
||||||
F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c
|
F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c
|
||||||
F test/temptable.test f42121a0d29a62f00f93274464164177ab1cc24a
|
F test/temptable.test f42121a0d29a62f00f93274464164177ab1cc24a
|
||||||
F test/temptrigger.test b0273db072ce5f37cf19140ceb1f0d524bbe9f05
|
F test/temptrigger.test b0273db072ce5f37cf19140ceb1f0d524bbe9f05
|
||||||
@@ -913,7 +913,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
|||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||||
P cbbb274e500237dbf7155a51d4f9c17583d704ea
|
P f2930840e4af3d7d9cb199d316502932fcbbb867
|
||||||
R c267abdc5c97771dbd3d62995c13d672
|
R fadac1472cdeb40a0e5c985ec43cbe17
|
||||||
U dan
|
U dan
|
||||||
Z 5fed91a90fa4060d0a5ac8127dba8c51
|
Z 22d8aae45d188380f4801c8d2b2db4e1
|
||||||
|
@@ -1 +1 @@
|
|||||||
f2930840e4af3d7d9cb199d316502932fcbbb867
|
b0015a1cfe63c924ee5f250aa08460522882009b
|
42
src/main.c
42
src/main.c
@@ -764,26 +764,6 @@ int sqlite3_close(sqlite3 *db){
|
|||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Invoke the transaction-hook.
|
|
||||||
*/
|
|
||||||
void sqlite3TransactionHook(sqlite3 *db, int op, int iLevel){
|
|
||||||
assert( op==SQLITE_BEGIN || op==SQLITE_COMMIT || op==SQLITE_ROLLBACK );
|
|
||||||
assert( op==SQLITE_BEGIN || iLevel<db->iOpenTrans || iLevel==0 );
|
|
||||||
assert( op==SQLITE_BEGIN || iLevel<db->iOpenTrans || db->iOpenTrans==0 );
|
|
||||||
assert( op!=SQLITE_BEGIN || iLevel==db->iOpenTrans || iLevel==0 );
|
|
||||||
assert( op!=SQLITE_BEGIN || iLevel==db->iOpenTrans || db->iOpenTrans==1 );
|
|
||||||
|
|
||||||
if( op==SQLITE_BEGIN && iLevel!=db->iOpenTrans ) return;
|
|
||||||
if( op!=SQLITE_BEGIN && iLevel>=db->iOpenTrans ) return;
|
|
||||||
|
|
||||||
if( db->xTransCallback ){
|
|
||||||
db->xTransCallback(db->pTransArg, op, iLevel);
|
|
||||||
}
|
|
||||||
db->iOpenTrans = iLevel + (op==SQLITE_BEGIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Rollback all database files.
|
** Rollback all database files.
|
||||||
*/
|
*/
|
||||||
@@ -816,10 +796,6 @@ void sqlite3RollbackAll(sqlite3 *db){
|
|||||||
if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){
|
if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){
|
||||||
db->xRollbackCallback(db->pRollbackArg);
|
db->xRollbackCallback(db->pRollbackArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If a transaction-hook is configured, invoke it now to report on
|
|
||||||
** the rollback operation. */
|
|
||||||
sqlite3TransactionHook(db, SQLITE_ROLLBACK, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1314,24 +1290,6 @@ void *sqlite3_preupdate_hook(
|
|||||||
return pRet;
|
return pRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
** Register a callback to be invoked each time a transaction or savepoint
|
|
||||||
** is opened, committed or rolled back.
|
|
||||||
*/
|
|
||||||
void *sqlite3_transaction_hook(
|
|
||||||
sqlite3 *db, /* Database handle */
|
|
||||||
void(*xCallback)(void *, int, int), /* Callback function */
|
|
||||||
void *pArg /* First callback argument */
|
|
||||||
){
|
|
||||||
void *pRet;
|
|
||||||
sqlite3_mutex_enter(db->mutex);
|
|
||||||
pRet = db->pTransArg;
|
|
||||||
db->xTransCallback = xCallback;
|
|
||||||
db->pTransArg = pArg;
|
|
||||||
sqlite3_mutex_leave(db->mutex);
|
|
||||||
return pRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef SQLITE_OMIT_WAL
|
#ifndef SQLITE_OMIT_WAL
|
||||||
/*
|
/*
|
||||||
** The sqlite3_wal_hook() callback registered by sqlite3_wal_autocheckpoint().
|
** The sqlite3_wal_hook() callback registered by sqlite3_wal_autocheckpoint().
|
||||||
|
@@ -6369,17 +6369,6 @@ SQLITE_EXPERIMENTAL int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **);
|
|||||||
SQLITE_EXPERIMENTAL int sqlite3_preupdate_modified(sqlite3 *, int, int *);
|
SQLITE_EXPERIMENTAL int sqlite3_preupdate_modified(sqlite3 *, int, int *);
|
||||||
SQLITE_EXPERIMENTAL int sqlite3_preupdate_count(sqlite3 *);
|
SQLITE_EXPERIMENTAL int sqlite3_preupdate_count(sqlite3 *);
|
||||||
|
|
||||||
/*
|
|
||||||
** CAPI3REF: The transaction hook.
|
|
||||||
*/
|
|
||||||
SQLITE_EXPERIMENTAL
|
|
||||||
void *sqlite3_transaction_hook(sqlite3 *, void(*)(void *, int, int), void *);
|
|
||||||
|
|
||||||
#define SQLITE_BEGIN 1
|
|
||||||
#define SQLITE_COMMIT 2
|
|
||||||
#define SQLITE_ROLLBACK 3
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Undo the hack that converts floating point types to integer for
|
** Undo the hack that converts floating point types to integer for
|
||||||
** builds on processors without floating point support.
|
** builds on processors without floating point support.
|
||||||
|
@@ -833,9 +833,6 @@ struct sqlite3 {
|
|||||||
void*,sqlite3*,int,char const*,char const*,sqlite3_int64,sqlite3_int64
|
void*,sqlite3*,int,char const*,char const*,sqlite3_int64,sqlite3_int64
|
||||||
);
|
);
|
||||||
PreUpdate *pPreUpdate; /* Context for active pre-update callback */
|
PreUpdate *pPreUpdate; /* Context for active pre-update callback */
|
||||||
void *pTransArg; /* First argument to xTransCallback */
|
|
||||||
void (*xTransCallback)(void*,int,int);
|
|
||||||
int iOpenTrans; /* Open transaction (xTransCallback) plus 1 */
|
|
||||||
#ifndef SQLITE_OMIT_WAL
|
#ifndef SQLITE_OMIT_WAL
|
||||||
int (*xWalCallback)(void *, sqlite3 *, const char *, int);
|
int (*xWalCallback)(void *, sqlite3 *, const char *, int);
|
||||||
void *pWalArg;
|
void *pWalArg;
|
||||||
|
@@ -124,7 +124,6 @@ struct SqliteDb {
|
|||||||
Tcl_Obj *pUpdateHook; /* Update hook script (if any) */
|
Tcl_Obj *pUpdateHook; /* Update hook script (if any) */
|
||||||
Tcl_Obj *pPreUpdateHook; /* Pre-update hook script (if any) */
|
Tcl_Obj *pPreUpdateHook; /* Pre-update hook script (if any) */
|
||||||
Tcl_Obj *pRollbackHook; /* Rollback hook script (if any) */
|
Tcl_Obj *pRollbackHook; /* Rollback hook script (if any) */
|
||||||
Tcl_Obj *pTransHook; /* Transaction hook script (if any) */
|
|
||||||
Tcl_Obj *pWalHook; /* WAL hook script (if any) */
|
Tcl_Obj *pWalHook; /* WAL hook script (if any) */
|
||||||
Tcl_Obj *pUnlockNotify; /* Unlock notify script (if any) */
|
Tcl_Obj *pUnlockNotify; /* Unlock notify script (if any) */
|
||||||
SqlCollate *pCollate; /* List of SQL collation functions */
|
SqlCollate *pCollate; /* List of SQL collation functions */
|
||||||
@@ -598,30 +597,6 @@ static void DbRollbackHandler(void *clientData){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
** sqlite3_transaction_hook() callback.
|
|
||||||
*/
|
|
||||||
static void DbTransHandler(void *clientData, int op, int iLevel){
|
|
||||||
static const char *azStr[] = { "BEGIN", "COMMIT", "ROLLBACK" };
|
|
||||||
SqliteDb *pDb = (SqliteDb*)clientData;
|
|
||||||
Tcl_Interp *interp = pDb->interp;
|
|
||||||
Tcl_Obj *pScript;
|
|
||||||
|
|
||||||
assert(pDb->pTransHook);
|
|
||||||
assert( SQLITE_BEGIN==1 );
|
|
||||||
assert( SQLITE_COMMIT==2 );
|
|
||||||
assert( SQLITE_ROLLBACK==3 );
|
|
||||||
|
|
||||||
pScript = Tcl_DuplicateObj(pDb->pTransHook);
|
|
||||||
Tcl_IncrRefCount(pScript);
|
|
||||||
Tcl_ListObjAppendElement(interp, pScript, Tcl_NewStringObj(azStr[op-1], -1));
|
|
||||||
Tcl_ListObjAppendElement(interp, pScript, Tcl_NewIntObj(iLevel));
|
|
||||||
if( TCL_OK!=Tcl_EvalObjEx(interp, pScript, 0) ){
|
|
||||||
Tcl_BackgroundError(interp);
|
|
||||||
}
|
|
||||||
Tcl_DecrRefCount(pScript);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This procedure handles wal_hook callbacks.
|
** This procedure handles wal_hook callbacks.
|
||||||
*/
|
*/
|
||||||
@@ -1653,7 +1628,6 @@ static void DbHookCmd(
|
|||||||
sqlite3_update_hook(db, (pDb->pUpdateHook?DbUpdateHandler:0), pDb);
|
sqlite3_update_hook(db, (pDb->pUpdateHook?DbUpdateHandler:0), pDb);
|
||||||
sqlite3_rollback_hook(db, (pDb->pRollbackHook?DbRollbackHandler:0), pDb);
|
sqlite3_rollback_hook(db, (pDb->pRollbackHook?DbRollbackHandler:0), pDb);
|
||||||
sqlite3_wal_hook(db, (pDb->pWalHook?DbWalHandler:0), pDb);
|
sqlite3_wal_hook(db, (pDb->pWalHook?DbWalHandler:0), pDb);
|
||||||
sqlite3_transaction_hook(db, (pDb->pTransHook?DbTransHandler:0), pDb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1685,8 +1659,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
|
|||||||
"profile", "progress", "rekey",
|
"profile", "progress", "rekey",
|
||||||
"restore", "rollback_hook", "status",
|
"restore", "rollback_hook", "status",
|
||||||
"timeout", "total_changes", "trace",
|
"timeout", "total_changes", "trace",
|
||||||
"transaction", "transaction_hook",
|
"transaction", "unlock_notify", "update_hook",
|
||||||
"unlock_notify", "update_hook",
|
|
||||||
"version", "wal_hook", 0
|
"version", "wal_hook", 0
|
||||||
};
|
};
|
||||||
enum DB_enum {
|
enum DB_enum {
|
||||||
@@ -1701,8 +1674,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
|
|||||||
DB_PROFILE, DB_PROGRESS, DB_REKEY,
|
DB_PROFILE, DB_PROGRESS, DB_REKEY,
|
||||||
DB_RESTORE, DB_ROLLBACK_HOOK, DB_STATUS,
|
DB_RESTORE, DB_ROLLBACK_HOOK, DB_STATUS,
|
||||||
DB_TIMEOUT, DB_TOTAL_CHANGES, DB_TRACE,
|
DB_TIMEOUT, DB_TOTAL_CHANGES, DB_TRACE,
|
||||||
DB_TRANSACTION, DB_TRANSACTION_HOOK,
|
DB_TRANSACTION, DB_UNLOCK_NOTIFY, DB_UPDATE_HOOK,
|
||||||
DB_UNLOCK_NOTIFY, DB_UPDATE_HOOK,
|
|
||||||
DB_VERSION, DB_WAL_HOOK
|
DB_VERSION, DB_WAL_HOOK
|
||||||
};
|
};
|
||||||
/* don't leave trailing commas on DB_enum, it confuses the AIX xlc compiler */
|
/* don't leave trailing commas on DB_enum, it confuses the AIX xlc compiler */
|
||||||
@@ -2942,12 +2914,10 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
|
|||||||
** $db wal_hook ?script?
|
** $db wal_hook ?script?
|
||||||
** $db update_hook ?script?
|
** $db update_hook ?script?
|
||||||
** $db rollback_hook ?script?
|
** $db rollback_hook ?script?
|
||||||
** $db transaction_hook ?script?
|
|
||||||
*/
|
*/
|
||||||
case DB_WAL_HOOK:
|
case DB_WAL_HOOK:
|
||||||
case DB_UPDATE_HOOK:
|
case DB_UPDATE_HOOK:
|
||||||
case DB_ROLLBACK_HOOK:
|
case DB_ROLLBACK_HOOK: {
|
||||||
case DB_TRANSACTION_HOOK: {
|
|
||||||
sqlite3 *db = pDb->db;
|
sqlite3 *db = pDb->db;
|
||||||
|
|
||||||
/* set ppHook to point at pUpdateHook or pRollbackHook, depending on
|
/* set ppHook to point at pUpdateHook or pRollbackHook, depending on
|
||||||
@@ -2957,7 +2927,6 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
|
|||||||
if( choice==DB_WAL_HOOK ) ppHook = &pDb->pWalHook;
|
if( choice==DB_WAL_HOOK ) ppHook = &pDb->pWalHook;
|
||||||
if( choice==DB_UPDATE_HOOK ) ppHook = &pDb->pUpdateHook;
|
if( choice==DB_UPDATE_HOOK ) ppHook = &pDb->pUpdateHook;
|
||||||
if( choice==DB_ROLLBACK_HOOK ) ppHook = &pDb->pRollbackHook;
|
if( choice==DB_ROLLBACK_HOOK ) ppHook = &pDb->pRollbackHook;
|
||||||
if( choice==DB_TRANSACTION_HOOK ) ppHook = &pDb->pTransHook;
|
|
||||||
if( objc>3 ){
|
if( objc>3 ){
|
||||||
Tcl_WrongNumArgs(interp, 2, objv, "?SCRIPT?");
|
Tcl_WrongNumArgs(interp, 2, objv, "?SCRIPT?");
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
|
13
src/vdbe.c
13
src/vdbe.c
@@ -2569,8 +2569,6 @@ case OP_Savepoint: {
|
|||||||
db->nSavepoint++;
|
db->nSavepoint++;
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3TransactionHook(db, SQLITE_BEGIN, db->nSavepoint);
|
|
||||||
|
|
||||||
/* Link the new savepoint into the database handle's list. */
|
/* Link the new savepoint into the database handle's list. */
|
||||||
pNew->pNext = db->pSavepoint;
|
pNew->pNext = db->pSavepoint;
|
||||||
db->pSavepoint = pNew;
|
db->pSavepoint = pNew;
|
||||||
@@ -2637,13 +2635,6 @@ case OP_Savepoint: {
|
|||||||
sqlite3ResetInternalSchema(db, 0);
|
sqlite3ResetInternalSchema(db, 0);
|
||||||
db->flags = (db->flags | SQLITE_InternChanges);
|
db->flags = (db->flags | SQLITE_InternChanges);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert( SAVEPOINT_ROLLBACK+1==SQLITE_ROLLBACK );
|
|
||||||
assert( SAVEPOINT_RELEASE+1==SQLITE_COMMIT );
|
|
||||||
sqlite3TransactionHook(db, p1+1, iSavepoint+1);
|
|
||||||
if( p1==SAVEPOINT_ROLLBACK ){
|
|
||||||
sqlite3TransactionHook(db, SQLITE_BEGIN, iSavepoint+1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Regardless of whether this is a RELEASE or ROLLBACK, destroy all
|
/* Regardless of whether this is a RELEASE or ROLLBACK, destroy all
|
||||||
@@ -2719,9 +2710,6 @@ case OP_AutoCommit: {
|
|||||||
}else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
|
}else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
|
||||||
goto vdbe_return;
|
goto vdbe_return;
|
||||||
}else{
|
}else{
|
||||||
if( desiredAutoCommit==0 ){
|
|
||||||
sqlite3TransactionHook(db, SQLITE_BEGIN, 0);
|
|
||||||
}
|
|
||||||
db->autoCommit = (u8)desiredAutoCommit;
|
db->autoCommit = (u8)desiredAutoCommit;
|
||||||
if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
|
if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
|
||||||
p->pc = pc;
|
p->pc = pc;
|
||||||
@@ -2808,7 +2796,6 @@ case OP_Transaction: {
|
|||||||
p->iStatement = db->nSavepoint + db->nStatement;
|
p->iStatement = db->nSavepoint + db->nStatement;
|
||||||
}
|
}
|
||||||
rc = sqlite3BtreeBeginStmt(pBt, p->iStatement);
|
rc = sqlite3BtreeBeginStmt(pBt, p->iStatement);
|
||||||
sqlite3TransactionHook(db, SQLITE_BEGIN, p->iStatement);
|
|
||||||
|
|
||||||
/* Store the current value of the database handles deferred constraint
|
/* Store the current value of the database handles deferred constraint
|
||||||
** counter. If the statement transaction needs to be rolled back,
|
** counter. If the statement transaction needs to be rolled back,
|
||||||
|
@@ -401,15 +401,7 @@ static int sqlite3Step(Vdbe *p){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
db->activeVdbeCnt++;
|
db->activeVdbeCnt++;
|
||||||
if( p->readOnly==0 ){
|
if( p->readOnly==0 ) db->writeVdbeCnt++;
|
||||||
/* If this statement will open an implicit transaction, invoke the
|
|
||||||
** transaction-hook here. */
|
|
||||||
if( db->autoCommit && db->writeVdbeCnt==0 ){
|
|
||||||
assert( db->nSavepoint==0 );
|
|
||||||
sqlite3TransactionHook(db, SQLITE_BEGIN, 0);
|
|
||||||
}
|
|
||||||
db->writeVdbeCnt++;
|
|
||||||
}
|
|
||||||
p->pc = 0;
|
p->pc = 0;
|
||||||
}
|
}
|
||||||
#ifndef SQLITE_OMIT_EXPLAIN
|
#ifndef SQLITE_OMIT_EXPLAIN
|
||||||
|
@@ -1845,12 +1845,6 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If a transaction-hook is configured, invoke it now to report on the
|
|
||||||
** successful commit operation. */
|
|
||||||
if( rc==SQLITE_OK ){
|
|
||||||
sqlite3TransactionHook(db, SQLITE_COMMIT, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1952,9 +1946,6 @@ int sqlite3VdbeCloseStatement(Vdbe *p, int eOp){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
db->nStatement--;
|
db->nStatement--;
|
||||||
assert( SAVEPOINT_ROLLBACK+1==SQLITE_ROLLBACK );
|
|
||||||
assert( SAVEPOINT_RELEASE+1==SQLITE_COMMIT );
|
|
||||||
sqlite3TransactionHook(db, eOp+1, p->iStatement);
|
|
||||||
p->iStatement = 0;
|
p->iStatement = 0;
|
||||||
|
|
||||||
/* If the statement transaction is being rolled back, also restore the
|
/* If the statement transaction is being rolled back, also restore the
|
||||||
|
131
test/hook.test
131
test/hook.test
@@ -631,136 +631,5 @@ do_preupdate_test 7.5.2.2 {
|
|||||||
UPDATE main t8 2 2 three four xxx
|
UPDATE main t8 2 2 three four xxx
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
|
||||||
# The following tests - hook-8.* - test the transaction hook.
|
|
||||||
#
|
|
||||||
db close
|
|
||||||
forcedelete test.db
|
|
||||||
sqlite3 db test.db
|
|
||||||
|
|
||||||
proc transaction_hook {op iLevel} {
|
|
||||||
lappend ::transaction_hook $op $iLevel
|
|
||||||
}
|
|
||||||
db transaction_hook transaction_hook
|
|
||||||
|
|
||||||
proc do_transaction_test {tn sql x} {
|
|
||||||
set X [list]
|
|
||||||
foreach elem $x {lappend X $elem}
|
|
||||||
|
|
||||||
uplevel do_test $tn [list "
|
|
||||||
set ::transaction_hook \[list\]
|
|
||||||
catchsql { $sql }
|
|
||||||
set ::transaction_hook
|
|
||||||
"] [list $X]
|
|
||||||
}
|
|
||||||
|
|
||||||
do_transaction_test 8.1.1 "CREATE TABLE t1(x)" {BEGIN 0 COMMIT 0}
|
|
||||||
do_transaction_test 8.1.2 "BEGIN" {BEGIN 0}
|
|
||||||
do_transaction_test 8.1.3 "COMMIT" {COMMIT 0}
|
|
||||||
do_transaction_test 8.1.4 "BEGIN ; ROLLBACK" {BEGIN 0 ROLLBACK 0}
|
|
||||||
|
|
||||||
do_execsql_test 8.2.0 {
|
|
||||||
CREATE TABLE t2(a PRIMARY KEY, b);
|
|
||||||
INSERT INTO t2 VALUES(1, 'one');
|
|
||||||
INSERT INTO t2 VALUES(2, 'two');
|
|
||||||
INSERT INTO t2 VALUES(3, 'three');
|
|
||||||
}
|
|
||||||
do_transaction_test 8.2.1 {
|
|
||||||
INSERT INTO t2 VALUES(2, 'xxx')
|
|
||||||
} {BEGIN 0 ROLLBACK 0}
|
|
||||||
|
|
||||||
do_transaction_test 8.2.2 {
|
|
||||||
BEGIN; INSERT INTO t2 SELECT a-2, b FROM t2;
|
|
||||||
} {BEGIN 0 BEGIN 1 ROLLBACK 1}
|
|
||||||
|
|
||||||
do_transaction_test 8.2.3 {
|
|
||||||
INSERT OR ROLLBACK INTO t2 SELECT a-2, b FROM t2;
|
|
||||||
} {ROLLBACK 0}
|
|
||||||
|
|
||||||
do_transaction_test 8.2.4 {
|
|
||||||
BEGIN; INSERT INTO t2 SELECT a+3, b FROM t2;
|
|
||||||
} {BEGIN 0 BEGIN 1 COMMIT 1}
|
|
||||||
|
|
||||||
do_transaction_test 8.2.5 "COMMIT" {COMMIT 0}
|
|
||||||
|
|
||||||
do_transaction_test 8.3.1 {SELECT * FROM t2} {}
|
|
||||||
|
|
||||||
do_transaction_test 8.4.1 {
|
|
||||||
SAVEPOINT top;
|
|
||||||
RELEASE top;
|
|
||||||
} {BEGIN 0 COMMIT 0}
|
|
||||||
|
|
||||||
do_transaction_test 8.4.2 {
|
|
||||||
SAVEPOINT top;
|
|
||||||
ROLLBACK TO top;
|
|
||||||
RELEASE top;
|
|
||||||
} {BEGIN 0 ROLLBACK 0 BEGIN 0 COMMIT 0}
|
|
||||||
|
|
||||||
do_transaction_test 8.4.3 {
|
|
||||||
SAVEPOINT zero;
|
|
||||||
SAVEPOINT one;
|
|
||||||
SAVEPOINT two;
|
|
||||||
SAVEPOINT three;
|
|
||||||
ROLLBACK TO zero;
|
|
||||||
SAVEPOINT one;
|
|
||||||
SAVEPOINT two;
|
|
||||||
SAVEPOINT three;
|
|
||||||
ROLLBACK TO one;
|
|
||||||
SAVEPOINT two;
|
|
||||||
RELEASE zero;
|
|
||||||
|
|
||||||
SAVEPOINT zero;
|
|
||||||
SAVEPOINT one;
|
|
||||||
SAVEPOINT two;
|
|
||||||
RELEASE two;
|
|
||||||
SAVEPOINT two;
|
|
||||||
SAVEPOINT three;
|
|
||||||
RELEASE one;
|
|
||||||
ROLLBACK TO zero;
|
|
||||||
RELEASE zero;
|
|
||||||
} {
|
|
||||||
BEGIN 0 BEGIN 1 BEGIN 2 BEGIN 3 ROLLBACK 0 BEGIN 0
|
|
||||||
BEGIN 1 BEGIN 2 BEGIN 3 ROLLBACK 1 BEGIN 1 BEGIN 2
|
|
||||||
COMMIT 0
|
|
||||||
|
|
||||||
BEGIN 0 BEGIN 1 BEGIN 2 COMMIT 2 BEGIN 2 BEGIN 3 COMMIT 1
|
|
||||||
ROLLBACK 0 BEGIN 0 COMMIT 0
|
|
||||||
}
|
|
||||||
|
|
||||||
do_transaction_test 8.4.4 {
|
|
||||||
BEGIN;
|
|
||||||
SAVEPOINT zero;
|
|
||||||
SAVEPOINT one;
|
|
||||||
SAVEPOINT two;
|
|
||||||
SAVEPOINT three;
|
|
||||||
ROLLBACK TO zero;
|
|
||||||
SAVEPOINT one;
|
|
||||||
SAVEPOINT two;
|
|
||||||
SAVEPOINT three;
|
|
||||||
ROLLBACK TO one;
|
|
||||||
SAVEPOINT two;
|
|
||||||
RELEASE zero;
|
|
||||||
|
|
||||||
SAVEPOINT zero;
|
|
||||||
SAVEPOINT one;
|
|
||||||
SAVEPOINT two;
|
|
||||||
RELEASE two;
|
|
||||||
SAVEPOINT two;
|
|
||||||
SAVEPOINT three;
|
|
||||||
RELEASE one;
|
|
||||||
ROLLBACK TO zero;
|
|
||||||
RELEASE zero;
|
|
||||||
COMMIT;
|
|
||||||
} {
|
|
||||||
BEGIN 0
|
|
||||||
BEGIN 1 BEGIN 2 BEGIN 3 BEGIN 4 ROLLBACK 1 BEGIN 1
|
|
||||||
BEGIN 2 BEGIN 3 BEGIN 4 ROLLBACK 2 BEGIN 2 BEGIN 3
|
|
||||||
COMMIT 1
|
|
||||||
|
|
||||||
BEGIN 1 BEGIN 2 BEGIN 3 COMMIT 3 BEGIN 3 BEGIN 4 COMMIT 2
|
|
||||||
ROLLBACK 1 BEGIN 1 COMMIT 1
|
|
||||||
COMMIT 0
|
|
||||||
}
|
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
|
||||||
|
@@ -35,7 +35,7 @@ do_test tcl-1.1 {
|
|||||||
do_test tcl-1.2 {
|
do_test tcl-1.2 {
|
||||||
set v [catch {db bogus} msg]
|
set v [catch {db bogus} msg]
|
||||||
lappend v $msg
|
lappend v $msg
|
||||||
} {1 {bad option "bogus": must be authorizer, backup, busy, cache, changes, close, collate, collation_needed, commit_hook, complete, copy, enable_load_extension, errorcode, eval, exists, function, incrblob, interrupt, last_insert_rowid, nullvalue, onecolumn, preupdate, profile, progress, rekey, restore, rollback_hook, status, timeout, total_changes, trace, transaction, transaction_hook, unlock_notify, update_hook, version, or wal_hook}}
|
} {1 {bad option "bogus": must be authorizer, backup, busy, cache, changes, close, collate, collation_needed, commit_hook, complete, copy, enable_load_extension, errorcode, eval, exists, function, incrblob, interrupt, last_insert_rowid, nullvalue, onecolumn, preupdate, profile, progress, rekey, restore, rollback_hook, status, timeout, total_changes, trace, transaction, unlock_notify, update_hook, version, or wal_hook}}
|
||||||
do_test tcl-1.2.1 {
|
do_test tcl-1.2.1 {
|
||||||
set v [catch {db cache bogus} msg]
|
set v [catch {db cache bogus} msg]
|
||||||
lappend v $msg
|
lappend v $msg
|
||||||
|
Reference in New Issue
Block a user