Index: third_party/sqlite/src/src/test_malloc.c |
diff --git a/third_party/sqlite/src/src/test_malloc.c b/third_party/sqlite/src/src/test_malloc.c |
index c63ded7035bd121004972cfe967f1b25e1fb96cc..bd0a3d1ffd2cc95131c43db362eba580533084a0 100644 |
--- a/third_party/sqlite/src/src/test_malloc.c |
+++ b/third_party/sqlite/src/src/test_malloc.c |
@@ -234,14 +234,14 @@ static int faultsimInstall(int install){ |
#ifdef SQLITE_TEST |
/* |
-** This function is implemented in test1.c. Returns a pointer to a static |
+** This function is implemented in main.c. Returns a pointer to a static |
** buffer containing the symbolic SQLite error code that corresponds to |
** the least-significant 8-bits of the integer passed as an argument. |
** For example: |
** |
-** sqlite3TestErrorName(1) -> "SQLITE_ERROR" |
+** sqlite3ErrName(1) -> "SQLITE_ERROR" |
*/ |
-const char *sqlite3TestErrorName(int); |
+extern const char *sqlite3ErrName(int); |
/* |
** Transform pointers to text and back again |
@@ -696,6 +696,12 @@ static int test_memdebug_pending( |
return TCL_OK; |
} |
+/* |
+** The following global variable keeps track of the number of tests |
+** that have run. This variable is only useful when running in the |
+** debugger. |
+*/ |
+static int sqlite3_memdebug_title_count = 0; |
/* |
** Usage: sqlite3_memdebug_settitle TITLE |
@@ -713,15 +719,16 @@ static int test_memdebug_settitle( |
int objc, |
Tcl_Obj *CONST objv[] |
){ |
- const char *zTitle; |
+ sqlite3_memdebug_title_count++; |
if( objc!=2 ){ |
Tcl_WrongNumArgs(interp, 1, objv, "TITLE"); |
return TCL_ERROR; |
} |
- zTitle = Tcl_GetString(objv[1]); |
#ifdef SQLITE_MEMDEBUG |
{ |
+ const char *zTitle; |
extern int sqlite3MemdebugSettitle(const char*); |
+ zTitle = Tcl_GetString(objv[1]); |
sqlite3MemdebugSettitle(zTitle); |
} |
#endif |
@@ -749,7 +756,7 @@ static void test_memdebug_callback(int nByte, int nFrame, void **aFrame){ |
int isNew; |
int aKey[MALLOC_LOG_KEYINTS]; |
- int nKey = sizeof(int)*MALLOC_LOG_KEYINTS; |
+ unsigned int nKey = sizeof(int)*MALLOC_LOG_KEYINTS; |
memset(aKey, 0, nKey); |
if( (sizeof(void*)*nFrame)<nKey ){ |
@@ -880,7 +887,7 @@ static int test_memdebug_log( |
** |
** Set the scratch memory buffer using SQLITE_CONFIG_SCRATCH. |
** The buffer is static and is of limited size. N might be |
-** adjusted downward as needed to accomodate the requested size. |
+** adjusted downward as needed to accommodate the requested size. |
** The revised value of N is returned. |
** |
** A negative SIZE causes the buffer pointer to be NULL. |
@@ -920,7 +927,7 @@ static int test_config_scratch( |
** |
** Set the page-cache memory buffer using SQLITE_CONFIG_PAGECACHE. |
** The buffer is static and is of limited size. N might be |
-** adjusted downward as needed to accomodate the requested size. |
+** adjusted downward as needed to accommodate the requested size. |
** The revised value of N is returned. |
** |
** A negative SIZE causes the buffer pointer to be NULL. |
@@ -1033,7 +1040,6 @@ static int test_config_lookaside( |
int objc, |
Tcl_Obj *CONST objv[] |
){ |
- int rc; |
int sz, cnt; |
Tcl_Obj *pRet; |
if( objc!=3 ){ |
@@ -1049,7 +1055,7 @@ static int test_config_lookaside( |
Tcl_ListObjAppendElement( |
interp, pRet, Tcl_NewIntObj(sqlite3GlobalConfig.nLookaside) |
); |
- rc = sqlite3_config(SQLITE_CONFIG_LOOKASIDE, sz, cnt); |
+ sqlite3_config(SQLITE_CONFIG_LOOKASIDE, sz, cnt); |
Tcl_SetObjResult(interp, pRet); |
return TCL_OK; |
} |
@@ -1073,7 +1079,7 @@ static int test_db_config_lookaside( |
sqlite3 *db; |
int bufid; |
static char azBuf[2][10000]; |
- int getDbPointer(Tcl_Interp*, const char*, sqlite3**); |
+ extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**); |
if( objc!=5 ){ |
Tcl_WrongNumArgs(interp, 1, objv, "BUFID SIZE COUNT"); |
return TCL_ERROR; |
@@ -1095,9 +1101,7 @@ static int test_db_config_lookaside( |
} |
/* |
-** Usage: |
-** |
-** sqlite3_config_heap NBYTE NMINALLOC |
+** Usage: sqlite3_config_heap NBYTE NMINALLOC |
*/ |
static int test_config_heap( |
void * clientData, |
@@ -1106,7 +1110,6 @@ static int test_config_heap( |
Tcl_Obj *CONST objv[] |
){ |
static char *zBuf; /* Use this memory */ |
- static int szBuf; /* Bytes allocated for zBuf */ |
int nByte; /* Size of buffer to pass to sqlite3_config() */ |
int nMinAlloc; /* Size of minimum allocation */ |
int rc; /* Return code of sqlite3_config() */ |
@@ -1124,20 +1127,45 @@ static int test_config_heap( |
if( nByte==0 ){ |
free( zBuf ); |
zBuf = 0; |
- szBuf = 0; |
rc = sqlite3_config(SQLITE_CONFIG_HEAP, (void*)0, 0, 0); |
}else{ |
zBuf = realloc(zBuf, nByte); |
- szBuf = nByte; |
rc = sqlite3_config(SQLITE_CONFIG_HEAP, zBuf, nByte, nMinAlloc); |
} |
- Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE); |
+ Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
return TCL_OK; |
} |
/* |
-** tclcmd: sqlite3_config_error [DB] |
+** Usage: sqlite3_config_heap_size NBYTE |
+*/ |
+static int test_config_heap_size( |
+ void * clientData, |
+ Tcl_Interp *interp, |
+ int objc, |
+ Tcl_Obj *CONST objv[] |
+){ |
+ int nByte; /* Size to pass to sqlite3_config() */ |
+ int rc; /* Return code of sqlite3_config() */ |
+ |
+ Tcl_Obj * CONST *aArg = &objv[1]; |
+ int nArg = objc-1; |
+ |
+ if( nArg!=1 ){ |
+ Tcl_WrongNumArgs(interp, 1, objv, "NBYTE"); |
+ return TCL_ERROR; |
+ } |
+ if( Tcl_GetIntFromObj(interp, aArg[0], &nByte) ) return TCL_ERROR; |
+ |
+ rc = sqlite3_config(SQLITE_CONFIG_WIN32_HEAPSIZE, nByte); |
+ |
+ Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
+ return TCL_OK; |
+} |
+ |
+/* |
+** Usage: sqlite3_config_error [DB] |
** |
** Invoke sqlite3_config() or sqlite3_db_config() with invalid |
** opcodes and verify that they return errors. |
@@ -1149,7 +1177,7 @@ static int test_config_error( |
Tcl_Obj *CONST objv[] |
){ |
sqlite3 *db; |
- int getDbPointer(Tcl_Interp*, const char*, sqlite3**); |
+ extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**); |
if( objc!=2 && objc!=1 ){ |
Tcl_WrongNumArgs(interp, 1, objv, "[DB]"); |
@@ -1175,10 +1203,67 @@ static int test_config_error( |
} |
/* |
-** Usage: |
+** Usage: sqlite3_config_uri BOOLEAN |
** |
-** sqlite3_dump_memsys3 FILENAME |
-** sqlite3_dump_memsys5 FILENAME |
+** Enables or disables interpretation of URI parameters by default using |
+** SQLITE_CONFIG_URI. |
+*/ |
+static int test_config_uri( |
+ void * clientData, |
+ Tcl_Interp *interp, |
+ int objc, |
+ Tcl_Obj *CONST objv[] |
+){ |
+ int rc; |
+ int bOpenUri; |
+ |
+ if( objc!=2 ){ |
+ Tcl_WrongNumArgs(interp, 1, objv, "BOOL"); |
+ return TCL_ERROR; |
+ } |
+ if( Tcl_GetBooleanFromObj(interp, objv[1], &bOpenUri) ){ |
+ return TCL_ERROR; |
+ } |
+ |
+ rc = sqlite3_config(SQLITE_CONFIG_URI, bOpenUri); |
+ Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
+ |
+ return TCL_OK; |
+} |
+ |
+/* |
+** Usage: sqlite3_config_cis BOOLEAN |
+** |
+** Enables or disables the use of the covering-index scan optimization. |
+** SQLITE_CONFIG_COVERING_INDEX_SCAN. |
+*/ |
+static int test_config_cis( |
+ void * clientData, |
+ Tcl_Interp *interp, |
+ int objc, |
+ Tcl_Obj *CONST objv[] |
+){ |
+ int rc; |
+ int bUseCis; |
+ |
+ if( objc!=2 ){ |
+ Tcl_WrongNumArgs(interp, 1, objv, "BOOL"); |
+ return TCL_ERROR; |
+ } |
+ if( Tcl_GetBooleanFromObj(interp, objv[1], &bUseCis) ){ |
+ return TCL_ERROR; |
+ } |
+ |
+ rc = sqlite3_config(SQLITE_CONFIG_COVERING_INDEX_SCAN, bUseCis); |
+ Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
+ |
+ return TCL_OK; |
+} |
+ |
+ |
+/* |
+** Usage: sqlite3_dump_memsys3 FILENAME |
+** sqlite3_dump_memsys5 FILENAME |
** |
** Write a summary of unfreed memsys3 allocations to FILENAME. |
*/ |
@@ -1193,7 +1278,7 @@ static int test_dump_memsys3( |
return TCL_ERROR; |
} |
- switch( (int)clientData ){ |
+ switch( SQLITE_PTR_TO_INT(clientData) ){ |
case 3: { |
#ifdef SQLITE_ENABLE_MEMSYS3 |
extern void sqlite3Memsys3Dump(const char*); |
@@ -1285,7 +1370,7 @@ static int test_db_status( |
int i, op, resetFlag; |
const char *zOpName; |
sqlite3 *db; |
- int getDbPointer(Tcl_Interp*, const char*, sqlite3**); |
+ extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**); |
static const struct { |
const char *zName; |
int op; |
@@ -1296,11 +1381,15 @@ static int test_db_status( |
{ "STMT_USED", SQLITE_DBSTATUS_STMT_USED }, |
{ "LOOKASIDE_HIT", SQLITE_DBSTATUS_LOOKASIDE_HIT }, |
{ "LOOKASIDE_MISS_SIZE", SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE }, |
- { "LOOKASIDE_MISS_FULL", SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL } |
+ { "LOOKASIDE_MISS_FULL", SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL }, |
+ { "CACHE_HIT", SQLITE_DBSTATUS_CACHE_HIT }, |
+ { "CACHE_MISS", SQLITE_DBSTATUS_CACHE_MISS }, |
+ { "CACHE_WRITE", SQLITE_DBSTATUS_CACHE_WRITE }, |
+ { "DEFERRED_FKS", SQLITE_DBSTATUS_DEFERRED_FKS } |
}; |
Tcl_Obj *pResult; |
if( objc!=4 ){ |
- Tcl_WrongNumArgs(interp, 1, objv, "PARAMETER RESETFLAG"); |
+ Tcl_WrongNumArgs(interp, 1, objv, "DB PARAMETER RESETFLAG"); |
return TCL_ERROR; |
} |
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
@@ -1348,7 +1437,7 @@ static int test_install_malloc_faultsim( |
return TCL_ERROR; |
} |
rc = faultsimInstall(isInstall); |
- Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE); |
+ Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
return TCL_OK; |
} |
@@ -1366,7 +1455,7 @@ static int test_install_memsys3( |
const sqlite3_mem_methods *sqlite3MemGetMemsys3(void); |
rc = sqlite3_config(SQLITE_CONFIG_MALLOC, sqlite3MemGetMemsys3()); |
#endif |
- Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE); |
+ Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
return TCL_OK; |
} |
@@ -1419,9 +1508,12 @@ int Sqlitetest_malloc_Init(Tcl_Interp *interp){ |
{ "sqlite3_db_status", test_db_status ,0 }, |
{ "install_malloc_faultsim", test_install_malloc_faultsim ,0 }, |
{ "sqlite3_config_heap", test_config_heap ,0 }, |
+ { "sqlite3_config_heap_size", test_config_heap_size ,0 }, |
{ "sqlite3_config_memstatus", test_config_memstatus ,0 }, |
{ "sqlite3_config_lookaside", test_config_lookaside ,0 }, |
{ "sqlite3_config_error", test_config_error ,0 }, |
+ { "sqlite3_config_uri", test_config_uri ,0 }, |
+ { "sqlite3_config_cis", test_config_cis ,0 }, |
{ "sqlite3_db_config_lookaside",test_db_config_lookaside ,0 }, |
{ "sqlite3_dump_memsys3", test_dump_memsys3 ,3 }, |
{ "sqlite3_dump_memsys5", test_dump_memsys3 ,5 }, |
@@ -1430,7 +1522,7 @@ int Sqlitetest_malloc_Init(Tcl_Interp *interp){ |
}; |
int i; |
for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ |
- ClientData c = (ClientData)aObjCmd[i].clientData; |
+ ClientData c = (ClientData)SQLITE_INT_TO_PTR(aObjCmd[i].clientData); |
Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, c, 0); |
} |
return TCL_OK; |