Compare commits

..

6 Commits

Author SHA1 Message Date
mistachkin 7547f78889 Expand scope of the SQLITE_DISABLE_MMAP define for the Win32 VFS.
FossilOrigin-Name: daa168f3dad995c4b7dd60e7717db90639e167c2
2013-04-11 22:52:44 +00:00
mistachkin fdd72c9a2f For the multi-process tester on Win32, make use of the GetCurrentProcessId API.
FossilOrigin-Name: f1b524b9d9ea3db96d54ac55c39f15e6879085bd
2013-04-11 21:13:10 +00:00
drh e82c6c39f4 Fix the xCheckReservedLock() method on the windows VFS so that it cannot
return a false positive when two or more processes use it at the same time
on the same file.  Ticket [7ff3120e4fa54abb55]

FossilOrigin-Name: dd3510bb20ade173c81c9874c05466011c8a249d
2013-04-11 18:28:55 +00:00
drh ef8e986bde Fix pragma code generation so that it always outputs an OP_Trace opcode so
that pragmas are shown in sqlite3_trace() output.

FossilOrigin-Name: 663f04bd48bc6f302230a22bd22b82bde2353943
2013-04-11 13:26:18 +00:00
drh e3be8c8627 Show the process-id on log messages from mptester.
FossilOrigin-Name: 6748a83dc5c02db37ecd963e678c5c69db142cac
2013-04-11 11:53:45 +00:00
drh fbc7e8845d Have the UNIX VFS issue warnings via sqlite3_log() if a database file is
renamed or unlinked or linked to more than one name while the file is open.

FossilOrigin-Name: e238dcf9189c029fbdcf89339e21d9cdd8fbf2c5
2013-04-11 01:16:15 +00:00
8 changed files with 93 additions and 38 deletions
+13 -13
View File
@@ -1,5 +1,5 @@
C Experimental\schanges\sto\ssupport\sa\sWin32\sVSIX\spackage\sflavor.
D 2013-04-11T00:13:46.757
C Expand\sscope\sof\sthe\sSQLITE_DISABLE_MMAP\sdefine\sfor\sthe\sWin32\sVFS.
D 2013-04-11T22:52:44.089
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 3dd3fcb87b70c78d99b2c8a03e44ec86d6ca9ce2
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -114,7 +114,7 @@ F mptest/config01.test 3f4ddeb152a4f83872f0fa7fcb48d9fd609893da
F mptest/config02.test 962913ed2b537d60de4126db7fe54716865cdd22
F mptest/crash01.test a5f31998ed48de8267d6620e8af107ec148e5f12
F mptest/crash02.subtest f4ef05adcd15d60e5d2bd654204f2c008b519df8
F mptest/mptest.c 8b6d7878addccbb9a1b28d9dbf2b0b516a3279f1
F mptest/mptest.c 53066ffe4ae6f0c4de451cc77985b88d0fee2aec
F mptest/multiwrite01.test 81fbc17657964889b60750bd7bbb1deffe8f4d42
F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca
F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
@@ -166,15 +166,15 @@ F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30
F src/os.c ca679b293a6233327e418fd1dde2cd5db3e90932
F src/os.h ae08bcc5f6ec6b339f4a2adf3931bb88cc14c3e4
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
F src/os_unix.c a6e9caadd8956a39153d1bd920e459211a281388
F src/os_win.c 3aec291c40048653c00a153fee96d3a442ab85ee
F src/os_unix.c 5707fcb125f043e2d3376ea862e8ec83633c5e0e
F src/os_win.c 190be0e689be61b3dcb8c1d253bc967e09c1866e
F src/pager.c 28f45e60d9a173368872d6e688e7a848c3926344
F src/pager.h 5cb78b8e1adfd5451e600be7719f5a99d87ac3b1
F src/parse.y 5d5e12772845805fdfeb889163516b84fbb9ae95
F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222
F src/pcache1.c 9fd22671c270b35131ef480bbc00392b8b5f8ab9
F src/pragma.c 8bbc8c8697d13f76394e592dcecafce3491ed8ba
F src/pragma.c 216d6c24520f7b2e267a2356e5d3269d28690f49
F src/prepare.c 743e484233c51109666d402f470523553b41797c
F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
@@ -1024,7 +1024,7 @@ F tool/mksqlite3c-noext.tcl 8bce31074e4cbe631bb7676526a048335f4c9f02
F tool/mksqlite3c.tcl a570a0b0847f5659482087f70e409ac45ce93b91
F tool/mksqlite3h.tcl ba24038056f51fde07c0079c41885ab85e2cff12
F tool/mksqlite3internalh.tcl 3dca7bb5374cee003379b8cbac73714f610ef795
F tool/mkvsix.tcl 7d6b5c45521f1422bca980f13c08fc0226ecd8aa
F tool/mkvsix.tcl 0be7f7a591f1e83f9199cb82911b66668ca484c9
F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091
F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77
F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
@@ -1049,11 +1049,11 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/win/sqlite.vsix 1cf37bf79e04fc4030f7a5acf1de64d6162e9a23
P 0fdc743583c67a3a017b9ad812c62a5104b9aee7
R f5ec6eca1c57a0969247b9c441fad8c1
T *branch * vsixWin32
T *sym-vsixWin32 *
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
P f1b524b9d9ea3db96d54ac55c39f15e6879085bd
R 81fda886c4b87168bc8522f21db6569f
T *branch * winDisableMmap
T *sym-winDisableMmap *
T -sym-trunk *
U mistachkin
Z 6f9112a4a88191e1094322a991d7d8e6
Z d00cd2eed7d26c94b83b76365b3988fe
+1 -1
View File
@@ -1 +1 @@
abedd7cb454aab99b62b63ed4fdd70c31ef87b0b
daa168f3dad995c4b7dd60e7717db90639e167c2
+8 -4
View File
@@ -49,8 +49,10 @@
/* The suffix to append to the child command lines, if any */
#if defined(_WIN32)
# define CMDLINE_SUFFIX ""
# define GETPID (int)GetCurrentProcessId
#else
# define CMDLINE_SUFFIX "&"
# define GETPID getpid
#endif
/* Mark a parameter as unused to suppress compiler warnings */
@@ -67,7 +69,7 @@ static struct Global {
FILE *pErrLog; /* Where to write errors */
char *zLog; /* Name of output log file */
FILE *pLog; /* Where to write log messages */
char zName[12]; /* Symbolic name of this process */
char zName[32]; /* Symbolic name of this process */
int taskId; /* Task ID. 0 means supervisor. */
int iTrace; /* Tracing level */
int bSqlTrace; /* True to trace SQL commands */
@@ -331,7 +333,7 @@ static void sqlErrorCallback(void *pArg, int iErrCode, const char *zMsg){
UNUSED_PARAMETER(pArg);
if( (iErrCode&0xff)==SQLITE_SCHEMA && g.iTrace<3 ) return;
if( g.iTimeout==0 && (iErrCode&0xff)==SQLITE_BUSY && g.iTrace<3 ) return;
if( iErrCode==SQLITE_OK ){
if( (iErrCode&0xff)==SQLITE_NOTICE ){
logMessage("(info) %s", zMsg);
}else{
errorMessage("(errcode=%d) %s", iErrCode, zMsg);
@@ -1189,7 +1191,7 @@ int main(int argc, char **argv){
exit(1);
}
n = argc-2;
sqlite3_snprintf(sizeof(g.zName), g.zName, "mptest");
sqlite3_snprintf(sizeof(g.zName), g.zName, "%05d.mptest", GETPID());
g.zVfs = findOption(argv+2, &n, "vfs", 1);
zClient = findOption(argv+2, &n, "client", 1);
g.zErrLog = findOption(argv+2, &n, "errlog", 1);
@@ -1209,11 +1211,13 @@ int main(int argc, char **argv){
}else{
g.pLog = stdout;
}
sqlite3_config(SQLITE_CONFIG_LOG, sqlErrorCallback, 0);
if( zClient ){
iClient = atoi(zClient);
if( iClient<1 ) fatalError("illegal client number: %d\n", iClient);
sqlite3_snprintf(sizeof(g.zName), g.zName, "client%02d", iClient);
sqlite3_snprintf(sizeof(g.zName), g.zName, "%05d.client%02d",
GETPID(), iClient);
}else{
if( g.iTrace>0 ){
printf("With SQLite " SQLITE_VERSION " " SQLITE_SOURCE_ID "\n" );
+52 -2
View File
@@ -280,6 +280,7 @@ struct unixFile {
#define UNIXFILE_DELETE 0x20 /* Delete on close */
#define UNIXFILE_URI 0x40 /* Filename might have query parameters */
#define UNIXFILE_NOLOCK 0x80 /* Do no file locking */
#define UNIXFILE_WARNED 0x0100 /* verifyDbFile() warnings have been issued */
/*
** Include code that is common to all os_*.c files
@@ -799,7 +800,6 @@ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {
}
/******************************************************************************
****************** Begin Unique File ID Utility Used By VxWorks ***************
**
@@ -1300,6 +1300,50 @@ static int findInodeInfo(
}
/*
** Check a unixFile that is a database. Verify the following:
**
** (1) There is exactly one hard link on the file
** (2) The file is not a symbolic link
** (3) The file has not been renamed or unlinked
**
** Issue sqlite3_log(SQLITE_WARNING,...) messages if anything is not right.
*/
static void verifyDbFile(unixFile *pFile){
struct stat buf;
int rc;
if( pFile->ctrlFlags & UNIXFILE_WARNED ){
/* One or more of the following warnings have already been issued. Do not
** repeat them so as not to clutter the error log */
return;
}
rc = osFstat(pFile->h, &buf);
if( rc!=0 ){
sqlite3_log(SQLITE_WARNING, "cannot fstat db file %s", pFile->zPath);
pFile->ctrlFlags |= UNIXFILE_WARNED;
return;
}
if( buf.st_nlink==0 && (pFile->ctrlFlags & UNIXFILE_DELETE)==0 ){
sqlite3_log(SQLITE_WARNING, "file unlinked while open: %s", pFile->zPath);
pFile->ctrlFlags |= UNIXFILE_WARNED;
return;
}
if( buf.st_nlink>1 ){
sqlite3_log(SQLITE_WARNING, "multiple links to file: %s", pFile->zPath);
pFile->ctrlFlags |= UNIXFILE_WARNED;
return;
}
if( pFile->pInode!=0
&& ((rc = osStat(pFile->zPath, &buf))!=0
|| buf.st_ino!=pFile->pInode->fileId.ino)
){
sqlite3_log(SQLITE_WARNING, "file renamed while open: %s", pFile->zPath);
pFile->ctrlFlags |= UNIXFILE_WARNED;
return;
}
}
/*
** This routine checks if there is a RESERVED lock held on the specified
** file by this or any other process. If such a lock is held, set *pResOut
@@ -1876,6 +1920,7 @@ static int closeUnixFile(sqlite3_file *id){
static int unixClose(sqlite3_file *id){
int rc = SQLITE_OK;
unixFile *pFile = (unixFile *)id;
verifyDbFile(pFile);
unixUnlock(id, NO_LOCK);
unixEnterMutex();
@@ -4539,6 +4584,7 @@ static void unixUnmapfile(unixFile *pFd){
#endif
}
#ifndef SQLITE_DISABLE_MMAP
/*
** Return the system page size.
*/
@@ -4551,6 +4597,7 @@ static int unixGetPagesize(void){
return (int)sysconf(_SC_PAGESIZE);
#endif
}
#endif /* SQLITE_DISABLE_MMAP */
#ifndef SQLITE_DISABLE_MMAP
/*
@@ -4656,10 +4703,10 @@ static void unixRemapfile(
** code otherwise.
*/
static int unixMapfile(unixFile *pFd, i64 nByte){
#ifndef SQLITE_DISABLE_MMAP
i64 nMap = nByte;
int rc;
#ifndef SQLITE_DISABLE_MMAP
assert( nMap>=0 || pFd->nFetchOut==0 );
if( pFd->nFetchOut>0 ) return SQLITE_OK;
@@ -4700,7 +4747,9 @@ static int unixMapfile(unixFile *pFd, i64 nByte){
** release the reference by calling unixUnfetch().
*/
static int unixFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
#ifndef SQLITE_DISABLE_MMAP
unixFile *pFd = (unixFile *)fd; /* The underlying database file */
#endif
*pp = 0;
#ifndef SQLITE_DISABLE_MMAP
@@ -5222,6 +5271,7 @@ static int fillInUnixFile(
}else{
pNew->pMethod = pLockingStyle;
OpenCounter(+1);
verifyDbFile(pNew);
}
return rc;
}
+14 -4
View File
@@ -150,12 +150,14 @@ struct winFile {
winceLock local; /* Locks obtained by this instance of winFile */
winceLock *shared; /* Global shared lock memory for the file */
#endif
#if !defined(SQLITE_DISABLE_MMAP)
int nFetchOut; /* Number of outstanding xFetch references */
HANDLE hMap; /* Handle for accessing memory mapping */
void *pMapRegion; /* Area memory mapped */
sqlite3_int64 mmapSize; /* Usable size of mapped region */
sqlite3_int64 mmapOrigsize; /* Actual size of mapped region */
sqlite3_int64 mmapLimit; /* Configured FCNTL_MMAP_LIMIT value */
#endif
};
/*
@@ -2093,8 +2095,10 @@ static int winClose(sqlite3_file *id){
OSTRACE(("CLOSE %d\n", pFile->h));
assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );
#if !defined(SQLITE_DISABLE_MMAP)
rc = winUnmapfile(pFile);
if( rc!=SQLITE_OK ) return rc;
#endif
do{
rc = osCloseHandle(pFile->h);
@@ -2702,7 +2706,7 @@ static int winCheckReservedLock(sqlite3_file *id, int *pResOut){
rc = 1;
OSTRACE(("TEST WR-LOCK %d %d (local)\n", pFile->h, rc));
}else{
rc = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS, RESERVED_BYTE, 0, 1, 0);
rc = winLockFile(&pFile->h, SQLITE_LOCKFILEEX_FLAGS,RESERVED_BYTE, 0, 1, 0);
if( rc ){
winUnlockFile(&pFile->h, RESERVED_BYTE, 0, 1, 0);
}
@@ -2842,12 +2846,14 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){
}
return SQLITE_OK;
}
#if !defined(SQLITE_DISABLE_MMAP)
case SQLITE_FCNTL_MMAP_LIMIT: {
i64 newLimit = *(i64*)pArg;
*(i64*)pArg = pFile->mmapLimit;
if( newLimit>=0 ) pFile->mmapLimit = newLimit;
return SQLITE_OK;
}
#endif
}
return SQLITE_NOTFOUND;
}
@@ -3521,9 +3527,9 @@ shmpage_out:
/*
** Cleans up the mapped region of the specified file, if any.
*/
#if !defined(SQLITE_DISABLE_MMAP)
static int winUnmapfile(winFile *pFile){
assert( pFile!=0 );
#if !defined(SQLITE_DISABLE_MMAP)
if( pFile->pMapRegion ){
if( !osUnmapViewOfFile(pFile->pMapRegion) ){
pFile->lastErrno = osGetLastError();
@@ -3542,11 +3548,9 @@ static int winUnmapfile(winFile *pFile){
}
pFile->hMap = NULL;
}
#endif
return SQLITE_OK;
}
#if !defined(SQLITE_DISABLE_MMAP)
/*
** 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
@@ -3649,7 +3653,9 @@ static int winMapfile(winFile *pFd, sqlite3_int64 nByte){
** release the reference by calling unixUnfetch().
*/
static int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
#if !defined(SQLITE_DISABLE_MMAP)
winFile *pFd = (winFile*)fd; /* The underlying database file */
#endif
*pp = 0;
#if !defined(SQLITE_DISABLE_MMAP)
@@ -3678,6 +3684,7 @@ static int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
** may now be invalid and should be unmapped.
*/
static int winUnfetch(sqlite3_file *fd, i64 iOff, void *p){
#if !defined(SQLITE_DISABLE_MMAP)
winFile *pFd = (winFile*)fd; /* The underlying database file */
/* If p==0 (unmap the entire file) then there must be no outstanding
@@ -3699,6 +3706,7 @@ static int winUnfetch(sqlite3_file *fd, i64 iOff, void *p){
}
assert( pFd->nFetchOut>=0 );
#endif
return SQLITE_OK;
}
@@ -4126,11 +4134,13 @@ static int winOpen(
}
pFile->lastErrno = NO_ERROR;
pFile->zPath = zName;
#if !defined(SQLITE_DISABLE_MMAP)
pFile->hMap = NULL;
pFile->pMapRegion = 0;
pFile->mmapSize = 0;
pFile->mmapOrigsize = 0;
pFile->mmapLimit = sqlite3GlobalConfig.mxMmap;
#endif
OpenCounter(+1);
return rc;
+4 -3
View File
@@ -319,7 +319,7 @@ void sqlite3Pragma(
int rc; /* return value form SQLITE_FCNTL_PRAGMA */
sqlite3 *db = pParse->db; /* The database connection */
Db *pDb; /* The specific database being pragmaed */
Vdbe *v = pParse->pVdbe = sqlite3VdbeCreate(db); /* Prepared statement */
Vdbe *v = sqlite3GetVdbe(pParse); /* Prepared statement */
if( v==0 ) return;
sqlite3VdbeRunOnlyOnce(v);
@@ -402,11 +402,12 @@ void sqlite3Pragma(
static const VdbeOpList getCacheSize[] = {
{ OP_Transaction, 0, 0, 0}, /* 0 */
{ OP_ReadCookie, 0, 1, BTREE_DEFAULT_CACHE_SIZE}, /* 1 */
{ OP_IfPos, 1, 7, 0},
{ OP_IfPos, 1, 8, 0},
{ OP_Integer, 0, 2, 0},
{ OP_Subtract, 1, 2, 1},
{ OP_IfPos, 1, 7, 0},
{ OP_IfPos, 1, 8, 0},
{ OP_Integer, 0, 1, 0}, /* 6 */
{ OP_Noop, 0, 0, 0},
{ OP_ResultRow, 1, 1, 0},
};
int addr;
+1 -11
View File
@@ -255,7 +255,6 @@ if {[string equal -nocase $packageFlavor WinRT]} then {
set shortName SQLite.WinRT
set displayName "SQLite for Windows Runtime"
set targetPlatformIdentifier Windows
set targetPlatformVersion v8.0
set extraSdkPath ""
set extraFileListAttributes [appendArgs \
"\r\n " {AppliesTo="WindowsAppContainer"} \
@@ -264,19 +263,10 @@ if {[string equal -nocase $packageFlavor WinRT]} then {
set shortName SQLite.WP80
set displayName "SQLite for Windows Phone"
set targetPlatformIdentifier "Windows Phone"
set targetPlatformVersion v8.0
set extraSdkPath "\\..\\$targetPlatformIdentifier"
set extraFileListAttributes ""
} elseif {[string equal -nocase $packageFlavor Win32]} then {
set shortName SQLite.Win32
set displayName "SQLite for Windows"
set targetPlatformIdentifier Windows
set targetPlatformVersion v8.0
set extraSdkPath ""
set extraFileListAttributes [appendArgs \
"\r\n " {AppliesTo="VisualC"}]
} else {
fail "unsupported package flavor, must be \"WinRT\", \"WP80\", or \"Win32\""
fail "unsupported package flavor, must be \"WinRT\" or \"WP80\""
}
if {$argc >= 4} then {
Binary file not shown.