diff options
Diffstat (limited to 'ext/pdo_sqlite/sqlite/src/test1.c')
| -rw-r--r-- | ext/pdo_sqlite/sqlite/src/test1.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/ext/pdo_sqlite/sqlite/src/test1.c b/ext/pdo_sqlite/sqlite/src/test1.c index f271eee875..7448de0e66 100644 --- a/ext/pdo_sqlite/sqlite/src/test1.c +++ b/ext/pdo_sqlite/sqlite/src/test1.c @@ -198,6 +198,57 @@ static int exec_printf_cb(void *pArg, int argc, char **argv, char **name){ } /* +** The I/O tracing callback. +*/ +static FILE *iotrace_file = 0; +static void io_trace_callback(const char *zFormat, ...){ + va_list ap; + va_start(ap, zFormat); + vfprintf(iotrace_file, zFormat, ap); + va_end(ap); + fflush(iotrace_file); +} + +/* +** Usage: io_trace FILENAME +** +** Turn I/O tracing on or off. If FILENAME is not an empty string, +** I/O tracing begins going into FILENAME. If FILENAME is an empty +** string, I/O tracing is turned off. +*/ +static int test_io_trace( + void *NotUsed, + Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ + int argc, /* Number of arguments */ + char **argv /* Text of each argument */ +){ + if( argc!=2 ){ + Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], + " FILENAME\"", 0); + return TCL_ERROR; + } + if( iotrace_file ){ + if( iotrace_file!=stdout && iotrace_file!=stderr ){ + fclose(iotrace_file); + } + iotrace_file = 0; + sqlite3_io_trace = 0; + } + if( argv[1][0] ){ + if( strcmp(argv[1],"stdout")==0 ){ + iotrace_file = stdout; + }else if( strcmp(argv[1],"stderr")==0 ){ + iotrace_file = stderr; + }else{ + iotrace_file = fopen(argv[1], "w"); + } + sqlite3_io_trace = io_trace_callback; + } + return SQLITE_OK; +} + + +/* ** Usage: sqlite3_exec_printf DB FORMAT STRING ** ** Invoke the sqlite3_exec_printf() interface using the open database @@ -4216,6 +4267,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite3_stack_used", (Tcl_CmdProc*)test_stack_used }, { "sqlite3_busy_timeout", (Tcl_CmdProc*)test_busy_timeout }, { "printf", (Tcl_CmdProc*)test_printf }, + { "sqlite3_io_trace", (Tcl_CmdProc*)test_io_trace }, }; static struct { char *zName; @@ -4338,6 +4390,10 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ extern int sqlite3_like_count; extern int sqlite3_tsd_count; extern int sqlite3_xferopt_count; + extern int sqlite3_pager_readdb_count; + extern int sqlite3_pager_writedb_count; + extern int sqlite3_pager_writej_count; + extern int sqlite3_pager_pgfree_count; #if OS_UNIX && defined(SQLITE_TEST) && defined(THREADSAFE) && THREADSAFE extern int threadsOverrideEachOthersLocks; #endif @@ -4377,6 +4433,14 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ (char*)&sqlite3_tsd_count, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite3_xferopt_count", (char*)&sqlite3_xferopt_count, TCL_LINK_INT); + Tcl_LinkVar(interp, "sqlite3_pager_readdb_count", + (char*)&sqlite3_pager_readdb_count, TCL_LINK_INT); + Tcl_LinkVar(interp, "sqlite3_pager_writedb_count", + (char*)&sqlite3_pager_writedb_count, TCL_LINK_INT); + Tcl_LinkVar(interp, "sqlite3_pager_writej_count", + (char*)&sqlite3_pager_writej_count, TCL_LINK_INT); + Tcl_LinkVar(interp, "sqlite3_pager_pgfree_count", + (char*)&sqlite3_pager_pgfree_count, TCL_LINK_INT); #ifndef SQLITE_OMIT_UTF16 Tcl_LinkVar(interp, "unaligned_string_counter", (char*)&unaligned_string_counter, TCL_LINK_INT); |
