-C Add\scomment\sexplaining\schecksum\smechanism.
-D 2010-04-24T19:07:29
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+C Begin\smoving\sWAL-specific\sI/O\sinto\sthe\sVFS.\s\sThis\scheckin\scontains\sVFS\ninfrastructure\sbut\sit\sis\suntested\sand\sis\snot\syet\shooked\sup\sto\sthe\sWAL.\nThe\sversion\snumber\sis\sbumped\sto\s3.7.0\sbecause\sof\sthe\sVFS\sextension.
+D 2010-04-26T00:04:55
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F Makefile.vxworks ab005d301296c40e021ccd0133ce49ca811e319f
F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6
-F VERSION 3e18b3dd7290883913c25d66c0ddb409ce318654
+F VERSION 4dce4379514b12d6bc5c30f7d1f64582ccb4f412
F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50
F addopcodes.awk 17dc593f791f874d2c23a0f9360850ded0286531
F art/2005osaward.gif 0d1851b2a7c1c9d0ccce545f3e14bca42d7fd248
F src/os.c 8bc63cf91e9802e2b807198e54e50227fa889306
F src/os.h 534b082c3cb349ad05fa6fa0b06087e022af282c
F src/os_common.h 240c88b163b02c21a9f21f87d49678a0aa21ff30
-F src/os_os2.c 75a8c7b9a00a2cf1a65f9fa4afbc27d46634bb2f
-F src/os_unix.c 5bf0015cebe2f21635da2af983c348eb88b3b4c1
-F src/os_win.c 1c7453c2df4dab26d90ff6f91272aea18bcf7053
+F src/os_os2.c 082884dc2a20a2f1fddc404f3606ec2abe907b56
+F src/os_unix.c 1acc854259b045cf029c6f95828a5f4b84f361c7
+F src/os_win.c 607b40e40662c6c74ff2400ff03e7f42521d5c75
F src/pager.c 9da40bb50d2baa8f7cbb18579f147b7623856211
F src/pager.h cee4487ab4f0911dd9f22a40e3cd55afdb7ef444
F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
F src/select.c b7c9a40bc1567bceff52ad4b73108734ee4bf268
F src/shell.c c40427c7245535a04a9cb4a417b6cc05c022e6a4
-F src/sqlite.h.in b9b0365613d4a99a0e6bc0ae6dbc73cc4a7e7cb7
+F src/sqlite.h.in 96b0bed7825da354119a9742a83033087c537133
F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89
F src/sqliteInt.h de668d16e73ef456b940ab3f60b2ac8842957853
F src/sqliteLimit.h 3afab2291762b5d09ae20c18feb8e9fa935a60a6
F src/test3.c 4c21700c73a890a47fc685c1097bfb661346ac94
F src/test4.c ad03bb987ddedce928f4258c1e7fa4109a73497d
F src/test5.c cc55900118fa4add8ec9cf69fc4225a4662f76b1
-F src/test6.c a8ece4284d0e34477f349ac05655db73c48e0926
+F src/test6.c d23fc84954751735bcb1050d4606b00952eb7809
F src/test7.c 3f2d63e4ccf97f8c2cf1a7fa0a3c8e2e2a354e6e
F src/test8.c f959db9a22d882013b64c92753fa793b2ce3bdea
F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60
F src/test_backup.c c129c91127e9b46e335715ae2e75756e25ba27de
F src/test_btree.c 47cd771250f09cdc6e12dda5bc71bc0b3abc96e2
F src/test_config.c 8c408fbffbe8082d1d3dc55044ddfd5580f3c9b9
-F src/test_demovfs.c 301a047287021940136a3a52d2366dc51f8072d5
-F src/test_devsym.c 3adf69c716e5c90bf5b7a1afe817e3ecac1adf6f
+F src/test_demovfs.c 68f8e6cfd6b337612e26b7027f97bf7ea02d4e04
+F src/test_devsym.c 76f47435769168fb665828f5cc24a4a0a130c302
F src/test_func.c 13b582345fb1185a93e46c53310fae8547dcce20
F src/test_hexio.c 1237f000ec7a491009b1233f5c626ea71bce1ea2
F src/test_init.c 5d624ffd0409d424cf9adbfe1f056b200270077c
F src/test_intarray.c d879bbf8e4ce085ab966d1f3c896a7c8b4f5fc99
F src/test_intarray.h 489edb9068bb926583445cb02589344961054207
-F src/test_journal.c adc0ce3840ed19b49feb1d583b2212f560ef7866
+F src/test_journal.c 6f2db1b847929791242e32323721c48c7d2d6e0c
F src/test_loadext.c df586c27176e3c2cb2e099c78da67bf14379a56e
F src/test_malloc.c 2842c922b8e8d992aba722214952204ca025b411
F src/test_mutex.c ce06b59aca168cd8c520b77159a24352a7469bd3
-F src/test_onefile.c 06da7e085dce42924cf062b91763dd4bb84c6101
-F src/test_osinst.c 90fb03d396f39956897dfb4bd0e62c6711db1cca
+F src/test_onefile.c 1d098e7446d89087def7d20e0cdb77a0713ed1bf
+F src/test_osinst.c 79a9b9fdb87fccd7fdc2f523bfbb91f964bafa68
F src/test_pcache.c 7bf828972ac0d2403f5cfa4cd14da41f8ebe73d8
F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0
F src/test_server.c bbba05c144b5fc4b52ff650a4328027b3fa5fcc6
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 31215969f59be536fe87431bb9fbfa7d13027e35
-R 1d48ccc5eb3586f62961518732858aa1
-U dan
-Z d82402bdae4dea648cb0a1aad66c722d
+P 3e9ef5153ebf0543ad0f75a7561f73d22171da53
+R d0d00cdfe34b5188edd49187f65dd4f0
+U drh
+Z a55984eccf1af95745f2d144e70469ac
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.6 (GNU/Linux)
+
+iD8DBQFL1NiqoxKgR168RlERAkSGAKCMwxXVaj6pJFUojxgq8jkWD5q0bgCfXZsd
+BjC57GjZtQKSf+QHQLj1hP0=
+=LyL/
+-----END PGP SIGNATURE-----
-3e9ef5153ebf0543ad0f75a7561f73d22171da53
\ No newline at end of file
+f5e615c28c7035a7e6d896790b51cf9bc7371d5f
\ No newline at end of file
os2Sleep, /* xSleep */
os2CurrentTime, /* xCurrentTime */
os2GetLastError /* xGetLastError */
+ 0, /* xShmOpen */
+ 0, /* xShmSize */
+ 0, /* xShmPush */
+ 0, /* xShmPull */
+ 0, /* xShmLock */
+ 0, /* xShmClose */
+ 0, /* xShmDelete */
+ 0, /* xRename */
+ 0, /* xCurrentTimeInt64 */
};
sqlite3_vfs_register(&os2Vfs, 1);
initUconvObjects();
#include <time.h>
#include <sys/time.h>
#include <errno.h>
+#include <sys/mman.h>
#if SQLITE_ENABLE_LOCKING_STYLE
# include <sys/ioctl.h>
return 0;
}
+/*
+** Structure used internally by this VFS to record the state of an
+** open shared memory segment.
+*/
+struct unixShm {
+ sqlite3_vfs *pVfs; /* VFS that opened this shared-memory segment */
+ int size; /* Size of the shared memory area */
+ char *pBuf; /* Pointer to the beginning */
+ unixFile fd; /* The open file descriptor */
+};
+
+/*
+** Close a shared-memory segment
+*/
+static int unixShmClose(sqlite3_shm *pSharedMem){
+ struct unixShm *p = (struct unixShm*)pSharedMem;
+ if( p && p->pVfs ){
+ if( p->pBuf ){
+ munmap(p->pBuf, p->size);
+ }
+ if( p->fd.pMethod ){
+ p->fd.pMethod->xClose((sqlite3_file*)&p->fd);
+ }
+ memset(p, 0, sizeof(*p));
+ sqlite3_free(p);
+ }
+ return SQLITE_OK;
+}
+
+/*
+** Size increment by which shared memory grows
+*/
+#define SQLITE_UNIX_SHM_INCR 4096
+
+/*
+** Open a shared-memory area. This implementation uses mmapped files.
+*/
+static int unixShmOpen(
+ sqlite3_vfs *pVfs, /* The VFS */
+ const char *zName, /* Name of file to mmap */
+ sqlite3_shm **pShm /* Write the unixShm object created here */
+){
+ struct unixShm *p = 0;
+ int rc;
+ int outFlags;
+ struct stat sStat;
+
+ p = sqlite3_malloc( sizeof(*p) );
+ *pShm = (sqlite3_shm*)p;
+ if( p==0 ) return SQLITE_NOMEM;
+ memset(p, 0, sizeof(*p));
+ p->pVfs = pVfs;
+ rc = pVfs->xOpen(pVfs, zName, (sqlite3_file*)&p->fd,
+ SQLITE_OPEN_READWRITE | SQLITE_OPEN_MAIN_JOURNAL,
+ &outFlags);
+ if( rc!=SQLITE_OK ) goto shm_open_err;
+
+ rc = fstat(p->fd.h, &sStat);
+ if( rc!=0 ) goto shm_open_err;
+ if( sStat.st_size<SQLITE_UNIX_SHM_INCR ){
+ rc = ftruncate(p->fd.h, SQLITE_UNIX_SHM_INCR);
+ if( rc!=0 ) goto shm_open_err;
+ p->size = SQLITE_UNIX_SHM_INCR;
+ }else{
+ p->size = sStat.st_size;
+ }
+
+ /* Map the file. */
+ p->pBuf = mmap(0, p->size, PROT_READ|PROT_WRITE, MAP_SHARED, p->fd.h, 0);
+ if( p->pBuf==MAP_FAILED ){
+ rc = SQLITE_IOERR;
+ goto shm_open_err;
+ }
+ return SQLITE_OK;
+
+shm_open_err:
+ unixShmClose((sqlite3_shm*)p);
+ *pShm = 0;
+ return rc;
+}
+
+/*
+** Query and/or changes the size of a shared-memory segment.
+** The reqSize parameter is the new size of the segment, or -1 to
+** do just a query. The size of the segment after resizing is
+** written into pNewSize. The start of the shared memory buffer
+** is stored in **ppBuffer.
+*/
+static int unixShmSize(
+ sqlite3_shm *pSharedMem, /* Pointer returned by unixShmOpen() */
+ int reqSize, /* Requested size. -1 for query only */
+ int *pNewSize, /* Write new size here */
+ char **ppBuf /* Write new buffer origin here */
+){
+ struct unixShm *p = (struct unixShm*)pSharedMem;
+ int rc = SQLITE_OK;
+
+ if( reqSize>=0 ){
+ reqSize = (reqSize + SQLITE_UNIX_SHM_INCR - 1)/SQLITE_UNIX_SHM_INCR;
+ reqSize *= SQLITE_UNIX_SHM_INCR;
+ if( reqSize!=p->size ){
+ munmap(p->pBuf, p->size);
+ rc = ftruncate(p->fd.h, reqSize);
+ if( rc ){
+ p->pBuf = 0;
+ p->size = 0;
+ }else{
+ p->pBuf = mmap(0, reqSize, PROT_READ|PROT_WRITE, MAP_SHARED, p->fd.h,0);
+ p->size = p->pBuf ? reqSize : 0;
+ }
+ }
+ }
+ *pNewSize = p->size;
+ *ppBuf = p->pBuf;
+ return rc;
+}
+
+/*
+** Create or release a lock on shared memory.
+*/
+static int unixShmLock(
+ sqlite3_shm *pSharedMem, /* Pointer from unixShmOpen() */
+ int lockType, /* _RDLK, _WRLK, or _UNLK, possibly ORed _BLOCK */
+ int ofst, /* Start of lock region */
+ int nByte /* Size of lock region in bytes */
+){
+ struct unixShm *p = (struct unixShm*)pSharedMem;
+ struct flock f;
+ int op;
+ int rc;
+
+ f.l_whence = SEEK_SET;
+ f.l_start = ofst;
+ f.l_len = nByte;
+ switch( lockType & 0x07 ){
+ case SQLITE_SHM_RDLK: f.l_type = F_RDLCK; break;
+ case SQLITE_SHM_WRLK: f.l_type = F_WRLCK; break;
+ case SQLITE_SHM_UNLK: f.l_type = F_UNLCK; break;
+ }
+ op = (lockType & 0x08)!=0 ? F_SETLKW : F_SETLK;
+ rc = fcntl(p->fd.h, op, &f);
+ return (rc==0) ? SQLITE_OK : SQLITE_BUSY;
+}
+
+/*
+** Delete a shared-memory segment from the system.
+*/
+static int unixShmDelete(sqlite3_vfs *pVfs, const char *zName){
+ return pVfs->xDelete(pVfs, zName, 0);
+}
+
+
/*
************************ End of sqlite3_vfs methods ***************************
******************************************************************************/
** that filesystem time.
*/
#define UNIXVFS(VFSNAME, FINDER) { \
- 1, /* iVersion */ \
+ 2, /* iVersion */ \
sizeof(unixFile), /* szOsFile */ \
MAX_PATHNAME, /* mxPathname */ \
0, /* pNext */ \
unixRandomness, /* xRandomness */ \
unixSleep, /* xSleep */ \
unixCurrentTime, /* xCurrentTime */ \
- unixGetLastError /* xGetLastError */ \
+ unixGetLastError, /* xGetLastError */ \
+ unixShmOpen, /* xShmOpen */ \
+ unixShmSize, /* xShmSize */ \
+ 0, /* xShmPush */ \
+ 0, /* xShmPull */ \
+ unixShmLock, /* xShmLock */ \
+ unixShmClose, /* xShmClose */ \
+ unixShmDelete, /* xShmDelete */ \
+ 0, /* xRename */ \
+ 0, /* xCurrentTimeInt64 */ \
}
/*
winSleep, /* xSleep */
winCurrentTime, /* xCurrentTime */
winGetLastError /* xGetLastError */
+ 0, /* xShmOpen */
+ 0, /* xShmSize */
+ 0, /* xShmPush */
+ 0, /* xShmPull */
+ 0, /* xShmLock */
+ 0, /* xShmClose */
+ 0, /* xShmDelete */
+ 0, /* xRename */
+ 0, /* xCurrentTimeInt64 */
};
sqlite3_vfs_register(&winVfs, 1);
**
*/
typedef struct sqlite3_vfs sqlite3_vfs;
+typedef struct sqlite3_shm sqlite3_shm;
struct sqlite3_vfs {
- int iVersion; /* Structure version number */
+ int iVersion; /* Structure version number (currently 2) */
int szOsFile; /* Size of subclassed sqlite3_file */
int mxPathname; /* Maximum file pathname length */
sqlite3_vfs *pNext; /* Next registered VFS */
int (*xSleep)(sqlite3_vfs*, int microseconds);
int (*xCurrentTime)(sqlite3_vfs*, double*);
int (*xGetLastError)(sqlite3_vfs*, int, char *);
- /* New fields may be appended in figure versions. The iVersion
- ** value will increment whenever this happens. */
+ /*
+ ** The methods above are in version 1 of the sqlite_vfs object
+ ** definition. Those that follow are added in version 2 or later
+ */
+ int (*xShmOpen)(sqlite3_vfs*, const char *zName, sqlite3_shm**);
+ int (*xShmSize)(sqlite3_shm*, int reqSize, int *pNewSize, char **);
+ int (*xShmPush)(sqlite3_shm*);
+ int (*xShmPull)(sqlite3_shm*);
+ int (*xShmLock)(sqlite3_shm*, int lockType, int ofst, int nByte);
+ int (*xShmClose)(sqlite3_shm*);
+ int (*xShmDelete)(sqlite3_vfs*, const char *zName);
+ int (*xRename)(sqlite3_vfs*, const char *zOld, const char *zNew, int dirSync);
+ int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
+ /*
+ ** The methods above are in versions 1 and 2 of the sqlite_vfs object.
+ ** New fields may be appended in figure versions. The iVersion
+ ** value will increment whenever this happens.
+ */
};
/*
#define SQLITE_ACCESS_READWRITE 1
#define SQLITE_ACCESS_READ 2
+/*
+** CAPI3REF: Flags for the xShmLock VFS method
+**
+** These integer constants can be used as the second parameter to
+** the xShmLock method of an [sqlite3_vfs] object. They determine
+** the specific locking action. Exactly one of the first three
+** values must be used ini the lockType parameter. The fourth
+** value (SQLITE_SHM_BLOCK) can optionally be ORed into the lockType
+** parameter to cause the thread to block until the lock becomes
+** available.
+*/
+#define SQLITE_SHM_RDLK 0x01
+#define SQLITE_SHM_WRLK 0x02
+#define SQLITE_SHM_UNLK 0x04
+#define SQLITE_SHM_BLOCK 0x08
+
/*
** CAPI3REF: Initialize The SQLite Library
**
cfDlClose, /* xDlClose */
cfRandomness, /* xRandomness */
cfSleep, /* xSleep */
- cfCurrentTime /* xCurrentTime */
+ cfCurrentTime, /* xCurrentTime */
+ 0, /* xShmOpen */
+ 0, /* xShmSize */
+ 0, /* xShmPush */
+ 0, /* xShmPull */
+ 0, /* xShmLock */
+ 0, /* xShmClose */
+ 0, /* xShmDelete */
+ 0, /* xRename */
+ 0 /* xCurrentTimeInt64 */
};
if( objc!=2 ){
demoDlClose, /* xDlClose */
demoRandomness, /* xRandomness */
demoSleep, /* xSleep */
- demoCurrentTime /* xCurrentTime */
+ demoCurrentTime, /* xCurrentTime */
+ 0, /* xShmOpen */
+ 0, /* xShmSize */
+ 0, /* xShmPush */
+ 0, /* xShmPull */
+ 0, /* xShmLock */
+ 0, /* xShmClose */
+ 0, /* xShmDelete */
+ 0, /* xRename */
+ 0 /* xCurrentTimeInt64 */
};
return &demovfs;
}
#endif /* SQLITE_OMIT_LOAD_EXTENSION */
devsymRandomness, /* xRandomness */
devsymSleep, /* xSleep */
- devsymCurrentTime /* xCurrentTime */
+ devsymCurrentTime, /* xCurrentTime */
+ 0, /* xShmOpen */
+ 0, /* xShmSize */
+ 0, /* xShmPush */
+ 0, /* xShmPull */
+ 0, /* xShmLock */
+ 0, /* xShmClose */
+ 0, /* xShmDelete */
+ 0, /* xRename */
+ 0 /* xCurrentTimeInt64 */
};
static sqlite3_io_methods devsym_io_methods = {
jtDlClose, /* xDlClose */
jtRandomness, /* xRandomness */
jtSleep, /* xSleep */
- jtCurrentTime /* xCurrentTime */
+ jtCurrentTime, /* xCurrentTime */
+ 0, /* xShmOpen */
+ 0, /* xShmSize */
+ 0, /* xShmPush */
+ 0, /* xShmPull */
+ 0, /* xShmLock */
+ 0, /* xShmClose */
+ 0, /* xShmDelete */
+ 0, /* xRename */
+ 0 /* xCurrentTimeInt64 */
};
static sqlite3_io_methods jt_io_methods = {
fsDlClose, /* xDlClose */
fsRandomness, /* xRandomness */
fsSleep, /* xSleep */
- fsCurrentTime /* xCurrentTime */
+ fsCurrentTime, /* xCurrentTime */
+ 0, /* xShmOpen */
+ 0, /* xShmSize */
+ 0, /* xShmPush */
+ 0, /* xShmPull */
+ 0, /* xShmLock */
+ 0, /* xShmClose */
+ 0, /* xShmDelete */
+ 0, /* xRename */
+ 0 /* xCurrentTimeInt64 */
},
0, /* pFileList */
0 /* pParent */
instDlClose, /* xDlClose */
instRandomness, /* xRandomness */
instSleep, /* xSleep */
- instCurrentTime /* xCurrentTime */
+ instCurrentTime, /* xCurrentTime */
+ 0, /* xShmOpen */
+ 0, /* xShmSize */
+ 0, /* xShmPush */
+ 0, /* xShmPull */
+ 0, /* xShmLock */
+ 0, /* xShmClose */
+ 0, /* xShmDelete */
+ 0, /* xRename */
+ 0 /* xCurrentTimeInt64 */
};
static sqlite3_io_methods inst_io_methods = {