sl@0: /* sl@0: ** 2001 September 15 sl@0: ** sl@0: ** The author disclaims copyright to this source code. In place of sl@0: ** a legal notice, here is a blessing: sl@0: ** sl@0: ** May you do good and not evil. sl@0: ** May you find forgiveness for yourself and forgive others. sl@0: ** May you share freely, never taking more than you give. sl@0: ** sl@0: ************************************************************************* sl@0: ** Code for testing the pager.c module in SQLite. This code sl@0: ** is not included in the SQLite library. It is used for automated sl@0: ** testing of the SQLite library. sl@0: ** sl@0: ** $Id: test2.c,v 1.62 2008/09/29 11:49:48 danielk1977 Exp $ sl@0: */ sl@0: #include "sqliteInt.h" sl@0: #include "tcl.h" sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: /* sl@0: ** Interpret an SQLite error number sl@0: */ sl@0: static char *errorName(int rc){ sl@0: char *zName; sl@0: switch( rc ){ sl@0: case SQLITE_OK: zName = "SQLITE_OK"; break; sl@0: case SQLITE_ERROR: zName = "SQLITE_ERROR"; break; sl@0: case SQLITE_PERM: zName = "SQLITE_PERM"; break; sl@0: case SQLITE_ABORT: zName = "SQLITE_ABORT"; break; sl@0: case SQLITE_BUSY: zName = "SQLITE_BUSY"; break; sl@0: case SQLITE_NOMEM: zName = "SQLITE_NOMEM"; break; sl@0: case SQLITE_READONLY: zName = "SQLITE_READONLY"; break; sl@0: case SQLITE_INTERRUPT: zName = "SQLITE_INTERRUPT"; break; sl@0: case SQLITE_IOERR: zName = "SQLITE_IOERR"; break; sl@0: case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break; sl@0: case SQLITE_FULL: zName = "SQLITE_FULL"; break; sl@0: case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break; sl@0: case SQLITE_PROTOCOL: zName = "SQLITE_PROTOCOL"; break; sl@0: case SQLITE_EMPTY: zName = "SQLITE_EMPTY"; break; sl@0: case SQLITE_SCHEMA: zName = "SQLITE_SCHEMA"; break; sl@0: case SQLITE_CONSTRAINT: zName = "SQLITE_CONSTRAINT"; break; sl@0: case SQLITE_MISMATCH: zName = "SQLITE_MISMATCH"; break; sl@0: case SQLITE_MISUSE: zName = "SQLITE_MISUSE"; break; sl@0: case SQLITE_NOLFS: zName = "SQLITE_NOLFS"; break; sl@0: default: zName = "SQLITE_Unknown"; break; sl@0: } sl@0: return zName; sl@0: } sl@0: sl@0: /* sl@0: ** Page size and reserved size used for testing. sl@0: */ sl@0: static int test_pagesize = 1024; sl@0: sl@0: /* sl@0: ** Usage: pager_open FILENAME N-PAGE sl@0: ** sl@0: ** Open a new pager sl@0: */ sl@0: static int pager_open( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: u16 pageSize; sl@0: Pager *pPager; sl@0: int nPage; sl@0: int rc; sl@0: char zBuf[100]; sl@0: if( argc!=3 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " FILENAME N-PAGE\"", 0); sl@0: return TCL_ERROR; sl@0: } sl@0: if( Tcl_GetInt(interp, argv[2], &nPage) ) return TCL_ERROR; sl@0: rc = sqlite3PagerOpen(sqlite3_vfs_find(0), &pPager, argv[1], 0, 0, sl@0: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MAIN_DB); sl@0: if( rc!=SQLITE_OK ){ sl@0: Tcl_AppendResult(interp, errorName(rc), 0); sl@0: return TCL_ERROR; sl@0: } sl@0: sqlite3PagerSetCachesize(pPager, nPage); sl@0: pageSize = test_pagesize; sl@0: sqlite3PagerSetPagesize(pPager, &pageSize); sl@0: sqlite3_snprintf(sizeof(zBuf),zBuf,"%p",pPager); sl@0: Tcl_AppendResult(interp, zBuf, 0); sl@0: return TCL_OK; sl@0: } sl@0: sl@0: /* sl@0: ** Usage: pager_close ID sl@0: ** sl@0: ** Close the given pager. sl@0: */ sl@0: static int pager_close( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: Pager *pPager; sl@0: int rc; sl@0: if( argc!=2 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " ID\"", 0); sl@0: return TCL_ERROR; sl@0: } sl@0: pPager = sqlite3TestTextToPtr(argv[1]); sl@0: rc = sqlite3PagerClose(pPager); sl@0: if( rc!=SQLITE_OK ){ sl@0: Tcl_AppendResult(interp, errorName(rc), 0); sl@0: return TCL_ERROR; sl@0: } sl@0: return TCL_OK; sl@0: } sl@0: sl@0: /* sl@0: ** Usage: pager_rollback ID sl@0: ** sl@0: ** Rollback changes sl@0: */ sl@0: static int pager_rollback( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: Pager *pPager; sl@0: int rc; sl@0: if( argc!=2 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " ID\"", 0); sl@0: return TCL_ERROR; sl@0: } sl@0: pPager = sqlite3TestTextToPtr(argv[1]); sl@0: rc = sqlite3PagerRollback(pPager); sl@0: if( rc!=SQLITE_OK ){ sl@0: Tcl_AppendResult(interp, errorName(rc), 0); sl@0: return TCL_ERROR; sl@0: } sl@0: return TCL_OK; sl@0: } sl@0: sl@0: /* sl@0: ** Usage: pager_commit ID sl@0: ** sl@0: ** Commit all changes sl@0: */ sl@0: static int pager_commit( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: Pager *pPager; sl@0: int rc; sl@0: if( argc!=2 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " ID\"", 0); sl@0: return TCL_ERROR; sl@0: } sl@0: pPager = sqlite3TestTextToPtr(argv[1]); sl@0: rc = sqlite3PagerCommitPhaseOne(pPager, 0, 0, 0); sl@0: if( rc!=SQLITE_OK ){ sl@0: Tcl_AppendResult(interp, errorName(rc), 0); sl@0: return TCL_ERROR; sl@0: } sl@0: rc = sqlite3PagerCommitPhaseTwo(pPager); sl@0: if( rc!=SQLITE_OK ){ sl@0: Tcl_AppendResult(interp, errorName(rc), 0); sl@0: return TCL_ERROR; sl@0: } sl@0: return TCL_OK; sl@0: } sl@0: sl@0: /* sl@0: ** Usage: pager_stmt_begin ID sl@0: ** sl@0: ** Start a new checkpoint. sl@0: */ sl@0: static int pager_stmt_begin( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: Pager *pPager; sl@0: int rc; sl@0: if( argc!=2 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " ID\"", 0); sl@0: return TCL_ERROR; sl@0: } sl@0: pPager = sqlite3TestTextToPtr(argv[1]); sl@0: rc = sqlite3PagerStmtBegin(pPager); sl@0: if( rc!=SQLITE_OK ){ sl@0: Tcl_AppendResult(interp, errorName(rc), 0); sl@0: return TCL_ERROR; sl@0: } sl@0: return TCL_OK; sl@0: } sl@0: sl@0: /* sl@0: ** Usage: pager_stmt_rollback ID sl@0: ** sl@0: ** Rollback changes to a checkpoint sl@0: */ sl@0: static int pager_stmt_rollback( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: Pager *pPager; sl@0: int rc; sl@0: if( argc!=2 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " ID\"", 0); sl@0: return TCL_ERROR; sl@0: } sl@0: pPager = sqlite3TestTextToPtr(argv[1]); sl@0: rc = sqlite3PagerStmtRollback(pPager); sl@0: if( rc!=SQLITE_OK ){ sl@0: Tcl_AppendResult(interp, errorName(rc), 0); sl@0: return TCL_ERROR; sl@0: } sl@0: return TCL_OK; sl@0: } sl@0: sl@0: /* sl@0: ** Usage: pager_stmt_commit ID sl@0: ** sl@0: ** Commit changes to a checkpoint sl@0: */ sl@0: static int pager_stmt_commit( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: Pager *pPager; sl@0: int rc; sl@0: if( argc!=2 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " ID\"", 0); sl@0: return TCL_ERROR; sl@0: } sl@0: pPager = sqlite3TestTextToPtr(argv[1]); sl@0: rc = sqlite3PagerStmtCommit(pPager); sl@0: if( rc!=SQLITE_OK ){ sl@0: Tcl_AppendResult(interp, errorName(rc), 0); sl@0: return TCL_ERROR; sl@0: } sl@0: return TCL_OK; sl@0: } sl@0: sl@0: /* sl@0: ** Usage: pager_stats ID sl@0: ** sl@0: ** Return pager statistics. sl@0: */ sl@0: static int pager_stats( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: Pager *pPager; sl@0: int i, *a; sl@0: if( argc!=2 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " ID\"", 0); sl@0: return TCL_ERROR; sl@0: } sl@0: pPager = sqlite3TestTextToPtr(argv[1]); sl@0: a = sqlite3PagerStats(pPager); sl@0: for(i=0; i<9; i++){ sl@0: static char *zName[] = { sl@0: "ref", "page", "max", "size", "state", "err", sl@0: "hit", "miss", "ovfl", sl@0: }; sl@0: char zBuf[100]; sl@0: Tcl_AppendElement(interp, zName[i]); sl@0: sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",a[i]); sl@0: Tcl_AppendElement(interp, zBuf); sl@0: } sl@0: return TCL_OK; sl@0: } sl@0: sl@0: /* sl@0: ** Usage: pager_pagecount ID sl@0: ** sl@0: ** Return the size of the database file. sl@0: */ sl@0: static int pager_pagecount( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: Pager *pPager; sl@0: char zBuf[100]; sl@0: int nPage; sl@0: if( argc!=2 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " ID\"", 0); sl@0: return TCL_ERROR; sl@0: } sl@0: pPager = sqlite3TestTextToPtr(argv[1]); sl@0: sqlite3PagerPagecount(pPager, &nPage); sl@0: sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", nPage); sl@0: Tcl_AppendResult(interp, zBuf, 0); sl@0: return TCL_OK; sl@0: } sl@0: sl@0: /* sl@0: ** Usage: page_get ID PGNO sl@0: ** sl@0: ** Return a pointer to a page from the database. sl@0: */ sl@0: static int page_get( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: Pager *pPager; sl@0: char zBuf[100]; sl@0: DbPage *pPage; sl@0: int pgno; sl@0: int rc; sl@0: if( argc!=3 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " ID PGNO\"", 0); sl@0: return TCL_ERROR; sl@0: } sl@0: pPager = sqlite3TestTextToPtr(argv[1]); sl@0: if( Tcl_GetInt(interp, argv[2], &pgno) ) return TCL_ERROR; sl@0: rc = sqlite3PagerGet(pPager, pgno, &pPage); sl@0: if( rc!=SQLITE_OK ){ sl@0: Tcl_AppendResult(interp, errorName(rc), 0); sl@0: return TCL_ERROR; sl@0: } sl@0: sqlite3_snprintf(sizeof(zBuf),zBuf,"%p",pPage); sl@0: Tcl_AppendResult(interp, zBuf, 0); sl@0: return TCL_OK; sl@0: } sl@0: sl@0: /* sl@0: ** Usage: page_lookup ID PGNO sl@0: ** sl@0: ** Return a pointer to a page if the page is already in cache. sl@0: ** If not in cache, return an empty string. sl@0: */ sl@0: static int page_lookup( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: Pager *pPager; sl@0: char zBuf[100]; sl@0: DbPage *pPage; sl@0: int pgno; sl@0: if( argc!=3 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " ID PGNO\"", 0); sl@0: return TCL_ERROR; sl@0: } sl@0: pPager = sqlite3TestTextToPtr(argv[1]); sl@0: if( Tcl_GetInt(interp, argv[2], &pgno) ) return TCL_ERROR; sl@0: pPage = sqlite3PagerLookup(pPager, pgno); sl@0: if( pPage ){ sl@0: sqlite3_snprintf(sizeof(zBuf),zBuf,"%p",pPage); sl@0: Tcl_AppendResult(interp, zBuf, 0); sl@0: } sl@0: return TCL_OK; sl@0: } sl@0: sl@0: /* sl@0: ** Usage: pager_truncate ID PGNO sl@0: */ sl@0: static int pager_truncate( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: Pager *pPager; sl@0: int rc; sl@0: int pgno; sl@0: if( argc!=3 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " ID PGNO\"", 0); sl@0: return TCL_ERROR; sl@0: } sl@0: pPager = sqlite3TestTextToPtr(argv[1]); sl@0: if( Tcl_GetInt(interp, argv[2], &pgno) ) return TCL_ERROR; sl@0: rc = sqlite3PagerTruncate(pPager, pgno); sl@0: if( rc!=SQLITE_OK ){ sl@0: Tcl_AppendResult(interp, errorName(rc), 0); sl@0: return TCL_ERROR; sl@0: } sl@0: return TCL_OK; sl@0: } sl@0: sl@0: sl@0: /* sl@0: ** Usage: page_unref PAGE sl@0: ** sl@0: ** Drop a pointer to a page. sl@0: */ sl@0: static int page_unref( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: DbPage *pPage; sl@0: int rc; sl@0: if( argc!=2 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " PAGE\"", 0); sl@0: return TCL_ERROR; sl@0: } sl@0: pPage = (DbPage *)sqlite3TestTextToPtr(argv[1]); sl@0: rc = sqlite3PagerUnref(pPage); sl@0: if( rc!=SQLITE_OK ){ sl@0: Tcl_AppendResult(interp, errorName(rc), 0); sl@0: return TCL_ERROR; sl@0: } sl@0: return TCL_OK; sl@0: } sl@0: sl@0: /* sl@0: ** Usage: page_read PAGE sl@0: ** sl@0: ** Return the content of a page sl@0: */ sl@0: static int page_read( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: char zBuf[100]; sl@0: DbPage *pPage; sl@0: if( argc!=2 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " PAGE\"", 0); sl@0: return TCL_ERROR; sl@0: } sl@0: pPage = sqlite3TestTextToPtr(argv[1]); sl@0: memcpy(zBuf, sqlite3PagerGetData(pPage), sizeof(zBuf)); sl@0: Tcl_AppendResult(interp, zBuf, 0); sl@0: return TCL_OK; sl@0: } sl@0: sl@0: /* sl@0: ** Usage: page_number PAGE sl@0: ** sl@0: ** Return the page number for a page. sl@0: */ sl@0: static int page_number( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: char zBuf[100]; sl@0: DbPage *pPage; sl@0: if( argc!=2 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " PAGE\"", 0); sl@0: return TCL_ERROR; sl@0: } sl@0: pPage = (DbPage *)sqlite3TestTextToPtr(argv[1]); sl@0: sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", sqlite3PagerPagenumber(pPage)); sl@0: Tcl_AppendResult(interp, zBuf, 0); sl@0: return TCL_OK; sl@0: } sl@0: sl@0: /* sl@0: ** Usage: page_write PAGE DATA sl@0: ** sl@0: ** Write something into a page. sl@0: */ sl@0: static int page_write( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: DbPage *pPage; sl@0: char *pData; sl@0: int rc; sl@0: if( argc!=3 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " PAGE DATA\"", 0); sl@0: return TCL_ERROR; sl@0: } sl@0: pPage = (DbPage *)sqlite3TestTextToPtr(argv[1]); sl@0: rc = sqlite3PagerWrite(pPage); sl@0: if( rc!=SQLITE_OK ){ sl@0: Tcl_AppendResult(interp, errorName(rc), 0); sl@0: return TCL_ERROR; sl@0: } sl@0: pData = sqlite3PagerGetData(pPage); sl@0: strncpy(pData, argv[2], test_pagesize-1); sl@0: pData[test_pagesize-1] = 0; sl@0: return TCL_OK; sl@0: } sl@0: sl@0: #ifndef SQLITE_OMIT_DISKIO sl@0: /* sl@0: ** Usage: fake_big_file N FILENAME sl@0: ** sl@0: ** Write a few bytes at the N megabyte point of FILENAME. This will sl@0: ** create a large file. If the file was a valid SQLite database, then sl@0: ** the next time the database is opened, SQLite will begin allocating sl@0: ** new pages after N. If N is 2096 or bigger, this will test the sl@0: ** ability of SQLite to write to large files. sl@0: */ sl@0: static int fake_big_file( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: sqlite3_vfs *pVfs; sl@0: sqlite3_file *fd = 0; sl@0: int rc; sl@0: int n; sl@0: i64 offset; sl@0: if( argc!=3 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " N-MEGABYTES FILE\"", 0); sl@0: return TCL_ERROR; sl@0: } sl@0: if( Tcl_GetInt(interp, argv[1], &n) ) return TCL_ERROR; sl@0: sl@0: pVfs = sqlite3_vfs_find(0); sl@0: rc = sqlite3OsOpenMalloc(pVfs, argv[2], &fd, sl@0: (SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB), 0 sl@0: ); sl@0: if( rc ){ sl@0: Tcl_AppendResult(interp, "open failed: ", errorName(rc), 0); sl@0: return TCL_ERROR; sl@0: } sl@0: offset = n; sl@0: offset *= 1024*1024; sl@0: rc = sqlite3OsWrite(fd, "Hello, World!", 14, offset); sl@0: sqlite3OsCloseFree(fd); sl@0: if( rc ){ sl@0: Tcl_AppendResult(interp, "write failed: ", errorName(rc), 0); sl@0: return TCL_ERROR; sl@0: } sl@0: return TCL_OK; sl@0: } sl@0: #endif sl@0: sl@0: sl@0: /* sl@0: ** sqlite3BitvecBuiltinTest SIZE PROGRAM sl@0: ** sl@0: ** Invoke the SQLITE_TESTCTRL_BITVEC_TEST operator on test_control. sl@0: ** See comments on sqlite3BitvecBuiltinTest() for additional information. sl@0: */ sl@0: static int testBitvecBuiltinTest( sl@0: void *NotUsed, sl@0: Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ sl@0: int argc, /* Number of arguments */ sl@0: const char **argv /* Text of each argument */ sl@0: ){ sl@0: int sz, rc; sl@0: int nProg = 0; sl@0: int aProg[100]; sl@0: const char *z; sl@0: if( argc!=3 ){ sl@0: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], sl@0: " SIZE PROGRAM\"", (void*)0); sl@0: } sl@0: if( Tcl_GetInt(interp, argv[1], &sz) ) return TCL_ERROR; sl@0: z = argv[2]; sl@0: while( nProg<99 && *z ){ sl@0: while( *z && !isdigit(*z) ){ z++; } sl@0: if( *z==0 ) break; sl@0: aProg[nProg++] = atoi(z); sl@0: while( isdigit(*z) ){ z++; } sl@0: } sl@0: aProg[nProg] = 0; sl@0: rc = sqlite3_test_control(SQLITE_TESTCTRL_BITVEC_TEST, sz, aProg); sl@0: Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); sl@0: return TCL_OK; sl@0: } sl@0: sl@0: /* sl@0: ** Register commands with the TCL interpreter. sl@0: */ sl@0: int Sqlitetest2_Init(Tcl_Interp *interp){ sl@0: extern int sqlite3_io_error_persist; sl@0: extern int sqlite3_io_error_pending; sl@0: extern int sqlite3_io_error_hit; sl@0: extern int sqlite3_io_error_hardhit; sl@0: extern int sqlite3_diskfull_pending; sl@0: extern int sqlite3_diskfull; sl@0: extern int sqlite3_pager_n_sort_bucket; sl@0: static struct { sl@0: char *zName; sl@0: Tcl_CmdProc *xProc; sl@0: } aCmd[] = { sl@0: { "pager_open", (Tcl_CmdProc*)pager_open }, sl@0: { "pager_close", (Tcl_CmdProc*)pager_close }, sl@0: { "pager_commit", (Tcl_CmdProc*)pager_commit }, sl@0: { "pager_rollback", (Tcl_CmdProc*)pager_rollback }, sl@0: { "pager_stmt_begin", (Tcl_CmdProc*)pager_stmt_begin }, sl@0: { "pager_stmt_commit", (Tcl_CmdProc*)pager_stmt_commit }, sl@0: { "pager_stmt_rollback", (Tcl_CmdProc*)pager_stmt_rollback }, sl@0: { "pager_stats", (Tcl_CmdProc*)pager_stats }, sl@0: { "pager_pagecount", (Tcl_CmdProc*)pager_pagecount }, sl@0: { "page_get", (Tcl_CmdProc*)page_get }, sl@0: { "page_lookup", (Tcl_CmdProc*)page_lookup }, sl@0: { "page_unref", (Tcl_CmdProc*)page_unref }, sl@0: { "page_read", (Tcl_CmdProc*)page_read }, sl@0: { "page_write", (Tcl_CmdProc*)page_write }, sl@0: { "page_number", (Tcl_CmdProc*)page_number }, sl@0: { "pager_truncate", (Tcl_CmdProc*)pager_truncate }, sl@0: #ifndef SQLITE_OMIT_DISKIO sl@0: { "fake_big_file", (Tcl_CmdProc*)fake_big_file }, sl@0: #endif sl@0: { "sqlite3BitvecBuiltinTest",(Tcl_CmdProc*)testBitvecBuiltinTest}, sl@0: }; sl@0: int i; sl@0: for(i=0; i