Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Unified Diff: third_party/sqlite/src/ext/rbu/test_rbu.c

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/ext/rbu/sqlite3rbu.c ('k') | third_party/sqlite/src/ext/rtree/rtree.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/ext/rbu/test_rbu.c
diff --git a/third_party/sqlite/src/ext/rbu/test_rbu.c b/third_party/sqlite/src/ext/rbu/test_rbu.c
index 3fa85b756909b72f2c01874c4422f2e5f9b0a594..b1a2252741ee0ff2d4e11383cf2c9a1c0ed7683e 100644
--- a/third_party/sqlite/src/ext/rbu/test_rbu.c
+++ b/third_party/sqlite/src/ext/rbu/test_rbu.c
@@ -17,11 +17,19 @@
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU)
#include "sqlite3rbu.h"
-#include <tcl.h>
+#if defined(INCLUDE_SQLITE_TCL_H)
+# include "sqlite_tcl.h"
+#else
+# include "tcl.h"
+# ifndef SQLITE_TCLAPI
+# define SQLITE_TCLAPI
+# endif
+#endif
#include <assert.h>
-/* From main.c (apparently...) */
+/* From main.c */
extern const char *sqlite3ErrName(int);
+extern int sqlite3TestMakePointerStr(Tcl_Interp*, char*, void*);
void test_rbu_delta(sqlite3_context *pCtx, int nArg, sqlite3_value **apVal){
Tcl_Interp *interp = (Tcl_Interp*)sqlite3_user_data(pCtx);
@@ -48,7 +56,7 @@ void test_rbu_delta(sqlite3_context *pCtx, int nArg, sqlite3_value **apVal){
}
-static int test_sqlite3rbu_cmd(
+static int SQLITE_TCLAPI test_sqlite3rbu_cmd(
ClientData clientData,
Tcl_Interp *interp,
int objc,
@@ -66,6 +74,10 @@ static int test_sqlite3rbu_cmd(
{"create_rbu_delta", 2, ""}, /* 2 */
{"savestate", 2, ""}, /* 3 */
{"dbMain_eval", 3, "SQL"}, /* 4 */
+ {"bp_progress", 2, ""}, /* 5 */
+ {"db", 3, "RBU"}, /* 6 */
+ {"state", 2, ""}, /* 7 */
+ {"progress", 2, ""}, /* 8 */
{0,0,0}
};
int iCmd;
@@ -136,6 +148,46 @@ static int test_sqlite3rbu_cmd(
break;
}
+ case 5: /* bp_progress */ {
+ int one, two;
+ Tcl_Obj *pObj;
+ sqlite3rbu_bp_progress(pRbu, &one, &two);
+
+ pObj = Tcl_NewObj();
+ Tcl_ListObjAppendElement(interp, pObj, Tcl_NewIntObj(one));
+ Tcl_ListObjAppendElement(interp, pObj, Tcl_NewIntObj(two));
+ Tcl_SetObjResult(interp, pObj);
+ break;
+ }
+
+ case 6: /* db */ {
+ int bArg;
+ if( Tcl_GetBooleanFromObj(interp, objv[2], &bArg) ){
+ ret = TCL_ERROR;
+ }else{
+ char zBuf[50];
+ sqlite3 *db = sqlite3rbu_db(pRbu, bArg);
+ if( sqlite3TestMakePointerStr(interp, zBuf, (void*)db) ){
+ ret = TCL_ERROR;
+ }else{
+ Tcl_SetResult(interp, zBuf, TCL_VOLATILE);
+ }
+ }
+ break;
+ }
+ case 7: /* state */ {
+ const char *aRes[] = { 0, "oal", "move", "checkpoint", "done", "error" };
+ int eState = sqlite3rbu_state(pRbu);
+ assert( eState>0 && eState<=5 );
+ Tcl_SetResult(interp, (char*)aRes[eState], TCL_STATIC);
+ break;
+ }
+ case 8: /* progress */ {
+ sqlite3_int64 nStep = sqlite3rbu_progress(pRbu);
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(nStep));
+ break;
+ }
+
default: /* seems unlikely */
assert( !"cannot happen" );
break;
@@ -147,7 +199,7 @@ static int test_sqlite3rbu_cmd(
/*
** Tclcmd: sqlite3rbu CMD <target-db> <rbu-db> ?<state-db>?
*/
-static int test_sqlite3rbu(
+static int SQLITE_TCLAPI test_sqlite3rbu(
ClientData clientData,
Tcl_Interp *interp,
int objc,
@@ -175,9 +227,37 @@ static int test_sqlite3rbu(
}
/*
+** Tclcmd: sqlite3rbu_vacuum CMD <target-db> <state-db>
+*/
+static int SQLITE_TCLAPI test_sqlite3rbu_vacuum(
+ ClientData clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ sqlite3rbu *pRbu = 0;
+ const char *zCmd;
+ const char *zTarget;
+ const char *zStateDb = 0;
+
+ if( objc!=3 && objc!=4 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "NAME TARGET-DB ?STATE-DB?");
+ return TCL_ERROR;
+ }
+ zCmd = Tcl_GetString(objv[1]);
+ zTarget = Tcl_GetString(objv[2]);
+ if( objc==4 ) zStateDb = Tcl_GetString(objv[3]);
+
+ pRbu = sqlite3rbu_vacuum(zTarget, zStateDb);
+ Tcl_CreateObjCommand(interp, zCmd, test_sqlite3rbu_cmd, (ClientData)pRbu, 0);
+ Tcl_SetObjResult(interp, objv[1]);
+ return TCL_OK;
+}
+
+/*
** Tclcmd: sqlite3rbu_create_vfs ?-default? NAME PARENT
*/
-static int test_sqlite3rbu_create_vfs(
+static int SQLITE_TCLAPI test_sqlite3rbu_create_vfs(
ClientData clientData,
Tcl_Interp *interp,
int objc,
@@ -212,7 +292,7 @@ static int test_sqlite3rbu_create_vfs(
/*
** Tclcmd: sqlite3rbu_destroy_vfs NAME
*/
-static int test_sqlite3rbu_destroy_vfs(
+static int SQLITE_TCLAPI test_sqlite3rbu_destroy_vfs(
ClientData clientData,
Tcl_Interp *interp,
int objc,
@@ -233,7 +313,7 @@ static int test_sqlite3rbu_destroy_vfs(
/*
** Tclcmd: sqlite3rbu_internal_test
*/
-static int test_sqlite3rbu_internal_test(
+static int SQLITE_TCLAPI test_sqlite3rbu_internal_test(
ClientData clientData,
Tcl_Interp *interp,
int objc,
@@ -261,6 +341,7 @@ int SqliteRbu_Init(Tcl_Interp *interp){
Tcl_ObjCmdProc *xProc;
} aObjCmd[] = {
{ "sqlite3rbu", test_sqlite3rbu },
+ { "sqlite3rbu_vacuum", test_sqlite3rbu_vacuum },
{ "sqlite3rbu_create_vfs", test_sqlite3rbu_create_vfs },
{ "sqlite3rbu_destroy_vfs", test_sqlite3rbu_destroy_vfs },
{ "sqlite3rbu_internal_test", test_sqlite3rbu_internal_test },
@@ -273,7 +354,11 @@ int SqliteRbu_Init(Tcl_Interp *interp){
}
#else
-#include <tcl.h>
+#if defined(INCLUDE_SQLITE_TCL_H)
+# include "sqlite_tcl.h"
+#else
+# include "tcl.h"
+#endif
int SqliteRbu_Init(Tcl_Interp *interp){ return TCL_OK; }
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU) */
#endif /* defined(SQLITE_TEST) */
« no previous file with comments | « third_party/sqlite/src/ext/rbu/sqlite3rbu.c ('k') | third_party/sqlite/src/ext/rtree/rtree.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698