From: dan Date: Fri, 14 May 2010 08:39:48 +0000 (+0000) Subject: Add xShmXXX methods to test_osinst.c. X-Git-Tag: version-3.7.2~378 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=14740f1cd59edc13444600fc79b34930a8578d96;p=thirdparty%2Fsqlite.git Add xShmXXX methods to test_osinst.c. FossilOrigin-Name: b8a9b37a3c8d1005a16185c1fc4c414ca11d736a --- diff --git a/manifest b/manifest index 61dbec0e0c..d8c4e6c09c 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Make\sdebugging\selements\sof\sthe\ssqlite3_mutex\sobject\svolatile\sand\smake\sthem\nonly\sappear\swhen\scompiling\swith\sSQLITE_DEBUG.\s\sTicket\s[51914f6acd2cb462]. -D 2010-05-13T20:19:17 +C Add\sxShmXXX\smethods\sto\stest_osinst.c. +D 2010-05-14T08:39:48 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -204,7 +201,7 @@ F src/test_loadext.c df586c27176e3c2cb2e099c78da67bf14379a56e F src/test_malloc.c 2842c922b8e8d992aba722214952204ca025b411 F src/test_mutex.c ce06b59aca168cd8c520b77159a24352a7469bd3 F src/test_onefile.c df4d7858b5cd1dffe92d36ec9dbad11f0037ffd1 -F src/test_osinst.c 1a8074514af1ad5154f010ce87776981558bcfd7 +F src/test_osinst.c 06ccd1bcf8193bd80bccbea07c0b2f40ea48bfdb F src/test_pcache.c 7bf828972ac0d2403f5cfa4cd14da41f8ebe73d8 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 F src/test_server.c bbba05c144b5fc4b52ff650a4328027b3fa5fcc6 @@ -766,7 +763,7 @@ F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 F test/vtab_shared.test 0eff9ce4f19facbe0a3e693f6c14b80711a4222d F test/wal.test 7a100918c45872fa19cfb4413299b9afb08727b6 -F test/wal2.test 2eba114ff58f0688278ad45249625af89a0bc9fa +F test/wal2.test 03059bc4d450c37f4b53278ddc3e2c7d53ac2d3f F test/walbak.test a0e45187c7d8928df035dfea29b99b016b21ca3c F test/walcrash.test f6d5fb2bb108876f04848720a488065d9deef69f F test/walfault.test 98df47444944a6db2161eed5cef71d6c00bcb8c3 @@ -817,14 +814,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 175b296f9b9680f605537f52a8a53944deaa5391 -R d5299c39eacf8ef75cb22ef8e896c85b -U drh -Z c4de85f29400b70f3ccfc19d9b6ef1ea ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFL7F7IoxKgR168RlERAl/rAKCJQmVtoXSuuKkoZ5WmLfYvUU8Y6QCePanm -qTdCHBH6Ih1hf+/7njgzXD0= -=TMY3 ------END PGP SIGNATURE----- +P e823c60ca4c3d515b8b12dada4631fe8f44975e9 +R 688705eb72656d22ec89aa9c72974093 +U dan +Z 7259351bee10f369f829692c8f5e1054 diff --git a/manifest.uuid b/manifest.uuid index db34614c8e..ee6ac2cf62 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e823c60ca4c3d515b8b12dada4631fe8f44975e9 \ No newline at end of file +b8a9b37a3c8d1005a16185c1fc4c414ca11d736a \ No newline at end of file diff --git a/src/test_osinst.c b/src/test_osinst.c index f52788b161..f14ab06a4a 100644 --- a/src/test_osinst.c +++ b/src/test_osinst.c @@ -35,6 +35,12 @@ ** ** int sqlite3_vfslog_finalize(const char *zVfs); ** +** ANNOTATING LOG FILES: +** +** To write an arbitrary message into a log file: +** +** int sqlite3_vfslog_annotate(const char *zVfs, const char *zMsg); +** ** READING LOG FILES: ** ** Log files are read using the "vfslog" virtual table implementation @@ -56,7 +62,6 @@ ** size INTEGER, // Bytes read or written ** offset INTEGER // File offset read or written ** ); -** */ #include "sqlite3.h" @@ -75,7 +80,6 @@ */ #define INST_MAX_PATHNAME 512 - #define OS_ACCESS 1 #define OS_CHECKRESERVEDLOCK 2 #define OS_CLOSE 3 @@ -95,16 +99,15 @@ #define OS_TRUNCATE 18 #define OS_UNLOCK 19 #define OS_WRITE 20 +#define OS_SHMOPEN 21 +#define OS_SHMCLOSE 22 +#define OS_SHMGET 23 +#define OS_SHMRELEASE 24 +#define OS_SHMLOCK 25 +#define OS_SHMSIZE 26 +#define OS_ANNOTATE 27 -#define OS_NUMEVENTS 21 - -#define BINARYLOG_STRING 30 -#define BINARYLOG_MARKER 31 - -#define BINARYLOG_PREPARE_V2 64 -#define BINARYLOG_STEP 65 -#define BINARYLOG_FINALIZE 66 - +#define OS_NUMEVENTS 28 #define VFSLOG_BUFFERSIZE 8192 @@ -148,6 +151,13 @@ static int vfslogFileControl(sqlite3_file*, int op, void *pArg); static int vfslogSectorSize(sqlite3_file*); static int vfslogDeviceCharacteristics(sqlite3_file*); +static int vfslogShmOpen(sqlite3_file *pFile); +static int vfslogShmSize(sqlite3_file *pFile, int reqSize, int *pNewSize); +static int vfslogShmGet(sqlite3_file *pFile, int req, int *pSize, void **pp); +static int vfslogShmRelease(sqlite3_file *pFile); +static int vfslogShmLock(sqlite3_file *pFile, int desiredLock, int *gotLock); +static int vfslogShmClose(sqlite3_file *pFile, int deleteFlag); + /* ** Method declarations for vfslog_vfs. */ @@ -164,43 +174,57 @@ static int vfslogSleep(sqlite3_vfs*, int microseconds); static int vfslogCurrentTime(sqlite3_vfs*, double*); static sqlite3_vfs vfslog_vfs = { - 1, /* iVersion */ - sizeof(VfslogFile), /* szOsFile */ - INST_MAX_PATHNAME, /* mxPathname */ - 0, /* pNext */ - 0, /* zName */ - 0, /* pAppData */ - vfslogOpen, /* xOpen */ - vfslogDelete, /* xDelete */ - vfslogAccess, /* xAccess */ - vfslogFullPathname, /* xFullPathname */ - vfslogDlOpen, /* xDlOpen */ - vfslogDlError, /* xDlError */ - vfslogDlSym, /* xDlSym */ - vfslogDlClose, /* xDlClose */ - vfslogRandomness, /* xRandomness */ - vfslogSleep, /* xSleep */ - vfslogCurrentTime, /* xCurrentTime */ + 1, /* iVersion */ + sizeof(VfslogFile), /* szOsFile */ + INST_MAX_PATHNAME, /* mxPathname */ + 0, /* pNext */ + 0, /* zName */ + 0, /* pAppData */ + vfslogOpen, /* xOpen */ + vfslogDelete, /* xDelete */ + vfslogAccess, /* xAccess */ + vfslogFullPathname, /* xFullPathname */ + vfslogDlOpen, /* xDlOpen */ + vfslogDlError, /* xDlError */ + vfslogDlSym, /* xDlSym */ + vfslogDlClose, /* xDlClose */ + vfslogRandomness, /* xRandomness */ + vfslogSleep, /* xSleep */ + vfslogCurrentTime, /* xCurrentTime */ }; static sqlite3_io_methods vfslog_io_methods = { - 1, /* iVersion */ - vfslogClose, /* xClose */ - vfslogRead, /* xRead */ - vfslogWrite, /* xWrite */ - vfslogTruncate, /* xTruncate */ - vfslogSync, /* xSync */ - vfslogFileSize, /* xFileSize */ - vfslogLock, /* xLock */ - vfslogUnlock, /* xUnlock */ - vfslogCheckReservedLock, /* xCheckReservedLock */ - vfslogFileControl, /* xFileControl */ - vfslogSectorSize, /* xSectorSize */ - vfslogDeviceCharacteristics /* xDeviceCharacteristics */ + 2, /* iVersion */ + vfslogClose, /* xClose */ + vfslogRead, /* xRead */ + vfslogWrite, /* xWrite */ + vfslogTruncate, /* xTruncate */ + vfslogSync, /* xSync */ + vfslogFileSize, /* xFileSize */ + vfslogLock, /* xLock */ + vfslogUnlock, /* xUnlock */ + vfslogCheckReservedLock, /* xCheckReservedLock */ + vfslogFileControl, /* xFileControl */ + vfslogSectorSize, /* xSectorSize */ + vfslogDeviceCharacteristics, /* xDeviceCharacteristics */ + vfslogShmOpen, /* xShmOpen */ + vfslogShmSize, /* xShmSize */ + vfslogShmGet, /* xShmGet */ + vfslogShmRelease, /* xShmRelease */ + vfslogShmLock, /* xShmLock */ + vfslogShmClose /* xShmClose */ }; +#include + static sqlite3_uint64 vfslog_time(){ +#if 0 return sqlite3Hwtime(); +#else + struct timeval sTime; + gettimeofday(&sTime, 0); + return sTime.tv_usec + (sqlite3_uint64)sTime.tv_sec * 1000000; +#endif } static void vfslog_call(sqlite3_vfs *, int, int, int, int, int, int); @@ -381,6 +405,68 @@ static int vfslogDeviceCharacteristics(sqlite3_file *pFile){ return rc; } +static int vfslogShmOpen(sqlite3_file *pFile){ + int rc; + sqlite3_uint64 t; + VfslogFile *p = (VfslogFile *)pFile; + t = vfslog_time(); + rc = p->pReal->pMethods->xShmOpen(p->pReal); + t = vfslog_time() - t; + vfslog_call(p->pVfslog, OS_SHMOPEN, p->iFileId, t, rc, 0, 0); + return rc; +} +static int vfslogShmSize(sqlite3_file *pFile, int reqSize, int *pNewSize){ + int rc; + sqlite3_uint64 t; + VfslogFile *p = (VfslogFile *)pFile; + t = vfslog_time(); + rc = p->pReal->pMethods->xShmSize(p->pReal, reqSize, pNewSize); + t = vfslog_time() - t; + vfslog_call(p->pVfslog, OS_SHMSIZE, p->iFileId, t, rc, 0, 0); + return rc; +} +static int vfslogShmGet(sqlite3_file *pFile, int req, int *pSize, void **pp){ + int rc; + sqlite3_uint64 t; + VfslogFile *p = (VfslogFile *)pFile; + t = vfslog_time(); + rc = p->pReal->pMethods->xShmGet(p->pReal, req, pSize, pp); + t = vfslog_time() - t; + vfslog_call(p->pVfslog, OS_SHMGET, p->iFileId, t, rc, 0, 0); + return rc; +} +static int vfslogShmRelease(sqlite3_file *pFile){ + int rc; + sqlite3_uint64 t; + VfslogFile *p = (VfslogFile *)pFile; + t = vfslog_time(); + rc = p->pReal->pMethods->xShmRelease(p->pReal); + t = vfslog_time() - t; + vfslog_call(p->pVfslog, OS_SHMRELEASE, p->iFileId, t, rc, 0, 0); + return rc; +} +static int vfslogShmLock(sqlite3_file *pFile, int desiredLock, int *gotLock){ + int rc; + sqlite3_uint64 t; + VfslogFile *p = (VfslogFile *)pFile; + t = vfslog_time(); + rc = p->pReal->pMethods->xShmLock(p->pReal, desiredLock, gotLock); + t = vfslog_time() - t; + vfslog_call(p->pVfslog, OS_SHMLOCK, p->iFileId, t, rc, 0, 0); + return rc; +} +static int vfslogShmClose(sqlite3_file *pFile, int deleteFlag){ + int rc; + sqlite3_uint64 t; + VfslogFile *p = (VfslogFile *)pFile; + t = vfslog_time(); + rc = p->pReal->pMethods->xShmClose(p->pReal, deleteFlag); + t = vfslog_time() - t; + vfslog_call(p->pVfslog, OS_SHMCLOSE, p->iFileId, t, rc, 0, 0); + return rc; +} + + /* ** Open an vfslog file handle. */ @@ -601,6 +687,7 @@ int sqlite3_vfslog_finalize(const char *zVfs){ if( !pVfs || pVfs->xOpen!=vfslogOpen ){ return SQLITE_ERROR; } + sqlite3_vfs_unregister(pVfs); vfslog_finalize((VfslogVfs *)pVfs); return SQLITE_OK; } @@ -653,6 +740,17 @@ int sqlite3_vfslog_new( return rc; } +int sqlite3_vfslog_annotate(const char *zVfs, const char *zMsg){ + sqlite3_vfs *pVfs; + pVfs = sqlite3_vfs_find(zVfs); + if( !pVfs || pVfs->xOpen!=vfslogOpen ){ + return SQLITE_ERROR; + } + vfslog_call(pVfs, OS_ANNOTATE, 0, 0, 0, 0, 0); + vfslog_string(pVfs, zMsg); + return SQLITE_OK; +} + static const char *vfslog_eventname(int eEvent){ const char *zEvent = 0; @@ -676,6 +774,15 @@ static const char *vfslog_eventname(int eEvent){ case OS_RANDOMNESS: zEvent = "xRandomness"; break; case OS_SLEEP: zEvent = "xSleep"; break; case OS_CURRENTTIME: zEvent = "xCurrentTime"; break; + + case OS_SHMCLOSE: zEvent = "xShmClose"; break; + case OS_SHMOPEN: zEvent = "xShmOpen"; break; + case OS_SHMGET: zEvent = "xShmGet"; break; + case OS_SHMSIZE: zEvent = "xShmSize"; break; + case OS_SHMRELEASE: zEvent = "xShmRelease"; break; + case OS_SHMLOCK: zEvent = "xShmLock"; break; + + case OS_ANNOTATE: zEvent = "annotation"; break; } return zEvent; @@ -981,7 +1088,7 @@ int sqlite3_vfslog_register(sqlite3 *db){ ** Tcl interface starts here. */ -#ifdef SQLITE_TEST +#if defined(SQLITE_TEST) || defined(TCLSH) #include @@ -996,8 +1103,8 @@ static int test_vfslog( Tcl_CmdInfo cmdInfo; int rc = SQLITE_ERROR; - static const char *strs[] = { "finalize", "new", "register", 0 }; - enum VL_enum { VL_FINALIZE, VL_NEW, VL_REGISTER }; + static const char *strs[] = { "annotate", "finalize", "new", "register", 0 }; + enum VL_enum { VL_ANNOTATE, VL_FINALIZE, VL_NEW, VL_REGISTER }; int iSub; if( objc<2 ){ @@ -1009,6 +1116,23 @@ static int test_vfslog( } switch( (enum VL_enum)iSub ){ + case VL_ANNOTATE: { + int rc; + char *zVfs; + char *zMsg; + if( objc!=4 ){ + Tcl_WrongNumArgs(interp, 3, objv, "VFS"); + return TCL_ERROR; + } + zVfs = Tcl_GetString(objv[2]); + zMsg = Tcl_GetString(objv[3]); + rc = sqlite3_vfslog_annotate(zVfs, zMsg); + if( rc!=SQLITE_OK ){ + Tcl_AppendResult(interp, "failed", 0); + return TCL_ERROR; + } + break; + } case VL_FINALIZE: { int rc; char *zVfs; diff --git a/test/wal2.test b/test/wal2.test index 781482801e..b8fe5fc4da 100644 --- a/test/wal2.test +++ b/test/wal2.test @@ -588,6 +588,18 @@ do_test wal2-6.5.1 { PRAGMA journal_mode; } } {wal exclusive wal} +do_test wal2-6.5.2 { + execsql { + PRAGMA locking_mode = normal; + INSERT INTO t2 VALUES('III', 'IV'); + PRAGMA locking_mode = exclusive; + SELECT * FROM t2; + } +} {normal exclusive I II III IV} +do_test wal2-6.5.3 { + execsql { PRAGMA wal_checkpoint } +} {} + db close finish_test