-C Do\snot\sreturn\sSQLITE_IOERR\swhen\sthe\suser\sattempts\sto\sopen\sa\ssmall\sfile\sthat\sis\snot\sa\sdatabase\swith\smmap\senabled.\sInstead\sreturn\sSQLITE_NOTADB.
-D 2013-03-25T14:31:39.689
+C Remove\sunnecessary\scode\sto\sround\sthe\ssize\sof\sa\smemory\smapping\sto\s4KB\sfrom\sos_unix.c.\sRename\sSQLITE_IOERR_MREMAP\sto\sSQLITE_IOERR_MMAP.\sFix\sother\ssmall\sissues\sin\sos_unix.c.
+D 2013-03-25T16:28:54.437
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 9a804abbd3cae82d196e4d33aba13239e32522a5
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/os.c a7ec2ddc43fb2684bfd8cb30db15ea6cce3298e9
F src/os.h 782980cd0d840b4240a6e29ba9f8ef0ca0d750ca
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
-F src/os_unix.c 1e61abcb664f3430ce13e5c5f32b2b2e204a6f23
+F src/os_unix.c 82efc58c818c69e191f5560935037af365f99ff5
F src/os_win.c 386f8c034b177b672f7819ddc5d80be6c8d593ac
F src/pager.c 2dd59f366b519d01d08b44f615058e7cfacd0bd7
F src/pager.h 241d72dc0905df042da165f086d03505cb0bb50c
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
F src/select.c e1c6f6abdf9f359f4e735cb8ae11d2f359bf52a9
F src/shell.c 7c41bfcd9e5bf9d96b9215f79b03a5b2b44a3bca
-F src/sqlite.h.in f41949e1e778043dd9fc23b33b96e7a6e20de4d6
+F src/sqlite.h.in a0866dafaa412d1e89abbc78d2b44b12cf95d1d1
F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
F src/sqlite3ext.h 7183ab832e23db0f934494f16928da127a571d75
F src/sqliteInt.h 2c3d830ae78b046ebf939c905c023610e43c2796
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
-P 5885ba6ce768658ec25b60747430d147b315b55c
-R c243df2223b3431445e14c1469df7b20
+P bbcaab3e80d0ff776d8567094b137d1483b3377b
+R fd25f18074b1cc787a38214a338c9127
U dan
-Z 6b851eca8762089c75296a1160d8987e
+Z ae05d407cd866087491e3302af269873
#endif /* #ifndef SQLITE_OMIT_WAL */
/*
-** Arguments x and y are both integers. Argument y must be a power of 2.
-** Round x up to the nearest integer multiple of y. For example:
-**
-** ROUNDUP(0, 8) -> 0
-** ROUNDUP(13, 8) -> 16
-** ROUNDUP(32, 8) -> 32
+** If it is currently memory mapped, unmap file pFd.
*/
-#define ROUNDUP(x,y) (((x)+y-1)&~(y-1))
-
static void unixUnmapfile(unixFile *pFd){
assert( pFd->nFetchOut==0 );
if( pFd->pMapRegion ){
}
}
+/*
+** Memory map or remap the file opened by file-descriptor pFd (if the file
+** is already mapped, the existing mapping is replaced by the new). Or, if
+** there already exists a mapping for this file, and there are still
+** outstanding xFetch() references to it, this function is a no-op.
+**
+** If parameter nByte is non-negative, then it is the requested size of
+** the mapping to create. Otherwise, if nByte is less than zero, then the
+** requested size is the size of the file on disk. The actual size of the
+** created mapping is either the requested size or the value configured
+** using SQLITE_FCNTL_MMAP_SIZE, whichever is smaller.
+**
+** SQLITE_OK is returned if no error occurs (even if the mapping is not
+** recreated as a result of outstanding references) or an SQLite error
+** code otherwise.
+*/
static int unixMapfile(unixFile *pFd, i64 nByte){
i64 nMap = nByte;
int rc;
void *pNew;
int flags = PROT_READ;
if( (pFd->ctrlFlags & UNIXFILE_RDONLY)==0 ) flags |= PROT_WRITE;
- pNew = mmap(0, ROUNDUP(nMap, 4096), flags, MAP_SHARED, pFd->h, 0);
+ pNew = mmap(0, nMap, flags, MAP_SHARED, pFd->h, 0);
if( pNew==MAP_FAILED ){
- return SQLITE_IOERR_MREMAP;
+ return SQLITE_IOERR_MMAP;
}
pFd->pMapRegion = pNew;
- pFd->mmapOrigsize = pFd->mmapSize = nMap;
+ pFd->mmapSize = nMap;
+ pFd->mmapOrigsize = nMap;
}
}
return SQLITE_OK;
}
+/*
+** If possible, return a pointer to a mapping of file fd starting at offset
+** iOff. The mapping must be valid for at least nAmt bytes.
+**
+** If such a pointer can be obtained, store it in *pp and return SQLITE_OK.
+** Or, if one cannot but no error occurs, set *pp to 0 and return SQLITE_OK.
+** Finally, if an error does occur, return an SQLite error code. The final
+** value of *pp is undefined in this case.
+**
+** If this function does return a pointer, the caller must eventually
+** release the reference by calling unixUnfetch().
+*/
static int unixFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
unixFile *pFd = (unixFile *)fd; /* The underlying database file */
*pp = 0;
return SQLITE_OK;
}
+/*
+** If the second argument is non-NULL, then this function releases a
+** reference obtained by an earlier call to unixFetch(). Or, if the second
+** argument is NULL, then this function is being called to inform the VFS
+** layer that, according to POSIX, any existing mapping may now be invalid
+** and should be unmapped.
+*/
static int unixUnfetch(sqlite3_file *fd, void *p){
unixFile *pFd = (unixFile *)fd; /* The underlying database file */
+ /* If p==0 (unmap the entire file) then there must be no outstanding
+ ** xFetch references. Or, if p!=0 (meaning it is an xFetch reference),
+ ** then there must be at least one outstanding. */
assert( (p==0)==(pFd->nFetchOut==0) );
if( p ){