diff --git a/manifest b/manifest index 69246e10a1..4839a43a3c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Clear\sa\sglobal\svariable\sin\sthe\sincrblob.test\sscript.\s\sTicket\s#3062.\s(CVS\s5021) -D 2008-04-16T23:39:26 +C Add\sthe\s-overwrite\soption\sto\sspeedtest8.c.\s(CVS\s5022) +D 2008-04-16T23:50:24 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.in 25b3282a4ac39388632c2fb0e044ff494d490952 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -572,7 +572,7 @@ F tool/spaceanal.tcl b87db46ae29e3116411b1686e136b9b994d7de39 F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 F tool/speedtest16.c 6f5bc019dcf8b6537f379bbac0408a9e1a86f0b6 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff -F tool/speedtest8.c c0b2587ce87e9e67db7e926d43eba864a53d7b1b +F tool/speedtest8.c fd53bf13c7bbea4671faa2222cbb3286c14200f8 F tool/speedtest8inst1.c 025879132979a5fdec11218472cba6cf8f6ec854 F www/34to35.tcl 942e479aa7740b55d714dce0f0b2cb6ca91c3f20 F www/arch.fig d5f9752a4dbf242e9cfffffd3f5762b6c63b3bcf @@ -632,7 +632,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P 7c094c80b2439480ffc680b2d63031d1033b266a -R 16c0b96c72bfdde54b6efada37047b9d +P 1c19854ae7790a8a1d5c9cfe8b2cb71e2c19ce50 +R aefba1bd9f7f39d7f799ac7524bcfdfa U drh -Z cdd92c3ad1b7a3d9eaa79035050e2ddb +Z fa920ea88ca3b0e0f21121fc24e21171 diff --git a/manifest.uuid b/manifest.uuid index aba3e3d807..a1fec0825e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1c19854ae7790a8a1d5c9cfe8b2cb71e2c19ce50 \ No newline at end of file +6765ea52b33270a323c620b060cffd4f59004db1 \ No newline at end of file diff --git a/tool/speedtest8.c b/tool/speedtest8.c index 844ba34856..43d77f2415 100644 --- a/tool/speedtest8.c +++ b/tool/speedtest8.c @@ -81,6 +81,89 @@ static void prepareAndRun(sqlite3 *db, const char *zSql){ } } +/*************************************************************************** +** The "overwrite" VFS is an overlay over the default VFS. It modifies +** the xTruncate operation on journal files so that xTruncate merely +** writes zeros into the first 50 bytes of the file rather than truely +** truncating the file. +** +** The following variables are initialized to be the virtual function +** tables for the overwrite VFS. +*/ +static sqlite3_vfs overwrite_vfs; +static sqlite3_io_methods overwrite_methods; + +/* +** The truncate method for journal files in the overwrite VFS. +*/ +static int overwriteTruncate(sqlite3_file *pFile, sqlite_int64 size){ + int rc; + static const char buf[50]; + if( size ){ + return SQLITE_IOERR; + } + rc = pFile->pMethods->xWrite(pFile, buf, sizeof(buf), 0); + if( rc==SQLITE_OK ){ + rc = pFile->pMethods->xSync(pFile, SQLITE_SYNC_NORMAL); + } + return rc; +} + +/* +** The delete method for journal files in the overwrite VFS. +*/ +static int overwriteDelete(sqlite3_file *pFile){ + return overwriteTruncate(pFile, 0); +} + +/* +** The open method for overwrite VFS. If the file being opened is +** a journal file then substitute the alternative xTruncate method. +*/ +static int overwriteOpen( + sqlite3_vfs *pVfs, + const char *zName, + sqlite3_file *pFile, + int flags, + int *pOutFlags +){ + int rc; + sqlite3_vfs *pRealVfs; + int isJournal; + + isJournal = (flags & (SQLITE_OPEN_MAIN_JOURNAL|SQLITE_OPEN_TEMP_JOURNAL))!=0; + pRealVfs = (sqlite3_vfs*)pVfs->pAppData; + rc = pRealVfs->xOpen(pRealVfs, zName, pFile, flags, pOutFlags); + if( rc==SQLITE_OK && isJournal ){ + if( overwrite_methods.xTruncate==0 ){ + sqlite3_io_methods temp; + memcpy(&temp, pFile->pMethods, sizeof(temp)); + temp.xTruncate = overwriteTruncate; + memcpy(&overwrite_methods, &temp, sizeof(temp)); + } + pFile->pMethods = &overwrite_methods; + } + return rc; +} + +/* +** Overlay the overwrite VFS over top of the current default VFS +** and make the overlay VFS the new default. +** +** This routine can only be evaluated once. On second and subsequent +** executions it becomes a no-op. +*/ +static void registerOverwriteVfs(void){ + sqlite3_vfs *pBase; + if( overwrite_vfs.iVersion ) return; + pBase = sqlite3_vfs_find(0); + memcpy(&overwrite_vfs, pBase, sizeof(overwrite_vfs)); + overwrite_vfs.pAppData = pBase; + overwrite_vfs.xOpen = overwriteOpen; + overwrite_vfs.zName = "overwriteVfs"; + sqlite3_vfs_register(&overwrite_vfs, 1); +} + int main(int argc, char **argv){ sqlite3 *db; int rc; @@ -92,32 +175,42 @@ int main(int argc, char **argv){ unsigned long long int iSetup = 0; int nStmt = 0; int nByte = 0; + const char *zArgv0 = argv[0]; #ifdef HAVE_OSINST extern sqlite3_vfs *sqlite3_instvfs_binarylog(char *, char *, char *); extern void sqlite3_instvfs_destroy(sqlite3_vfs *); - sqlite3_vfs *pVfs = 0; - if( argc!=3 && (argc!=5 || strcmp("-log", argv[1])) ){ - fprintf(stderr, "Usage: %s ?-log LOGFILE? FILENAME SQL-SCRIPT\n" - "Runs SQL-SCRIPT against a UTF8 database\n", - argv[0]); - exit(1); +#endif + + if( argc>=4 && strcmp(argv[1], "-overwrite")==0 ){ + registerOverwriteVfs(); + argv++; + argc--; } - if( argc==5 ){ + +#ifdef HAVE_OSINST + if( argc>=5 && strcmp(argv[1], "-log")==0 ){ pVfs = sqlite3_instvfs_binarylog("oslog", 0, argv[2]); sqlite3_vfs_register(pVfs, 1); argv += 2; - } -#else - if( argc!=3 ){ - fprintf(stderr, "Usage: %s FILENAME SQL-SCRIPT\n" - "Runs SQL-SCRIPT against a UTF8 database\n", - argv[0]); - exit(1); + argc -= 2; } #endif + if( argc>=4 && strcmp(argv[1], "-overwrite")==0 ){ + registerOverwriteVfs(); + argv++; + argc--; + } + + if( argc!=3 ){ + fprintf(stderr, "Usage: %s [options] FILENAME SQL-SCRIPT\n" + "Runs SQL-SCRIPT against a UTF8 database\n", + zArgv0); + exit(1); + } + in = fopen(argv[2], "r"); fseek(in, 0L, SEEK_END); nSql = ftell(in); @@ -144,8 +237,10 @@ int main(int argc, char **argv){ zSql[j] = 0; while( i=6 && memcmp(&zSql[i], ".crash",6)==0 ) exit(1); nStmt++; - nByte += j-i; + nByte += n; prepareAndRun(db, &zSql[i]); } zSql[j] = ';';