From 5c22e82a175b6015df5b6fe70eabec413fca8a23 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 21 Oct 2015 08:26:01 +0000 Subject: [PATCH] Add extra debugging function to test_rbu.c. Enhance the documentation for sqlite3rbu_db() to define the validity of the returned database handles. FossilOrigin-Name: b9c4aa521156d8ca09151a82a7e80aa8d1d7a313 --- ext/rbu/sqlite3rbu.h | 3 +++ ext/rbu/test_rbu.c | 36 ++++++++++++++++++++++++++++++------ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/ext/rbu/sqlite3rbu.h b/ext/rbu/sqlite3rbu.h index 65d1c5f6e5..f1a0f3cd84 100644 --- a/ext/rbu/sqlite3rbu.h +++ b/ext/rbu/sqlite3rbu.h @@ -341,6 +341,9 @@ sqlite3rbu *sqlite3rbu_open( ** If an error has occurred, either while opening or stepping the RBU object, ** this function may return NULL. The error code and message may be collected ** when sqlite3rbu_close() is called. +** +** Database handles returned by this function remain valid until the next +** call to any sqlite3rbu_xxx() function other than sqlite3rbu_db(). */ sqlite3 *sqlite3rbu_db(sqlite3rbu*, int bRbu); diff --git a/ext/rbu/test_rbu.c b/ext/rbu/test_rbu.c index 6648f28e8b..3fa85b7569 100644 --- a/ext/rbu/test_rbu.c +++ b/ext/rbu/test_rbu.c @@ -56,20 +56,34 @@ static int test_sqlite3rbu_cmd( ){ int ret = TCL_OK; sqlite3rbu *pRbu = (sqlite3rbu*)clientData; - const char *azMethod[] = { - "step", "close", "create_rbu_delta", "savestate", 0 + struct RbuCmd { + const char *zName; + int nArg; + const char *zUsage; + } aCmd[] = { + {"step", 2, ""}, /* 0 */ + {"close", 2, ""}, /* 1 */ + {"create_rbu_delta", 2, ""}, /* 2 */ + {"savestate", 2, ""}, /* 3 */ + {"dbMain_eval", 3, "SQL"}, /* 4 */ + {0,0,0} }; - int iMethod; + int iCmd; - if( objc!=2 ){ + if( objc<2 ){ Tcl_WrongNumArgs(interp, 1, objv, "METHOD"); return TCL_ERROR; } - if( Tcl_GetIndexFromObj(interp, objv[1], azMethod, "method", 0, &iMethod) ){ + ret = Tcl_GetIndexFromObjStruct( + interp, objv[1], aCmd, sizeof(aCmd[0]), "method", 0, &iCmd + ); + if( ret ) return TCL_ERROR; + if( objc!=aCmd[iCmd].nArg ){ + Tcl_WrongNumArgs(interp, 1, objv, aCmd[iCmd].zUsage); return TCL_ERROR; } - switch( iMethod ){ + switch( iCmd ){ case 0: /* step */ { int rc = sqlite3rbu_step(pRbu); Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); @@ -112,6 +126,16 @@ static int test_sqlite3rbu_cmd( break; } + case 4: /* dbMain_eval */ { + sqlite3 *db = sqlite3rbu_db(pRbu, 0); + int rc = sqlite3_exec(db, Tcl_GetString(objv[2]), 0, 0, 0); + if( rc!=SQLITE_OK ){ + Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3_errmsg(db), -1)); + ret = TCL_ERROR; + } + break; + } + default: /* seems unlikely */ assert( !"cannot happen" ); break; diff --git a/manifest b/manifest index e406cb4dc0..05c2a89ea4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\sFTS5. -D 2015-10-20T23:27:14.365 +C Add\sextra\sdebugging\sfunction\sto\stest_rbu.c.\sEnhance\sthe\sdocumentation\sfor\ssqlite3rbu_db()\sto\sdefine\sthe\svalidity\sof\sthe\sreturned\sdatabase\shandles. +D 2015-10-21T08:26:01.477 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 4eb750e0fdf52050a06d881e1b060f4bb116ed7e @@ -230,8 +230,8 @@ F ext/rbu/rbufault2.test 9a7f19edd6ea35c4c9f807d8a3db0a03a5670c06 F ext/rbu/rbufts.test 828cd689da825f0a7b7c53ffc1f6f7fdb6fa5bda F ext/rbu/rbusave.test 0f43b6686084f426ddd040b878426452fd2c2f48 F ext/rbu/sqlite3rbu.c ea47de615e911b3a69a8e7fb3be3866298403a25 -F ext/rbu/sqlite3rbu.h 1d568cb33738d7900975cc5c72e6f68049f15914 -F ext/rbu/test_rbu.c 2a3652241fa45d5eaa141775e4ae68c1d3582c03 +F ext/rbu/sqlite3rbu.h 0bdeb3be211aaba7d85445fa36f4701a25a3dbde +F ext/rbu/test_rbu.c 4a4cdcef4ef9379fc2a21f008805c80b27bcf573 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/rtree.c 0f9b595bd0debcbedf1d7a63d0e0678d619e6c9c F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b8fb263ed1b36d085437131795505e53af103d26 -R 95702bd1633e56deaa7f0c8cd9294ab7 -U mistachkin -Z 2868708b35b26115fe25354e42651fac +P 0a903ec26bfbbe9bfd18bc34934e689ffdb01ce5 +R c0f5065bff60d0df79ae9d2bf6514716 +U dan +Z 2c0acb856eea548f945a4e7fa327a156 diff --git a/manifest.uuid b/manifest.uuid index ea64a17af2..c6965600bc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0a903ec26bfbbe9bfd18bc34934e689ffdb01ce5 \ No newline at end of file +b9c4aa521156d8ca09151a82a7e80aa8d1d7a313 \ No newline at end of file -- 2.47.2