From 1f1549f8f3d4acaafb5b4da014389af9b404ceaf Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 26 Aug 2008 21:33:34 +0000 Subject: [PATCH] In the TCL interface, disable the authorizer when during a BEGIN, COMMIT, or ROLLBACK associated with the transaction method. Ticket #3336. (CVS 5618) FossilOrigin-Name: 7e1032ab0031ba535f37b6338a3ac81cb1449d76 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/tclsqlite.c | 8 +++++++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 54e367be32..119ddd2dc3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C All\sthe\spage_size\spragma\sto\schange\sthe\spage\ssize\son\sa\snew\s:memory:\sdatabase,\nbut\snot\sa\svacuumed\s:memory:\sdatabase.\s\sTicket\s#3335\s(CVS\s5617) -D 2008-08-26T21:07:27 +C In\sthe\sTCL\sinterface,\sdisable\sthe\sauthorizer\swhen\sduring\sa\sBEGIN,\sCOMMIT,\nor\sROLLBACK\sassociated\swith\sthe\stransaction\smethod.\sTicket\s#3336.\s(CVS\s5618) +D 2008-08-26T21:33:34 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 689e14735f862a5553bceef206d8c13e29504e44 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -153,7 +153,7 @@ F src/sqliteInt.h c66e9c22a9c7fcf32db52a14fcddaa4d87bf9559 F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8 F src/status.c 8caa772cd9310bc297280f7cf0ede4d69ed5b801 F src/table.c 22744786199c9195720c15a7a42cb97b2e2728d8 -F src/tclsqlite.c ec46084184f033ba396a9ee7b5514b695083d0f3 +F src/tclsqlite.c 420c7936d71f8318ea23b254c0d2cfc365135403 F src/test1.c f92039530f6a6253ec8d3bfeaa54205a0036bbb6 F src/test2.c eaa77124786649eedf47d3c5e94d8070c0da228f F src/test3.c e85b7ce5c28c3ce7fbdbf7f98e1467b19786c62b @@ -624,7 +624,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 555dad900fad874099556d44c464ea9f64687ca0 -R 13266d9013275d3da810529c8b3c4107 +P 226a9056783247679fcf442e10807a1f2707f463 +R 1dca17ea8af03c92a254032098cda071 U drh -Z 5391d7f9c881bbaeba1d5a1fec437229 +Z 054c735d0303cff98ac0e0c962c3aa9b diff --git a/manifest.uuid b/manifest.uuid index ec18d1d201..3a0cce45d7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -226a9056783247679fcf442e10807a1f2707f463 \ No newline at end of file +7e1032ab0031ba535f37b6338a3ac81cb1449d76 \ No newline at end of file diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 35a69b8c12..3da23c3add 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -12,7 +12,7 @@ ** A TCL Interface to SQLite. Append this file to sqlite3.c and ** compile the whole thing to build a TCL-enabled version of SQLite. ** -** $Id: tclsqlite.c,v 1.219 2008/07/10 17:52:49 danielk1977 Exp $ +** $Id: tclsqlite.c,v 1.220 2008/08/26 21:33:34 drh Exp $ */ #include "tcl.h" #include @@ -104,6 +104,7 @@ struct SqliteDb { char *zProfile; /* The profile callback routine */ char *zProgress; /* The progress callback routine */ char *zAuth; /* The authorization callback routine */ + int disableAuth; /* Disable the authorizer if it exists */ char *zNull; /* Text to substitute for an SQL NULL value */ SqlFunc *pFunc; /* List of SQL functions */ Tcl_Obj *pUpdateHook; /* Update hook script (if any) */ @@ -761,6 +762,7 @@ static int auth_callback( int rc; const char *zReply; SqliteDb *pDb = (SqliteDb*)pArg; + if( pDb->disableAuth ) return SQLITE_OK; switch( code ){ case SQLITE_COPY : zCode="SQLITE_COPY"; break; @@ -2224,7 +2226,9 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ } inTrans = !sqlite3_get_autocommit(pDb->db); if( !inTrans ){ + pDb->disableAuth++; (void)sqlite3_exec(pDb->db, zBegin, 0, 0, 0); + pDb->disableAuth--; } rc = Tcl_EvalObjEx(interp, pScript, 0); if( !inTrans ){ @@ -2234,9 +2238,11 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ } else { zEnd = "COMMIT"; } + pDb->disableAuth++; if( sqlite3_exec(pDb->db, zEnd, 0, 0, 0) ){ sqlite3_exec(pDb->db, "ROLLBACK", 0, 0, 0); } + pDb->disableAuth--; } break; } -- 2.47.2