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

Unified Diff: third_party/sqlite/src/src/test1.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/src/tclsqlite.c ('k') | third_party/sqlite/src/src/test2.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/src/test1.c
diff --git a/third_party/sqlite/src/src/test1.c b/third_party/sqlite/src/src/test1.c
index c5e71582bcd5a5a21f9f0982e83c465b04f21692..d17fc1022ad4208641894466a6d5fb1a20c76a91 100644
--- a/third_party/sqlite/src/src/test1.c
+++ b/third_party/sqlite/src/src/test1.c
@@ -19,7 +19,11 @@
#endif
#include "vdbeInt.h"
-#include "tcl.h"
+#if defined(INCLUDE_SQLITE_TCL_H)
+# include "sqlite_tcl.h"
+#else
+# include "tcl.h"
+#endif
#include <stdlib.h>
#include <string.h>
@@ -75,7 +79,7 @@ void *sqlite3TestTextToPtr(const char *z){
** for an sqlite connection instance. Bad things happen if the
** input is not an sqlite connection.
*/
-static int get_sqlite_pointer(
+static int SQLITE_TCLAPI get_sqlite_pointer(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -221,7 +225,7 @@ static void io_trace_callback(const char *zFormat, ...){
** I/O tracing begins going into FILENAME. If FILENAME is an empty
** string, I/O tracing is turned off.
*/
-static int test_io_trace(
+static int SQLITE_TCLAPI test_io_trace(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -262,7 +266,7 @@ static int test_io_trace(
**
** Also return true if the OMIT_MISUSE environment variable exists.
*/
-static int clang_sanitize_address(
+static int SQLITE_TCLAPI clang_sanitize_address(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -289,7 +293,7 @@ static int clang_sanitize_address(
** DB. The SQL is the string FORMAT. The format string should contain
** one %s or %q. STRING is the value inserted into %s or %q.
*/
-static int test_exec_printf(
+static int SQLITE_TCLAPI test_exec_printf(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -327,7 +331,7 @@ static int test_exec_printf(
** HEX into ASCII. Most characters are translated as is. %HH becomes
** a hex character.
*/
-static int test_exec_hex(
+static int SQLITE_TCLAPI test_exec_hex(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -373,7 +377,7 @@ static int test_exec_hex(
**
** Enter or leave the mutex on a database connection.
*/
-static int db_enter(
+static int SQLITE_TCLAPI db_enter(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -389,7 +393,7 @@ static int db_enter(
sqlite3_mutex_enter(db->mutex);
return TCL_OK;
}
-static int db_leave(
+static int SQLITE_TCLAPI db_leave(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -411,7 +415,7 @@ static int db_leave(
**
** Invoke the sqlite3_exec interface using the open database DB
*/
-static int test_exec(
+static int SQLITE_TCLAPI test_exec(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -458,7 +462,7 @@ static int test_exec(
** Invoke the sqlite3_exec interface using the open database DB. Discard
** all results
*/
-static int test_exec_nr(
+static int SQLITE_TCLAPI test_exec_nr(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -485,7 +489,7 @@ static int test_exec_nr(
** concatenate arg0 through argn using separator as the separator.
** Return the result.
*/
-static int test_mprintf_z(
+static int SQLITE_TCLAPI test_mprintf_z(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -508,7 +512,7 @@ static int test_mprintf_z(
** Test the %n format of sqlite_mprintf(). Return the length of the
** input string.
*/
-static int test_mprintf_n(
+static int SQLITE_TCLAPI test_mprintf_n(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -532,7 +536,7 @@ static int test_mprintf_n(
** You pass in a format string that requires more than one argument,
** bad things will happen.
*/
-static int test_snprintf_int(
+static int SQLITE_TCLAPI test_snprintf_int(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -558,7 +562,7 @@ static int test_snprintf_int(
** DB. The SQL is the string FORMAT. The format string should contain
** one %s or %q. STRING is the value inserted into %s or %q.
*/
-static int test_get_table_printf(
+static int SQLITE_TCLAPI test_get_table_printf(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -621,7 +625,7 @@ static int test_get_table_printf(
**
** Returns the integer ROWID of the most recent insert.
*/
-static int test_last_rowid(
+static int SQLITE_TCLAPI test_last_rowid(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -645,13 +649,13 @@ static int test_last_rowid(
**
** Set the codec key.
*/
-static int test_key(
+static int SQLITE_TCLAPI test_key(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
){
-#ifdef SQLITE_HAS_CODEC
+#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_CODEC_FROM_TCL)
sqlite3 *db;
const char *zKey;
int nKey;
@@ -673,7 +677,7 @@ static int test_key(
**
** Change the codec key.
*/
-static int test_rekey(
+static int SQLITE_TCLAPI test_rekey(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -701,7 +705,7 @@ static int test_rekey(
**
** Closes the database opened by sqlite3_open.
*/
-static int sqlite_test_close(
+static int SQLITE_TCLAPI sqlite_test_close(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -725,7 +729,7 @@ static int sqlite_test_close(
**
** Closes the database opened by sqlite3_open.
*/
-static int sqlite_test_close_v2(
+static int SQLITE_TCLAPI sqlite_test_close_v2(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -1009,7 +1013,7 @@ static void nondeterministicFunction(
** sqlite3_create_function function while a query is in progress in order
** to test the SQLITE_MISUSE detection logic.
*/
-static int test_create_function(
+static int SQLITE_TCLAPI test_create_function(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -1166,7 +1170,7 @@ static void legacyCountFinalize(sqlite3_context *context){
** "legacy_count()" with the supplied database handle. This is used
** to test the deprecated sqlite3_aggregate_count() API.
*/
-static int test_create_aggregate(
+static int SQLITE_TCLAPI test_create_aggregate(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -1207,7 +1211,7 @@ static int test_create_aggregate(
** Puts uses a separate buffer and debugging statements will be out of
** sequence if it is used.
*/
-static int test_printf(
+static int SQLITE_TCLAPI test_printf(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -1229,7 +1233,7 @@ static int test_printf(
**
** Call mprintf with three integer arguments
*/
-static int sqlite3_mprintf_int(
+static int SQLITE_TCLAPI sqlite3_mprintf_int(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -1256,7 +1260,7 @@ static int sqlite3_mprintf_int(
**
** Call mprintf with three 64-bit integer arguments
*/
-static int sqlite3_mprintf_int64(
+static int SQLITE_TCLAPI sqlite3_mprintf_int64(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -1271,7 +1275,7 @@ static int sqlite3_mprintf_int64(
return TCL_ERROR;
}
for(i=2; i<5; i++){
- if( sqlite3Atoi64(argv[i], &a[i-2], 1000000, SQLITE_UTF8) ){
+ if( sqlite3Atoi64(argv[i], &a[i-2], sqlite3Strlen30(argv[i]), SQLITE_UTF8) ){
Tcl_AppendResult(interp, "argument is not a valid 64-bit integer", 0);
return TCL_ERROR;
}
@@ -1289,7 +1293,7 @@ static int sqlite3_mprintf_int64(
** same as sqlite3_mprintf_int or sqlite3_mprintf_int64, depending on
** platform.
*/
-static int sqlite3_mprintf_long(
+static int SQLITE_TCLAPI sqlite3_mprintf_long(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -1320,7 +1324,7 @@ static int sqlite3_mprintf_long(
**
** Call mprintf with two integer arguments and one string argument
*/
-static int sqlite3_mprintf_str(
+static int SQLITE_TCLAPI sqlite3_mprintf_str(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -1347,7 +1351,7 @@ static int sqlite3_mprintf_str(
**
** Call mprintf with two integer arguments and one string argument
*/
-static int sqlite3_snprintf_str(
+static int SQLITE_TCLAPI sqlite3_snprintf_str(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -1381,7 +1385,7 @@ static int sqlite3_snprintf_str(
**
** Call mprintf with two integer arguments and one double argument
*/
-static int sqlite3_mprintf_double(
+static int SQLITE_TCLAPI sqlite3_mprintf_double(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -1412,7 +1416,7 @@ static int sqlite3_mprintf_double(
** two arguments given above. This is used to generate overflow and underflow
** doubles to test that they are converted properly.
*/
-static int sqlite3_mprintf_scaled(
+static int SQLITE_TCLAPI sqlite3_mprintf_scaled(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -1442,7 +1446,7 @@ static int sqlite3_mprintf_scaled(
** two arguments given above. This is used to generate overflow and underflow
** doubles to test that they are converted properly.
*/
-static int sqlite3_mprintf_stronly(
+static int SQLITE_TCLAPI sqlite3_mprintf_stronly(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -1466,7 +1470,7 @@ static int sqlite3_mprintf_stronly(
** Call mprintf with a single double argument which is derived from the
** hexadecimal encoding of an IEEE double.
*/
-static int sqlite3_mprintf_hexdouble(
+static int SQLITE_TCLAPI sqlite3_mprintf_hexdouble(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -1499,7 +1503,7 @@ static int sqlite3_mprintf_hexdouble(
**
*/
#if !defined(SQLITE_OMIT_SHARED_CACHE)
-static int test_enable_shared(
+static int SQLITE_TCLAPI test_enable_shared(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -1536,7 +1540,7 @@ static int test_enable_shared(
** Usage: sqlite3_extended_result_codes DB BOOLEAN
**
*/
-static int test_extended_result_codes(
+static int SQLITE_TCLAPI test_extended_result_codes(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -1559,7 +1563,7 @@ static int test_extended_result_codes(
** Usage: sqlite3_libversion_number
**
*/
-static int test_libversion_number(
+static int SQLITE_TCLAPI test_libversion_number(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -1573,7 +1577,7 @@ static int test_libversion_number(
** Usage: sqlite3_table_column_metadata DB dbname tblname colname
**
*/
-static int test_table_column_metadata(
+static int SQLITE_TCLAPI test_table_column_metadata(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -1624,7 +1628,7 @@ static int test_table_column_metadata(
#ifndef SQLITE_OMIT_INCRBLOB
-static int blobHandleFromObj(
+static int SQLITE_TCLAPI blobHandleFromObj(
Tcl_Interp *interp,
Tcl_Obj *pObj,
sqlite3_blob **ppBlob
@@ -1653,7 +1657,7 @@ static int blobHandleFromObj(
return TCL_OK;
}
-static int test_blob_reopen(
+static int SQLITE_TCLAPI test_blob_reopen(
ClientData clientData, /* Not used */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -1729,7 +1733,7 @@ static int testCreateCollationCmp(
return iRes;
}
-static int test_create_collation_v2(
+static int SQLITE_TCLAPI test_create_collation_v2(
ClientData clientData, /* Not used */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -1804,7 +1808,7 @@ static void cf2Destroy(void *pUser){
if( p->pDestroy ) Tcl_DecrRefCount(p->pDestroy);
sqlite3_free(p);
}
-static int test_create_function_v2(
+static int SQLITE_TCLAPI test_create_function_v2(
ClientData clientData, /* Not used */
Tcl_Interp *interp, /* The invoking TCL interpreter */
int objc, /* Number of arguments */
@@ -1892,7 +1896,7 @@ static int test_create_function_v2(
/*
** Usage: sqlite3_load_extension DB-HANDLE FILE ?PROC?
*/
-static int test_load_extension(
+static int SQLITE_TCLAPI test_load_extension(
ClientData clientData, /* Not used */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -1931,6 +1935,8 @@ static int test_load_extension(
#ifdef SQLITE_OMIT_LOAD_EXTENSION
rc = SQLITE_ERROR;
zErr = sqlite3_mprintf("this build omits sqlite3_load_extension()");
+ (void)zProc;
+ (void)zFile;
#else
rc = sqlite3_load_extension(db, zFile, zProc, &zErr);
#endif
@@ -1948,7 +1954,7 @@ static int test_load_extension(
/*
** Usage: sqlite3_enable_load_extension DB-HANDLE ONOFF
*/
-static int test_enable_load(
+static int SQLITE_TCLAPI test_enable_load(
ClientData clientData, /* Not used */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -1994,7 +2000,7 @@ static int test_enable_load(
** This command is used to test the recoverability of a database in
** the event of a program crash.
*/
-static int sqlite_abort(
+static int SQLITE_TCLAPI sqlite_abort(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -2053,7 +2059,7 @@ error_out:
**
** Register the test SQL function on the database DB under the name NAME.
*/
-static int test_register_func(
+static int SQLITE_TCLAPI test_register_func(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -2082,7 +2088,7 @@ static int test_register_func(
**
** Finalize a statement handle.
*/
-static int test_finalize(
+static int SQLITE_TCLAPI test_finalize(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2114,7 +2120,7 @@ static int test_finalize(
**
** Get the value of a status counter from a statement.
*/
-static int test_stmt_status(
+static int SQLITE_TCLAPI test_stmt_status(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2159,7 +2165,7 @@ static int test_stmt_status(
/*
** Usage: sqlite3_stmt_scanstatus STMT IDX
*/
-static int test_stmt_scanstatus(
+static int SQLITE_TCLAPI test_stmt_scanstatus(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2209,7 +2215,7 @@ static int test_stmt_scanstatus(
/*
** Usage: sqlite3_stmt_scanstatus_reset STMT
*/
-static int test_stmt_scanstatus_reset(
+static int SQLITE_TCLAPI test_stmt_scanstatus_reset(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2232,7 +2238,7 @@ static int test_stmt_scanstatus_reset(
**
** Zero the SQLITE_CONFIG_SQLLOG configuration
*/
-static int test_config_sqllog(
+static int SQLITE_TCLAPI test_config_sqllog(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2252,7 +2258,7 @@ static int test_config_sqllog(
**
** Return the value returned by the default VFS's xCurrentTimeInt64 method.
*/
-static int vfsCurrentTimeInt64(
+static int SQLITE_TCLAPI vfsCurrentTimeInt64(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2273,7 +2279,7 @@ static int vfsCurrentTimeInt64(
/*
** Usage: sqlite3_snapshot_get DB DBNAME
*/
-static int test_snapshot_get(
+static int SQLITE_TCLAPI test_snapshot_get(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2306,9 +2312,41 @@ static int test_snapshot_get(
#ifdef SQLITE_ENABLE_SNAPSHOT
/*
+** Usage: sqlite3_snapshot_recover DB DBNAME
+*/
+static int SQLITE_TCLAPI test_snapshot_recover(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ int rc;
+ sqlite3 *db;
+ char *zName;
+
+ if( objc!=3 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME");
+ return TCL_ERROR;
+ }
+ if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
+ zName = Tcl_GetString(objv[2]);
+
+ rc = sqlite3_snapshot_recover(db, zName);
+ if( rc!=SQLITE_OK ){
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
+ return TCL_ERROR;
+ }else{
+ Tcl_ResetResult(interp);
+ }
+ return TCL_OK;
+}
+#endif /* SQLITE_ENABLE_SNAPSHOT */
+
+#ifdef SQLITE_ENABLE_SNAPSHOT
+/*
** Usage: sqlite3_snapshot_open DB DBNAME SNAPSHOT
*/
-static int test_snapshot_open(
+static int SQLITE_TCLAPI test_snapshot_open(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2340,7 +2378,7 @@ static int test_snapshot_open(
/*
** Usage: sqlite3_snapshot_free SNAPSHOT
*/
-static int test_snapshot_free(
+static int SQLITE_TCLAPI test_snapshot_free(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2357,12 +2395,167 @@ static int test_snapshot_free(
}
#endif /* SQLITE_ENABLE_SNAPSHOT */
+#ifdef SQLITE_ENABLE_SNAPSHOT
+/*
+** Usage: sqlite3_snapshot_cmp SNAPSHOT1 SNAPSHOT2
+*/
+static int SQLITE_TCLAPI test_snapshot_cmp(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ int res;
+ sqlite3_snapshot *p1;
+ sqlite3_snapshot *p2;
+ if( objc!=3 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "SNAPSHOT1 SNAPSHOT2");
+ return TCL_ERROR;
+ }
+ p1 = (sqlite3_snapshot*)sqlite3TestTextToPtr(Tcl_GetString(objv[1]));
+ p2 = (sqlite3_snapshot*)sqlite3TestTextToPtr(Tcl_GetString(objv[2]));
+ res = sqlite3_snapshot_cmp(p1, p2);
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(res));
+ return TCL_OK;
+}
+#endif /* SQLITE_ENABLE_SNAPSHOT */
+
+#ifdef SQLITE_ENABLE_SNAPSHOT
+/*
+** Usage: sqlite3_snapshot_get_blob DB DBNAME
+*/
+static int SQLITE_TCLAPI test_snapshot_get_blob(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ int rc;
+ sqlite3 *db;
+ char *zName;
+ sqlite3_snapshot *pSnapshot = 0;
+
+ if( objc!=3 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME");
+ return TCL_ERROR;
+ }
+ if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
+ zName = Tcl_GetString(objv[2]);
+
+ rc = sqlite3_snapshot_get(db, zName, &pSnapshot);
+ if( rc!=SQLITE_OK ){
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
+ return TCL_ERROR;
+ }else{
+ Tcl_SetObjResult(interp,
+ Tcl_NewByteArrayObj((unsigned char*)pSnapshot, sizeof(sqlite3_snapshot))
+ );
+ sqlite3_snapshot_free(pSnapshot);
+ }
+ return TCL_OK;
+}
+#endif /* SQLITE_ENABLE_SNAPSHOT */
+
+#ifdef SQLITE_ENABLE_SNAPSHOT
+ /*
+ ** Usage: sqlite3_snapshot_open_blob DB DBNAME SNAPSHOT
+*/
+static int SQLITE_TCLAPI test_snapshot_open_blob(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ int rc;
+ sqlite3 *db;
+ char *zName;
+ unsigned char *pBlob;
+ int nBlob;
+
+ if( objc!=4 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME SNAPSHOT");
+ return TCL_ERROR;
+ }
+ if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
+ zName = Tcl_GetString(objv[2]);
+ pBlob = Tcl_GetByteArrayFromObj(objv[3], &nBlob);
+ if( nBlob!=sizeof(sqlite3_snapshot) ){
+ Tcl_AppendResult(interp, "bad SNAPSHOT", 0);
+ return TCL_ERROR;
+ }
+ rc = sqlite3_snapshot_open(db, zName, (sqlite3_snapshot*)pBlob);
+ if( rc!=SQLITE_OK ){
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
+ return TCL_ERROR;
+ }
+ return TCL_OK;
+}
+#endif /* SQLITE_ENABLE_SNAPSHOT */
+
+#ifdef SQLITE_ENABLE_SNAPSHOT
+/*
+** Usage: sqlite3_snapshot_cmp_blob SNAPSHOT1 SNAPSHOT2
+*/
+static int SQLITE_TCLAPI test_snapshot_cmp_blob(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ int res;
+ unsigned char *p1;
+ unsigned char *p2;
+ int n1;
+ int n2;
+
+ if( objc!=3 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "SNAPSHOT1 SNAPSHOT2");
+ return TCL_ERROR;
+ }
+
+ p1 = Tcl_GetByteArrayFromObj(objv[1], &n1);
+ p2 = Tcl_GetByteArrayFromObj(objv[2], &n2);
+
+ if( n1!=sizeof(sqlite3_snapshot) || n1!=n2 ){
+ Tcl_AppendResult(interp, "bad SNAPSHOT", 0);
+ return TCL_ERROR;
+ }
+
+ res = sqlite3_snapshot_cmp((sqlite3_snapshot*)p1, (sqlite3_snapshot*)p2);
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(res));
+ return TCL_OK;
+}
+#endif /* SQLITE_ENABLE_SNAPSHOT */
+
+/*
+** Usage: sqlite3_delete_database FILENAME
+*/
+int sqlite3_delete_database(const char*); /* in test_delete.c */
+static int SQLITE_TCLAPI test_delete_database(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ int rc;
+ const char *zFile;
+ if( objc!=2 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "FILE");
+ return TCL_ERROR;
+ }
+ zFile = (const char*)Tcl_GetString(objv[1]);
+ rc = sqlite3_delete_database(zFile);
+
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
+ return TCL_OK;
+}
+
/*
** Usage: sqlite3_next_stmt DB STMT
**
** Return the next statment in sequence after STMT.
*/
-static int test_next_stmt(
+static int SQLITE_TCLAPI test_next_stmt(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2394,7 +2587,7 @@ static int test_next_stmt(
** Return true if STMT is a NULL pointer or a pointer to a statement
** that is guaranteed to leave the database unmodified.
*/
-static int test_stmt_readonly(
+static int SQLITE_TCLAPI test_stmt_readonly(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2421,7 +2614,7 @@ static int test_stmt_readonly(
** Return true if STMT is a non-NULL pointer to a statement
** that has been stepped but not to completion.
*/
-static int test_stmt_busy(
+static int SQLITE_TCLAPI test_stmt_busy(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2447,7 +2640,7 @@ static int test_stmt_busy(
**
** Return true if STMT uses a statement journal.
*/
-static int uses_stmt_journal(
+static int SQLITE_TCLAPI uses_stmt_journal(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2473,7 +2666,7 @@ static int uses_stmt_journal(
**
** Reset a statement handle.
*/
-static int test_reset(
+static int SQLITE_TCLAPI test_reset(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2508,7 +2701,7 @@ static int test_reset(
**
** Return TRUE if a recompilation of the statement is recommended.
*/
-static int test_expired(
+static int SQLITE_TCLAPI test_expired(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2532,7 +2725,7 @@ static int test_expired(
**
** Transfer all bindings from FROMSTMT over to TOSTMT
*/
-static int test_transfer_bind(
+static int SQLITE_TCLAPI test_transfer_bind(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2559,7 +2752,7 @@ static int test_transfer_bind(
** Return the number of changes made to the database by the last SQL
** execution.
*/
-static int test_changes(
+static int SQLITE_TCLAPI test_changes(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2594,7 +2787,7 @@ static int sqlite_static_bind_nbyte = 0;
** of the VALUE is made. If FLAGS=="blob10" then a VALUE is ignored
** an a 10-byte blob "abc\000xyz\000pq" is inserted.
*/
-static int test_bind(
+static int SQLITE_TCLAPI test_bind(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -2716,7 +2909,7 @@ static int test_collate_func(
Tcl_GetIntFromObj(i, Tcl_GetObjResult(i), &res);
return res;
}
-static int test_collate(
+static int SQLITE_TCLAPI test_collate(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2790,7 +2983,7 @@ static int test_utf16bin_collate_func(
if( res==0 ) res = nA - nB;
return res;
}
-static int test_utf16bin_collate(
+static int SQLITE_TCLAPI test_utf16bin_collate(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2847,7 +3040,7 @@ static void test_collate_needed_cb(
/*
** Usage: add_test_collate_needed DB
*/
-static int test_collate_needed(
+static int SQLITE_TCLAPI test_collate_needed(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -2898,7 +3091,7 @@ static int alignmentCollFunc(
}
return rc;
}
-static int add_alignment_test_collations(
+static int SQLITE_TCLAPI add_alignment_test_collations(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3016,7 +3209,7 @@ static void test_function_utf16be(
sqlite3ValueFree(pVal);
}
#endif /* SQLITE_OMIT_UTF16 */
-static int test_function(
+static int SQLITE_TCLAPI test_function(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3061,7 +3254,7 @@ bad_args:
** The result is a list of two elements, the string representation of the
** error code and the english language explanation.
*/
-static int test_errstr(
+static int SQLITE_TCLAPI test_errstr(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3094,7 +3287,7 @@ static int test_errstr(
** Then run testfixture in the debugger and wait for the breakpoint to
** fire. Then additional breakpoints can be set to trace down the bug.
*/
-static int test_breakpoint(
+static int SQLITE_TCLAPI test_breakpoint(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
@@ -3110,7 +3303,7 @@ static int test_breakpoint(
** IDX is the index of a wildcard in the prepared statement. This command
** binds a N-byte zero-filled BLOB to the wildcard.
*/
-static int test_bind_zeroblob(
+static int SQLITE_TCLAPI test_bind_zeroblob(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3146,7 +3339,7 @@ static int test_bind_zeroblob(
** IDX is the index of a wildcard in the prepared statement. This command
** binds a N-byte zero-filled BLOB to the wildcard.
*/
-static int test_bind_zeroblob64(
+static int SQLITE_TCLAPI test_bind_zeroblob64(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3154,7 +3347,7 @@ static int test_bind_zeroblob64(
){
sqlite3_stmt *pStmt;
int idx;
- i64 n;
+ Tcl_WideInt n;
int rc;
if( objc!=4 ){
@@ -3183,7 +3376,7 @@ static int test_bind_zeroblob64(
** N is the index of a wildcard in the prepared statement. This command
** binds a 32-bit integer VALUE to that wildcard.
*/
-static int test_bind_int(
+static int SQLITE_TCLAPI test_bind_int(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3215,13 +3408,152 @@ static int test_bind_int(
/*
+** Usage: intarray_addr INT ...
+**
+** Return the address of a C-language array of 32-bit integers.
+**
+** Space to hold the array is obtained from malloc(). Call this procedure once
+** with no arguments in order to release memory. Each call to this procedure
+** overwrites the previous array.
+*/
+static int SQLITE_TCLAPI test_intarray_addr(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ int i;
+ static int *p = 0;
+
+ sqlite3_free(p);
+ p = 0;
+ if( objc>1 ){
+ p = sqlite3_malloc( sizeof(p[0])*(objc-1) );
+ if( p==0 ) return TCL_ERROR;
+ for(i=0; i<objc-1; i++){
+ if( Tcl_GetIntFromObj(interp, objv[1+i], &p[i]) ){
+ sqlite3_free(p);
+ p = 0;
+ return TCL_ERROR;
+ }
+ }
+ }
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj((sqlite3_int64)p));
+ return TCL_OK;
+}
+/*
+** Usage: intarray_addr INT ...
+**
+** Return the address of a C-language array of 32-bit integers.
+**
+** Space to hold the array is obtained from malloc(). Call this procedure once
+** with no arguments in order to release memory. Each call to this procedure
+** overwrites the previous array.
+*/
+static int SQLITE_TCLAPI test_int64array_addr(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ int i;
+ static sqlite3_int64 *p = 0;
+
+ sqlite3_free(p);
+ p = 0;
+ if( objc>1 ){
+ p = sqlite3_malloc( sizeof(p[0])*(objc-1) );
+ if( p==0 ) return TCL_ERROR;
+ for(i=0; i<objc-1; i++){
+ Tcl_WideInt v;
+ if( Tcl_GetWideIntFromObj(interp, objv[1+i], &v) ){
+ sqlite3_free(p);
+ p = 0;
+ return TCL_ERROR;
+ }
+ p[i] = v;
+ }
+ }
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj((sqlite3_int64)p));
+ return TCL_OK;
+}
+/*
+** Usage: doublearray_addr INT ...
+**
+** Return the address of a C-language array of doubles.
+**
+** Space to hold the array is obtained from malloc(). Call this procedure once
+** with no arguments in order to release memory. Each call to this procedure
+** overwrites the previous array.
+*/
+static int SQLITE_TCLAPI test_doublearray_addr(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ int i;
+ static double *p = 0;
+
+ sqlite3_free(p);
+ p = 0;
+ if( objc>1 ){
+ p = sqlite3_malloc( sizeof(p[0])*(objc-1) );
+ if( p==0 ) return TCL_ERROR;
+ for(i=0; i<objc-1; i++){
+ if( Tcl_GetDoubleFromObj(interp, objv[1+i], &p[i]) ){
+ sqlite3_free(p);
+ p = 0;
+ return TCL_ERROR;
+ }
+ }
+ }
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj((sqlite3_int64)p));
+ return TCL_OK;
+}
+/*
+** Usage: textarray_addr TEXT ...
+**
+** Return the address of a C-language array of strings.
+**
+** Space to hold the array is obtained from malloc(). Call this procedure once
+** with no arguments in order to release memory. Each call to this procedure
+** overwrites the previous array.
+*/
+static int SQLITE_TCLAPI test_textarray_addr(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ int i;
+ static int n = 0;
+ static char **p = 0;
+
+ for(i=0; i<n; i++) sqlite3_free(p[i]);
+ sqlite3_free(p);
+ p = 0;
+ if( objc>1 ){
+ p = sqlite3_malloc( sizeof(p[0])*(objc-1) );
+ if( p==0 ) return TCL_ERROR;
+ for(i=0; i<objc-1; i++){
+ p[i] = sqlite3_mprintf("%s", Tcl_GetString(objv[1+i]));
+ }
+ }
+ n = objc-1;
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj((sqlite3_int64)p));
+ return TCL_OK;
+}
+
+
+/*
** Usage: sqlite3_bind_int64 STMT N VALUE
**
** Test the sqlite3_bind_int64 interface. STMT is a prepared statement.
** N is the index of a wildcard in the prepared statement. This command
** binds a 64-bit integer VALUE to that wildcard.
*/
-static int test_bind_int64(
+static int SQLITE_TCLAPI test_bind_int64(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3259,7 +3591,7 @@ static int test_bind_int64(
** N is the index of a wildcard in the prepared statement. This command
** binds a 64-bit integer VALUE to that wildcard.
*/
-static int test_bind_double(
+static int SQLITE_TCLAPI test_bind_double(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3335,7 +3667,7 @@ static int test_bind_double(
** N is the index of a wildcard in the prepared statement. This command
** binds a NULL to the wildcard.
*/
-static int test_bind_null(
+static int SQLITE_TCLAPI test_bind_null(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3371,7 +3703,7 @@ static int test_bind_null(
** binds a UTF-8 string STRING to the wildcard. The string is BYTES bytes
** long.
*/
-static int test_bind_text(
+static int SQLITE_TCLAPI test_bind_text(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3412,7 +3744,7 @@ static int test_bind_text(
** binds a UTF-16 string STRING to the wildcard. The string is BYTES bytes
** long.
*/
-static int test_bind_text16(
+static int SQLITE_TCLAPI test_bind_text16(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3460,14 +3792,14 @@ static int test_bind_text16(
** N is the index of a wildcard in the prepared statement. This command
** binds a BLOB to the wildcard. The BLOB is BYTES bytes in size.
*/
-static int test_bind_blob(
+static int SQLITE_TCLAPI test_bind_blob(
void * clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *CONST objv[]
){
sqlite3_stmt *pStmt;
- int idx;
+ int len, idx;
int bytes;
char *value;
int rc;
@@ -3486,9 +3818,18 @@ static int test_bind_blob(
if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR;
- value = Tcl_GetString(objv[3]);
+
+ value = (char*)Tcl_GetByteArrayFromObj(objv[3], &len);
if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR;
+ if( bytes>len ){
+ char zBuf[200];
+ sqlite3_snprintf(sizeof(zBuf), zBuf,
+ "cannot use %d blob bytes, have %d", bytes, len);
+ Tcl_AppendResult(interp, zBuf, -1);
+ return TCL_ERROR;
+ }
+
rc = sqlite3_bind_blob(pStmt, idx, value, bytes, xDestructor);
if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR;
if( rc!=SQLITE_OK ){
@@ -3503,7 +3844,7 @@ static int test_bind_blob(
**
** Return the number of wildcards in the given statement.
*/
-static int test_bind_parameter_count(
+static int SQLITE_TCLAPI test_bind_parameter_count(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3527,7 +3868,7 @@ static int test_bind_parameter_count(
** An empty string is returned if N is out of range or if the wildcard
** is nameless.
*/
-static int test_bind_parameter_name(
+static int SQLITE_TCLAPI test_bind_parameter_name(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3554,7 +3895,7 @@ static int test_bind_parameter_name(
** Return the index of the wildcard called NAME. Return 0 if there is
** no such wildcard.
*/
-static int test_bind_parameter_index(
+static int SQLITE_TCLAPI test_bind_parameter_index(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3579,7 +3920,7 @@ static int test_bind_parameter_index(
** Usage: sqlite3_clear_bindings STMT
**
*/
-static int test_clear_bindings(
+static int SQLITE_TCLAPI test_clear_bindings(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3599,7 +3940,7 @@ static int test_clear_bindings(
/*
** Usage: sqlite3_sleep MILLISECONDS
*/
-static int test_sleep(
+static int SQLITE_TCLAPI test_sleep(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3624,7 +3965,7 @@ static int test_sleep(
** Return the string representation of the most recent sqlite3_* API
** error code. e.g. "SQLITE_ERROR".
*/
-static int test_ex_errcode(
+static int SQLITE_TCLAPI test_ex_errcode(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3651,7 +3992,7 @@ static int test_ex_errcode(
** Return the string representation of the most recent sqlite3_* API
** error code. e.g. "SQLITE_ERROR".
*/
-static int test_errcode(
+static int SQLITE_TCLAPI test_errcode(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3677,7 +4018,7 @@ static int test_errcode(
** Returns the UTF-8 representation of the error message string for the
** most recent sqlite3_* API call.
*/
-static int test_errmsg(
+static int SQLITE_TCLAPI test_errmsg(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3706,7 +4047,7 @@ static int test_errmsg(
** level, and it includes the 0x00 0x00 terminator bytes at the end of the
** UTF-16 string.
*/
-static int test_errmsg16(
+static int SQLITE_TCLAPI test_errmsg16(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3743,7 +4084,7 @@ static int test_errmsg16(
** variable that is set to the unused portion of <sql> (if any). A
** STMT handle is returned.
*/
-static int test_prepare(
+static int SQLITE_TCLAPI test_prepare(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3800,7 +4141,7 @@ static int test_prepare(
** variable that is set to the unused portion of <sql> (if any). A
** STMT handle is returned.
*/
-static int test_prepare_v2(
+static int SQLITE_TCLAPI test_prepare_v2(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3868,7 +4209,7 @@ static int test_prepare_v2(
** Generate a prepared statement for a zero-byte string as a test
** for ticket #3134. The string should be preceded by a zero byte.
*/
-static int test_prepare_tkt3134(
+static int SQLITE_TCLAPI test_prepare_tkt3134(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3911,7 +4252,7 @@ static int test_prepare_tkt3134(
** variable that is set to the unused portion of <sql> (if any). A
** STMT handle is returned.
*/
-static int test_prepare16(
+static int SQLITE_TCLAPI test_prepare16(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -3971,7 +4312,7 @@ static int test_prepare16(
** variable that is set to the unused portion of <sql> (if any). A
** STMT handle is returned.
*/
-static int test_prepare16_v2(
+static int SQLITE_TCLAPI test_prepare16_v2(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4026,7 +4367,7 @@ static int test_prepare16_v2(
/*
** Usage: sqlite3_open filename ?options-list?
*/
-static int test_open(
+static int SQLITE_TCLAPI test_open(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4053,7 +4394,7 @@ static int test_open(
/*
** Usage: sqlite3_open_v2 FILENAME FLAGS VFS
*/
-static int test_open_v2(
+static int SQLITE_TCLAPI test_open_v2(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4123,7 +4464,7 @@ static int test_open_v2(
/*
** Usage: sqlite3_open16 filename options
*/
-static int test_open16(
+static int SQLITE_TCLAPI test_open16(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4155,7 +4496,7 @@ static int test_open16(
** Return 1 if the supplied argument is a complete SQL statement, or zero
** otherwise.
*/
-static int test_complete16(
+static int SQLITE_TCLAPI test_complete16(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4180,7 +4521,7 @@ static int test_complete16(
**
** Advance the statement to the next row.
*/
-static int test_step(
+static int SQLITE_TCLAPI test_step(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4203,7 +4544,7 @@ static int test_step(
return TCL_OK;
}
-static int test_sql(
+static int SQLITE_TCLAPI test_sql(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4220,13 +4561,33 @@ static int test_sql(
Tcl_SetResult(interp, (char *)sqlite3_sql(pStmt), TCL_VOLATILE);
return TCL_OK;
}
+static int SQLITE_TCLAPI test_ex_sql(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ sqlite3_stmt *pStmt;
+ char *z;
+
+ if( objc!=2 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "STMT");
+ return TCL_ERROR;
+ }
+
+ if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
+ z = sqlite3_expanded_sql(pStmt);
+ Tcl_SetResult(interp, z, TCL_VOLATILE);
+ sqlite3_free(z);
+ return TCL_OK;
+}
/*
** Usage: sqlite3_column_count STMT
**
** Return the number of columns returned by the sql statement STMT.
*/
-static int test_column_count(
+static int SQLITE_TCLAPI test_column_count(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4251,7 +4612,7 @@ static int test_column_count(
**
** Return the type of the data in column 'column' of the current row.
*/
-static int test_column_type(
+static int SQLITE_TCLAPI test_column_type(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4300,7 +4661,7 @@ static int test_column_type(
** Return the data in column 'column' of the current row cast as an
** wide (64-bit) integer.
*/
-static int test_column_int64(
+static int SQLITE_TCLAPI test_column_int64(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4327,7 +4688,7 @@ static int test_column_int64(
/*
** Usage: sqlite3_column_blob STMT column
*/
-static int test_column_blob(
+static int SQLITE_TCLAPI test_column_blob(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4359,7 +4720,7 @@ static int test_column_blob(
**
** Return the data in column 'column' of the current row cast as a double.
*/
-static int test_column_double(
+static int SQLITE_TCLAPI test_column_double(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4388,7 +4749,7 @@ static int test_column_double(
**
** Return the number of columns returned by the sql statement STMT.
*/
-static int test_data_count(
+static int SQLITE_TCLAPI test_data_count(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4415,7 +4776,7 @@ static int test_data_count(
**
** Usage: sqlite3_column_name STMT column
*/
-static int test_stmt_utf8(
+static int SQLITE_TCLAPI test_stmt_utf8(
void * clientData, /* Pointer to SQLite API function to be invoke */
Tcl_Interp *interp,
int objc,
@@ -4442,7 +4803,7 @@ static int test_stmt_utf8(
return TCL_OK;
}
-static int test_global_recover(
+static int SQLITE_TCLAPI test_global_recover(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4467,7 +4828,7 @@ static int test_global_recover(
**
** Usage: sqlite3_column_name STMT column
*/
-static int test_stmt_utf16(
+static int SQLITE_TCLAPI test_stmt_utf16(
void * clientData, /* Pointer to SQLite API function to be invoked */
Tcl_Interp *interp,
int objc,
@@ -4511,7 +4872,7 @@ static int test_stmt_utf16(
** Usage: sqlite3_column_bytes16 STMT column
**
*/
-static int test_stmt_int(
+static int SQLITE_TCLAPI test_stmt_int(
void * clientData, /* Pointer to SQLite API function to be invoked */
Tcl_Interp *interp,
int objc,
@@ -4540,7 +4901,7 @@ static int test_stmt_int(
**
** Set the db->magic value. This is used to test error recovery logic.
*/
-static int sqlite_set_magic(
+static int SQLITE_TCLAPI sqlite_set_magic(
void * clientData,
Tcl_Interp *interp,
int argc,
@@ -4572,7 +4933,7 @@ static int sqlite_set_magic(
**
** Trigger an interrupt on DB
*/
-static int test_interrupt(
+static int SQLITE_TCLAPI test_interrupt(
void * clientData,
Tcl_Interp *interp,
int argc,
@@ -4613,7 +4974,7 @@ u64 sqlite3StackDepth(void){
**
** Try to measure the amount of stack space used by a call to sqlite3_exec
*/
-static int test_stack_used(
+static int SQLITE_TCLAPI test_stack_used(
void * clientData,
Tcl_Interp *interp,
int argc,
@@ -4641,7 +5002,7 @@ static int test_stack_used(
** is assumed that the user function was created as UTF8, any number of
** arguments (the way the TCL interface does it).
*/
-static int delete_function(
+static int SQLITE_TCLAPI delete_function(
void * clientData,
Tcl_Interp *interp,
int argc,
@@ -4667,7 +5028,7 @@ static int delete_function(
** DB. It is assumed that the collation sequence was created as UTF8 (the
** way the TCL interface does it).
*/
-static int delete_collation(
+static int SQLITE_TCLAPI delete_collation(
void * clientData,
Tcl_Interp *interp,
int argc,
@@ -4692,7 +5053,7 @@ static int delete_collation(
** Return true if the database DB is currently in auto-commit mode.
** Return false if not.
*/
-static int get_autocommit(
+static int SQLITE_TCLAPI get_autocommit(
void * clientData,
Tcl_Interp *interp,
int argc,
@@ -4718,7 +5079,7 @@ static int get_autocommit(
** method of the TCL interface. But we need a way to test the case
** where it returns SQLITE_MISUSE.
*/
-static int test_busy_timeout(
+static int SQLITE_TCLAPI test_busy_timeout(
void * clientData,
Tcl_Interp *interp,
int argc,
@@ -4744,7 +5105,7 @@ static int test_busy_timeout(
** Return the name of the internal representation for the
** value of the given variable.
*/
-static int tcl_variable_type(
+static int SQLITE_TCLAPI tcl_variable_type(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4770,7 +5131,7 @@ static int tcl_variable_type(
** The integer N is the number of bytes we are trying to release. The
** return value is the amount of memory actually released.
*/
-static int test_release_memory(
+static int SQLITE_TCLAPI test_release_memory(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4801,7 +5162,7 @@ static int test_release_memory(
** Attempt to release memory currently held by database DB. Return the
** result code (which in the current implementation is always zero).
*/
-static int test_db_release_memory(
+static int SQLITE_TCLAPI test_db_release_memory(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4824,7 +5185,7 @@ static int test_db_release_memory(
**
** Attempt to flush any dirty pages to disk.
*/
-static int test_db_cacheflush(
+static int SQLITE_TCLAPI test_db_cacheflush(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4848,11 +5209,34 @@ static int test_db_cacheflush(
}
/*
+** Usage: sqlite3_system_errno DB
+**
+** Return the low-level system errno value.
+*/
+static int SQLITE_TCLAPI test_system_errno(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ sqlite3 *db;
+ int iErrno;
+ if( objc!=2 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "DB");
+ return TCL_ERROR;
+ }
+ if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
+ iErrno = sqlite3_system_errno(db);
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(iErrno));
+ return TCL_OK;
+}
+
+/*
** Usage: sqlite3_db_filename DB DBNAME
**
** Return the name of a file associated with a database.
*/
-static int test_db_filename(
+static int SQLITE_TCLAPI test_db_filename(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4876,7 +5260,7 @@ static int test_db_filename(
** Return 1 or 0 if DBNAME is readonly or not. Return -1 if DBNAME does
** not exist.
*/
-static int test_db_readonly(
+static int SQLITE_TCLAPI test_db_readonly(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4901,7 +5285,7 @@ static int test_db_readonly(
** limit is only changed if the N is present. The previous limit
** is returned.
*/
-static int test_soft_heap_limit(
+static int SQLITE_TCLAPI test_soft_heap_limit(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4926,7 +5310,7 @@ static int test_soft_heap_limit(
**
** Call the sqlite3_thread_cleanup API.
*/
-static int test_thread_cleanup(
+static int SQLITE_TCLAPI test_thread_cleanup(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4944,7 +5328,7 @@ static int test_thread_cleanup(
** Return a list of numbers which are the PagerRefcount for all
** pagers on each database connection.
*/
-static int test_pager_refcounts(
+static int SQLITE_TCLAPI test_pager_refcounts(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -4990,7 +5374,7 @@ static int test_pager_refcounts(
** and that the errors they are seeing in the test scripts might be
** a result of their defective TCL rather than problems in SQLite.
*/
-static int working_64bit_int(
+static int SQLITE_TCLAPI working_64bit_int(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5015,7 +5399,7 @@ static int working_64bit_int(
** VFS when none are previously registered, and the ability to
** unregister the only available VFS. Ticket #2738
*/
-static int vfs_unlink_test(
+static int SQLITE_TCLAPI vfs_unlink_test(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5117,7 +5501,7 @@ static int vfs_unlink_test(
** This TCL command attempts to vfs_find and vfs_register when the
** sqlite3_initialize() interface is failing. All calls should fail.
*/
-static int vfs_initfail_test(
+static int SQLITE_TCLAPI vfs_initfail_test(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5145,7 +5529,7 @@ static int nVfs = 0;
**
** Unregister all VFSes.
*/
-static int vfs_unregister_all(
+static int SQLITE_TCLAPI vfs_unregister_all(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5163,17 +5547,19 @@ static int vfs_unregister_all(
/*
** tclcmd: vfs_reregister_all
**
-** Restore all VFSes that were removed using vfs_unregister_all
+** Restore all VFSes that were removed using vfs_unregister_all. Taking
+** care to put the linked list back together in the same order as it was
+** in before vfs_unregister_all was invoked.
*/
-static int vfs_reregister_all(
+static int SQLITE_TCLAPI vfs_reregister_all(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
Tcl_Obj *CONST objv[] /* Command arguments */
){
int i;
- for(i=0; i<nVfs; i++){
- sqlite3_vfs_register(apVfs[i], i==0);
+ for(i=nVfs-1; i>=0; i--){
+ sqlite3_vfs_register(apVfs[i], 1);
}
return TCL_OK;
}
@@ -5185,7 +5571,7 @@ static int vfs_reregister_all(
** This TCL command runs the sqlite3_file_control interface and
** verifies correct operation of the same.
*/
-static int file_control_test(
+static int SQLITE_TCLAPI file_control_test(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5220,7 +5606,7 @@ static int file_control_test(
** This TCL command runs the sqlite3_file_control interface and
** verifies correct operation of the SQLITE_LAST_ERRNO verb.
*/
-static int file_control_lasterrno_test(
+static int SQLITE_TCLAPI file_control_lasterrno_test(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5258,7 +5644,7 @@ static int file_control_lasterrno_test(
** verifies correct operation of the SQLITE_GET_LOCKPROXYFILE and
** SQLITE_SET_LOCKPROXYFILE verbs.
*/
-static int file_control_chunksize_test(
+static int SQLITE_TCLAPI file_control_chunksize_test(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5295,7 +5681,7 @@ static int file_control_chunksize_test(
** This TCL command runs the sqlite3_file_control interface
** with SQLITE_FCNTL_SIZE_HINT
*/
-static int file_control_sizehint_test(
+static int SQLITE_TCLAPI file_control_sizehint_test(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5333,7 +5719,7 @@ static int file_control_sizehint_test(
** verifies correct operation of the SQLITE_GET_LOCKPROXYFILE and
** SQLITE_SET_LOCKPROXYFILE verbs.
*/
-static int file_control_lockproxy_test(
+static int SQLITE_TCLAPI file_control_lockproxy_test(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5403,7 +5789,7 @@ static int file_control_lockproxy_test(
** This TCL command runs the sqlite3_file_control interface with
** the SQLITE_FCNTL_WIN32_AV_RETRY opcode.
*/
-static int file_control_win32_av_retry(
+static int SQLITE_TCLAPI file_control_win32_av_retry(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5431,12 +5817,44 @@ static int file_control_win32_av_retry(
}
/*
+** tclcmd: file_control_win32_get_handle DB
+**
+** This TCL command runs the sqlite3_file_control interface with
+** the SQLITE_FCNTL_WIN32_GET_HANDLE opcode.
+*/
+static int file_control_win32_get_handle(
+ ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
+ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
+ int objc, /* Number of arguments */
+ Tcl_Obj *CONST objv[] /* Command arguments */
+){
+ sqlite3 *db;
+ int rc;
+ HANDLE hFile = NULL;
+ char z[100];
+
+ if( objc!=2 ){
+ Tcl_AppendResult(interp, "wrong # args: should be \"",
+ Tcl_GetStringFromObj(objv[0], 0), " DB", 0);
+ return TCL_ERROR;
+ }
+ if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){
+ return TCL_ERROR;
+ }
+ rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_WIN32_GET_HANDLE,
+ (void*)&hFile);
+ sqlite3_snprintf(sizeof(z), z, "%d %p", rc, (void*)hFile);
+ Tcl_AppendResult(interp, z, (char*)0);
+ return TCL_OK;
+}
+
+/*
** tclcmd: file_control_win32_set_handle DB HANDLE
**
** This TCL command runs the sqlite3_file_control interface with
** the SQLITE_FCNTL_WIN32_SET_HANDLE opcode.
*/
-static int file_control_win32_set_handle(
+static int SQLITE_TCLAPI file_control_win32_set_handle(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5472,7 +5890,7 @@ static int file_control_win32_set_handle(
** This TCL command runs the sqlite3_file_control interface with
** the SQLITE_FCNTL_PERSIST_WAL opcode.
*/
-static int file_control_persist_wal(
+static int SQLITE_TCLAPI file_control_persist_wal(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5504,7 +5922,7 @@ static int file_control_persist_wal(
** This TCL command runs the sqlite3_file_control interface with
** the SQLITE_FCNTL_POWERSAFE_OVERWRITE opcode.
*/
-static int file_control_powersafe_overwrite(
+static int SQLITE_TCLAPI file_control_powersafe_overwrite(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5536,7 +5954,7 @@ static int file_control_powersafe_overwrite(
**
** Return a string that describes the stack of VFSes.
*/
-static int file_control_vfsname(
+static int SQLITE_TCLAPI file_control_vfsname(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5568,7 +5986,7 @@ static int file_control_vfsname(
**
** Return a string that is a temporary filename
*/
-static int file_control_tempfilename(
+static int SQLITE_TCLAPI file_control_tempfilename(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5601,7 +6019,7 @@ static int file_control_tempfilename(
**
** Return a tcl list containing the names of all registered vfs's.
*/
-static int vfs_list(
+static int SQLITE_TCLAPI vfs_list(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5626,7 +6044,7 @@ static int vfs_list(
** This TCL command runs the sqlite3_limit interface and
** verifies correct operation of the same.
*/
-static int test_limit(
+static int SQLITE_TCLAPI test_limit(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5689,7 +6107,7 @@ static int test_limit(
** At the same time, verify that sqlite3_test_control works even when
** called with an out-of-range opcode.
*/
-static int save_prng_state(
+static int SQLITE_TCLAPI save_prng_state(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5705,7 +6123,7 @@ static int save_prng_state(
/*
** tclcmd: restore_prng_state
*/
-static int restore_prng_state(
+static int SQLITE_TCLAPI restore_prng_state(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5717,7 +6135,7 @@ static int restore_prng_state(
/*
** tclcmd: reset_prng_state
*/
-static int reset_prng_state(
+static int SQLITE_TCLAPI reset_prng_state(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5733,7 +6151,7 @@ static int reset_prng_state(
** Indicate that database files might be corrupt. In other words, set the normal
** state of operation.
*/
-static int database_may_be_corrupt(
+static int SQLITE_TCLAPI database_may_be_corrupt(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5748,7 +6166,7 @@ static int database_may_be_corrupt(
** Indicate that database files are always well-formed. This enables extra assert()
** statements that test conditions that are always true for well-formed databases.
*/
-static int database_never_corrupt(
+static int SQLITE_TCLAPI database_never_corrupt(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5761,7 +6179,7 @@ static int database_never_corrupt(
/*
** tclcmd: pcache_stats
*/
-static int test_pcache_stats(
+static int SQLITE_TCLAPI test_pcache_stats(
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5803,7 +6221,7 @@ static void test_unlock_notify_cb(void **aArg, int nArg){
** tclcmd: sqlite3_unlock_notify db
*/
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
-static int test_unlock_notify(
+static int SQLITE_TCLAPI test_unlock_notify(
ClientData clientData, /* Unused */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5829,7 +6247,7 @@ static int test_unlock_notify(
/*
** tclcmd: sqlite3_wal_checkpoint db ?NAME?
*/
-static int test_wal_checkpoint(
+static int SQLITE_TCLAPI test_wal_checkpoint(
ClientData clientData, /* Unused */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5873,7 +6291,7 @@ static int test_wal_checkpoint(
** the number of frames in the log and the number of frames in the log
** that have been checkpointed.
*/
-static int test_wal_checkpoint_v2(
+static int SQLITE_TCLAPI test_wal_checkpoint_v2(
ClientData clientData, /* Unused */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5929,7 +6347,7 @@ static int test_wal_checkpoint_v2(
/*
** tclcmd: sqlite3_wal_autocheckpoint db VALUE
*/
-static int test_wal_autocheckpoint(
+static int SQLITE_TCLAPI test_wal_autocheckpoint(
ClientData clientData, /* Unused */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -5980,7 +6398,7 @@ static void xLogcallback(void *unused, int err, char *zMsg){
Tcl_EvalObjEx(logcallback.pInterp, pNew, TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT);
Tcl_DecrRefCount(pNew);
}
-static int test_sqlite3_log(
+static int SQLITE_TCLAPI test_sqlite3_log(
ClientData clientData,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -6011,7 +6429,7 @@ static int test_sqlite3_log(
** Run a TCL command using its objProc interface. Throw an error if
** the command has no objProc interface.
*/
-static int runAsObjProc(
+static int SQLITE_TCLAPI runAsObjProc(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -6074,7 +6492,7 @@ int printExplainQueryPlan(sqlite3_stmt *pStmt){
return sqlite3_finalize(pExplain);
}
-static int test_print_eqp(
+static int SQLITE_TCLAPI test_print_eqp(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -6102,7 +6520,7 @@ static int test_print_eqp(
/*
** sqlite3_test_control VERB ARGS...
*/
-static int test_test_control(
+static int SQLITE_TCLAPI test_test_control(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -6181,7 +6599,7 @@ static int test_test_control(
#include <sys/time.h>
#include <sys/resource.h>
-static int test_getrusage(
+static int SQLITE_TCLAPI test_getrusage(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -6224,7 +6642,7 @@ struct win32FileLocker {
/*
** The background thread that does file locking.
*/
-static void win32_file_locker(void *pAppData){
+static void SQLITE_CDECL win32_file_locker(void *pAppData){
struct win32FileLocker *p = (struct win32FileLocker*)pAppData;
if( p->evName ){
HANDLE ev = OpenEvent(EVENT_MODIFY_STATE, FALSE, p->evName);
@@ -6255,7 +6673,7 @@ static void win32_file_locker(void *pAppData){
** Get an exclusive manditory lock on file for DELAY2 milliseconds.
** Wait DELAY1 milliseconds before acquiring the lock.
*/
-static int win32_file_lock(
+static int SQLITE_TCLAPI win32_file_lock(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -6319,7 +6737,7 @@ static int win32_file_lock(
** Returns non-zero if the specified path exists, whose fully qualified name
** may exceed 260 characters if it is prefixed with "\\?\".
*/
-static int win32_exists_path(
+static int SQLITE_TCLAPI win32_exists_path(
void *clientData,
Tcl_Interp *interp,
int objc,
@@ -6341,7 +6759,7 @@ static int win32_exists_path(
** whose fully qualified name may exceed 248 characters if it is prefixed with
** "\\?\".
*/
-static int win32_find_file(
+static int SQLITE_TCLAPI win32_find_file(
void *clientData,
Tcl_Interp *interp,
int objc,
@@ -6386,7 +6804,7 @@ static int win32_find_file(
** Deletes the specified file, whose fully qualified name may exceed 260
** characters if it is prefixed with "\\?\".
*/
-static int win32_delete_file(
+static int SQLITE_TCLAPI win32_delete_file(
void *clientData,
Tcl_Interp *interp,
int objc,
@@ -6410,7 +6828,7 @@ static int win32_delete_file(
** Creates the specified directory, whose fully qualified name may exceed 248
** characters if it is prefixed with "\\?\".
*/
-static int win32_mkdir(
+static int SQLITE_TCLAPI win32_mkdir(
void *clientData,
Tcl_Interp *interp,
int objc,
@@ -6434,7 +6852,7 @@ static int win32_mkdir(
** Removes the specified directory, whose fully qualified name may exceed 248
** characters if it is prefixed with "\\?\".
*/
-static int win32_rmdir(
+static int SQLITE_TCLAPI win32_rmdir(
void *clientData,
Tcl_Interp *interp,
int objc,
@@ -6461,7 +6879,7 @@ static int win32_rmdir(
** interface. Disable if BOOLEAN is false and enable if BOOLEAN is true.
** OPT is the name of the optimization to be disabled.
*/
-static int optimization_control(
+static int SQLITE_TCLAPI optimization_control(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -6518,20 +6936,21 @@ static int optimization_control(
return TCL_OK;
}
-typedef struct sqlite3_api_routines sqlite3_api_routines;
/*
** load_static_extension DB NAME ...
**
** Load one or more statically linked extensions.
*/
-static int tclLoadStaticExtensionCmd(
+static int SQLITE_TCLAPI tclLoadStaticExtensionCmd(
void * clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *CONST objv[]
){
extern int sqlite3_amatch_init(sqlite3*,char**,const sqlite3_api_routines*);
+ extern int sqlite3_carray_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_closure_init(sqlite3*,char**,const sqlite3_api_routines*);
+ extern int sqlite3_csv_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_eval_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_fileio_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_fuzzer_init(sqlite3*,char**,const sqlite3_api_routines*);
@@ -6539,6 +6958,7 @@ static int tclLoadStaticExtensionCmd(
extern int sqlite3_nextchar_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_percentile_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_regexp_init(sqlite3*,char**,const sqlite3_api_routines*);
+ extern int sqlite3_remember_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_series_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_spellfix_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_totype_init(sqlite3*,char**,const sqlite3_api_routines*);
@@ -6548,7 +6968,9 @@ static int tclLoadStaticExtensionCmd(
int (*pInit)(sqlite3*,char**,const sqlite3_api_routines*);
} aExtension[] = {
{ "amatch", sqlite3_amatch_init },
+ { "carray", sqlite3_carray_init },
{ "closure", sqlite3_closure_init },
+ { "csv", sqlite3_csv_init },
{ "eval", sqlite3_eval_init },
{ "fileio", sqlite3_fileio_init },
{ "fuzzer", sqlite3_fuzzer_init },
@@ -6556,6 +6978,7 @@ static int tclLoadStaticExtensionCmd(
{ "nextchar", sqlite3_nextchar_init },
{ "percentile", sqlite3_percentile_init },
{ "regexp", sqlite3_regexp_init },
+ { "remember", sqlite3_remember_init },
{ "series", sqlite3_series_init },
{ "spellfix", sqlite3_spellfix_init },
{ "totype", sqlite3_totype_init },
@@ -6598,7 +7021,7 @@ static int tclLoadStaticExtensionCmd(
** sorter_test_fakeheap BOOL
**
*/
-static int sorter_test_fakeheap(
+static int SQLITE_TCLAPI sorter_test_fakeheap(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -6638,7 +7061,7 @@ static int sorter_test_fakeheap(
** Then execute statement $SQL2. Check that the statement returns the same
** set of integers in the same order as in the previous step (using $SQL1).
*/
-static int sorter_test_sort4_helper(
+static int SQLITE_TCLAPI sorter_test_sort4_helper(
void * clientData,
Tcl_Interp *interp,
int objc,
@@ -6648,8 +7071,8 @@ static int sorter_test_sort4_helper(
const char *zSql2;
int nStep;
int iStep;
- int iCksum1 = 0;
- int iCksum2 = 0;
+ unsigned int iCksum1 = 0;
+ unsigned int iCksum2 = 0;
int rc;
int iB;
sqlite3 *db;
@@ -6676,7 +7099,7 @@ static int sorter_test_sort4_helper(
return TCL_ERROR;
}
- iCksum1 += (iCksum1 << 3) + a;
+ iCksum1 += (iCksum1 << 3) + (unsigned int)a;
}
rc = sqlite3_finalize(pStmt);
if( rc!=SQLITE_OK ) goto sql_error;
@@ -6685,7 +7108,7 @@ static int sorter_test_sort4_helper(
if( rc!=SQLITE_OK ) goto sql_error;
for(iStep=0; SQLITE_ROW==sqlite3_step(pStmt); iStep++){
int a = sqlite3_column_int(pStmt, 0);
- iCksum2 += (iCksum2 << 3) + a;
+ iCksum2 += (iCksum2 << 3) + (unsigned int)a;
}
rc = sqlite3_finalize(pStmt);
if( rc!=SQLITE_OK ) goto sql_error;
@@ -6707,7 +7130,7 @@ static int sorter_test_sort4_helper(
/*
** tclcmd: sqlite3_user_authenticate DB USERNAME PASSWORD
*/
-static int test_user_authenticate(
+static int SQLITE_TCLAPI test_user_authenticate(
ClientData clientData, /* Unused */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -6738,7 +7161,7 @@ static int test_user_authenticate(
/*
** tclcmd: sqlite3_user_add DB USERNAME PASSWORD ISADMIN
*/
-static int test_user_add(
+static int SQLITE_TCLAPI test_user_add(
ClientData clientData, /* Unused */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -6771,7 +7194,7 @@ static int test_user_add(
/*
** tclcmd: sqlite3_user_change DB USERNAME PASSWORD ISADMIN
*/
-static int test_user_change(
+static int SQLITE_TCLAPI test_user_change(
ClientData clientData, /* Unused */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -6804,7 +7227,7 @@ static int test_user_change(
/*
** tclcmd: sqlite3_user_delete DB USERNAME
*/
-static int test_user_delete(
+static int SQLITE_TCLAPI test_user_delete(
ClientData clientData, /* Unused */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -6841,7 +7264,7 @@ static int test_user_delete(
** 3 Read after free
** 4 Panic
*/
-static int test_bad_behavior(
+static int SQLITE_TCLAPI test_bad_behavior(
ClientData clientData, /* Pointer to an integer containing zero */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -6891,7 +7314,7 @@ static int test_bad_behavior(
**
** Cause the dbstat virtual table to be available on the connection DB
*/
-static int test_register_dbstat_vtab(
+static int SQLITE_TCLAPI test_register_dbstat_vtab(
void *clientData,
Tcl_Interp *interp,
int objc,
@@ -6921,6 +7344,78 @@ static int test_register_dbstat_vtab(
}
/*
+** tclcmd: sqlite3_db_config DB SETTING VALUE
+**
+** Invoke sqlite3_db_config() for one of the setting values.
+*/
+static int SQLITE_TCLAPI test_sqlite3_db_config(
+ void *clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ static const struct {
+ const char *zName;
+ int eVal;
+ } aSetting[] = {
+ { "FKEY", SQLITE_DBCONFIG_ENABLE_FKEY },
+ { "TRIGGER", SQLITE_DBCONFIG_ENABLE_TRIGGER },
+ { "FTS3_TOKENIZER", SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER },
+ { "LOAD_EXTENSION", SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION },
+ { "NO_CKPT_ON_CLOSE",SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE },
+ };
+ int i;
+ int v;
+ const char *zSetting;
+ sqlite3 *db;
+
+ if( objc!=4 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "DB SETTING VALUE");
+ return TCL_ERROR;
+ }
+ if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
+ zSetting = Tcl_GetString(objv[2]);
+ if( sqlite3_strglob("SQLITE_*", zSetting)==0 ) zSetting += 7;
+ if( sqlite3_strglob("DBCONFIG_*", zSetting)==0 ) zSetting += 9;
+ if( sqlite3_strglob("ENABLE_*", zSetting)==0 ) zSetting += 7;
+ for(i=0; i<ArraySize(aSetting); i++){
+ if( strcmp(zSetting, aSetting[i].zName)==0 ) break;
+ }
+ if( i>=ArraySize(aSetting) ){
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj("unknown sqlite3_db_config setting", -1));
+ return TCL_ERROR;
+ }
+ if( Tcl_GetIntFromObj(interp, objv[3], &v) ) return TCL_ERROR;
+ sqlite3_db_config(db, aSetting[i].eVal, v, &v);
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(v));
+ return TCL_OK;
+}
+
+/*
+** Change the name of the main database schema from "main" to "icecube".
+*/
+static int SQLITE_TCLAPI test_dbconfig_maindbname_icecube(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ int rc;
+ sqlite3 *db;
+ extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**);
+ if( objc!=2 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "DB");
+ return TCL_ERROR;
+ }else{
+ if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
+ rc = sqlite3_db_config(db, SQLITE_DBCONFIG_MAINDBNAME, "icecube");
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
+ return TCL_OK;
+ }
+}
+
+/*
** Register commands with the TCL interpreter.
*/
int Sqlitetest1_Init(Tcl_Interp *interp){
@@ -6934,7 +7429,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
extern int sqlite3_hostid_num;
#endif
extern int sqlite3_max_blobsize;
- extern int sqlite3BtreeSharedCacheReport(void*,
+ extern int SQLITE_TCLAPI sqlite3BtreeSharedCacheReport(void*,
Tcl_Interp*,int,Tcl_Obj*CONST*);
static int iZero = 0;
static struct {
@@ -6989,9 +7484,14 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
Tcl_ObjCmdProc *xProc;
void *clientData;
} aObjCmd[] = {
+ { "sqlite3_db_config", test_sqlite3_db_config, 0 },
{ "bad_behavior", test_bad_behavior, (void*)&iZero },
{ "register_dbstat_vtab", test_register_dbstat_vtab },
{ "sqlite3_connection_pointer", get_sqlite_pointer, 0 },
+ { "intarray_addr", test_intarray_addr, 0 },
+ { "int64array_addr", test_int64array_addr, 0 },
+ { "doublearray_addr", test_doublearray_addr, 0 },
+ { "textarray_addr", test_textarray_addr, 0 },
{ "sqlite3_bind_int", test_bind_int, 0 },
{ "sqlite3_bind_zeroblob", test_bind_zeroblob, 0 },
{ "sqlite3_bind_zeroblob64", test_bind_zeroblob64, 0 },
@@ -7028,6 +7528,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "sqlite3_changes", test_changes ,0 },
{ "sqlite3_step", test_step ,0 },
{ "sqlite3_sql", test_sql ,0 },
+ { "sqlite3_expanded_sql", test_ex_sql ,0 },
{ "sqlite3_next_stmt", test_next_stmt ,0 },
{ "sqlite3_stmt_readonly", test_stmt_readonly ,0 },
{ "sqlite3_stmt_busy", test_stmt_busy ,0 },
@@ -7036,6 +7537,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "sqlite3_release_memory", test_release_memory, 0},
{ "sqlite3_db_release_memory", test_db_release_memory, 0},
{ "sqlite3_db_cacheflush", test_db_cacheflush, 0},
+ { "sqlite3_system_errno", test_system_errno, 0},
{ "sqlite3_db_filename", test_db_filename, 0},
{ "sqlite3_db_readonly", test_db_readonly, 0},
{ "sqlite3_soft_heap_limit", test_soft_heap_limit, 0},
@@ -7046,6 +7548,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "sqlite3_enable_load_extension", test_enable_load, 0},
{ "sqlite3_extended_result_codes", test_extended_result_codes, 0},
{ "sqlite3_limit", test_limit, 0},
+ { "dbconfig_maindbname_icecube", test_dbconfig_maindbname_icecube },
{ "save_prng_state", save_prng_state, 0 },
{ "restore_prng_state", restore_prng_state, 0 },
@@ -7112,6 +7615,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "file_control_sizehint_test", file_control_sizehint_test, 0 },
#if SQLITE_OS_WIN
{ "file_control_win32_av_retry", file_control_win32_av_retry, 0 },
+ { "file_control_win32_get_handle", file_control_win32_get_handle, 0 },
{ "file_control_win32_set_handle", file_control_win32_set_handle, 0 },
#endif
{ "file_control_persist_wal", file_control_persist_wal, 0 },
@@ -7175,7 +7679,13 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "sqlite3_snapshot_get", test_snapshot_get, 0 },
{ "sqlite3_snapshot_open", test_snapshot_open, 0 },
{ "sqlite3_snapshot_free", test_snapshot_free, 0 },
+ { "sqlite3_snapshot_cmp", test_snapshot_cmp, 0 },
+ { "sqlite3_snapshot_recover", test_snapshot_recover, 0 },
+ { "sqlite3_snapshot_get_blob", test_snapshot_get_blob, 0 },
+ { "sqlite3_snapshot_open_blob", test_snapshot_open_blob, 0 },
+ { "sqlite3_snapshot_cmp_blob", test_snapshot_cmp_blob, 0 },
#endif
+ { "sqlite3_delete_database", test_delete_database, 0 },
};
static int bitmask_size = sizeof(Bitmask)*8;
static int longdouble_size = sizeof(LONGDOUBLE_TYPE);
« no previous file with comments | « third_party/sqlite/src/src/tclsqlite.c ('k') | third_party/sqlite/src/src/test2.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698