From 815aac8e0fe1d6a7cc96f6a6ed9680cc05228c50 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 1 Mar 2012 18:16:48 +0000 Subject: [PATCH 01/59] Remove unused #defines from os.h. FossilOrigin-Name: c0891296b49fb95917db8a881425f8131cbf6de7 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os.h | 24 ------------------------ 3 files changed, 8 insertions(+), 32 deletions(-) diff --git a/manifest b/manifest index ffe0e4775e..010e2bf888 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sspurious\serrors\sthat\smay\soccur\sif\san\sempty\sdatabase\sis\sopened\sand\sthen\sinitialized\sas\sa\sWAL\sdatabase\sby\sa\ssecond\sconnection. -D 2012-02-28T17:57:34.628 +C Remove\sunused\s#defines\sfrom\sos.h. +D 2012-03-01T18:16:48.199 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -163,7 +163,7 @@ F src/mutex_unix.c c3a4e00f96ba068a8dbef34084465979aaf369cc F src/mutex_w32.c 5e54f3ba275bcb5d00248b8c23107df2e2f73e33 F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c -F src/os.h 59beba555b65a450bd1d804220532971d4299f60 +F src/os.h 3b152a1b6d426228c1d10d75cdcc7adcc89b8e8c F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 @@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P c267893a0813beb1764071409025e178318e1ca3 -R 751c4f9505bcae82ab2d498f42151225 -U dan -Z aacac9f6818b59f3fbe792ef77401913 +P 16330a2f7262173a32ae48a72c0ee2522b6dc554 +R dcd6f3533b75ce35c1c4bbf3bf0513ac +U drh +Z bd5dc6273ea797f2f01bb9f1d730a750 diff --git a/manifest.uuid b/manifest.uuid index df6fdce3ee..310ebb5702 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -16330a2f7262173a32ae48a72c0ee2522b6dc554 \ No newline at end of file +c0891296b49fb95917db8a881425f8131cbf6de7 \ No newline at end of file diff --git a/src/os.h b/src/os.h index 7dc0c8c2fb..5ccb442f1f 100644 --- a/src/os.h +++ b/src/os.h @@ -65,30 +65,6 @@ # endif #endif -/* -** Define the maximum size of a temporary filename -*/ -#if SQLITE_OS_WIN -# include -# define SQLITE_TEMPNAME_SIZE (MAX_PATH+50) -#elif SQLITE_OS_OS2 -# if (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3) && defined(OS2_HIGH_MEMORY) -# include /* has to be included before os2.h for linking to work */ -# endif -# define INCL_DOSDATETIME -# define INCL_DOSFILEMGR -# define INCL_DOSERRORS -# define INCL_DOSMISC -# define INCL_DOSPROCESS -# define INCL_DOSMODULEMGR -# define INCL_DOSSEMAPHORES -# include -# include -# define SQLITE_TEMPNAME_SIZE (CCHMAXPATHCOMP) -#else -# define SQLITE_TEMPNAME_SIZE 200 -#endif - /* ** Determine if we are dealing with Windows NT. ** From 11de93360fcdab066c52ddcf9976f117b6f2ec73 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 1 Mar 2012 19:14:13 +0000 Subject: [PATCH 02/59] Add back in some #includes that were removed incorrectly by the previous check-in. FossilOrigin-Name: 718905367ff3f86a449c2c27f724089ba31dea3a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os.h | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 010e2bf888..598e978876 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunused\s#defines\sfrom\sos.h. -D 2012-03-01T18:16:48.199 +C Add\sback\sin\ssome\s#includes\sthat\swere\sremoved\sincorrectly\sby\sthe\nprevious\scheck-in. +D 2012-03-01T19:14:13.642 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -163,7 +163,7 @@ F src/mutex_unix.c c3a4e00f96ba068a8dbef34084465979aaf369cc F src/mutex_w32.c 5e54f3ba275bcb5d00248b8c23107df2e2f73e33 F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c -F src/os.h 3b152a1b6d426228c1d10d75cdcc7adcc89b8e8c +F src/os.h a8c6a8aeda6c9a1b1deea675aa79bae82fa7c15f F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 @@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 16330a2f7262173a32ae48a72c0ee2522b6dc554 -R dcd6f3533b75ce35c1c4bbf3bf0513ac +P c0891296b49fb95917db8a881425f8131cbf6de7 +R 6e4cb882ea93ae9339007a493ca76cc2 U drh -Z bd5dc6273ea797f2f01bb9f1d730a750 +Z 1990475c2c72ee94b7f89b5294ac0476 diff --git a/manifest.uuid b/manifest.uuid index 310ebb5702..fa815bb210 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c0891296b49fb95917db8a881425f8131cbf6de7 \ No newline at end of file +718905367ff3f86a449c2c27f724089ba31dea3a \ No newline at end of file diff --git a/src/os.h b/src/os.h index 5ccb442f1f..cf0530447e 100644 --- a/src/os.h +++ b/src/os.h @@ -65,6 +65,25 @@ # endif #endif +#if SQLITE_OS_WIN +# include +#endif + +#if SQLITE_OS_OS2 +# if (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3) && defined(OS2_HIGH_MEMORY) +# include /* has to be included before os2.h for linking to work */ +# endif +# define INCL_DOSDATETIME +# define INCL_DOSFILEMGR +# define INCL_DOSERRORS +# define INCL_DOSMISC +# define INCL_DOSPROCESS +# define INCL_DOSMODULEMGR +# define INCL_DOSSEMAPHORES +# include +# include +#endif + /* ** Determine if we are dealing with Windows NT. ** From cf3d7a4e13c6b3c4feecf2a33dc604f87255fa22 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 1 Mar 2012 20:05:41 +0000 Subject: [PATCH 03/59] Add recognition of the SQLITE_OS_WINRT compile-time option. Use InitializeCriticalSectionEx() under winRT. FossilOrigin-Name: 8b7ca8a09f7b69db1fe766616cba0307e681a6f3 --- Makefile.msc | 2 +- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/mutex_w32.c | 4 ++++ src/os.h | 8 ++++++++ 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index e95b443fe1..84efa4f58f 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -47,7 +47,7 @@ BCC = cl.exe # will run on the target platform. (BCC and TCC are usually the # same unless your are cross-compiling.) # -TCC = cl.exe -W3 -DSQLITE_OS_WIN=1 -I. -I$(TOP)\src -fp:precise +TCC = cl.exe -W3 -DSQLITE_OS_WIN=1 -DSQLITE_OS_WINRT=1 -I. -I$(TOP)\src -fp:precise # The mksqlite3c.tcl and mksqlite3h.tcl scripts will pull in # any extension header files by default. For non-amalgamation diff --git a/manifest b/manifest index 598e978876..053f4b5391 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Add\sback\sin\ssome\s#includes\sthat\swere\sremoved\sincorrectly\sby\sthe\nprevious\scheck-in. -D 2012-03-01T19:14:13.642 +C Add\srecognition\sof\sthe\sSQLITE_OS_WINRT\scompile-time\soption.\s\s\nUse\sInitializeCriticalSectionEx()\sunder\swinRT. +D 2012-03-01T20:05:41.277 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 3a5582a858b8071af43cd459bd757f7d0748f66a +F Makefile.msc 0e67f253439ebc333b7b49f373d5932a93209c6a F Makefile.vxworks 1deb39c8bb047296c30161ffa10c1b5423e632f9 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION bb4c2a86abe53ea3c1d6ea515b69a426040e2414 @@ -160,10 +160,10 @@ F src/mutex.h 2a79e0c10c26412546b501ee0f3d92b42decf63e F src/mutex_noop.c 7682796b7d8d39bf1c138248858efcd10c9e1553 F src/mutex_os2.c 882d735098c07c8c6a5472b8dd66e19675fe117f F src/mutex_unix.c c3a4e00f96ba068a8dbef34084465979aaf369cc -F src/mutex_w32.c 5e54f3ba275bcb5d00248b8c23107df2e2f73e33 +F src/mutex_w32.c ddd2a783230e22831ab44fca181b5904e48a7318 F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c -F src/os.h a8c6a8aeda6c9a1b1deea675aa79bae82fa7c15f +F src/os.h c3a9db9e8e16f564e1a40cea1687dad69634262c F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 @@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P c0891296b49fb95917db8a881425f8131cbf6de7 -R 6e4cb882ea93ae9339007a493ca76cc2 +P 718905367ff3f86a449c2c27f724089ba31dea3a +R 465a0789e63e9500d164032936751907 U drh -Z 1990475c2c72ee94b7f89b5294ac0476 +Z 36d2e47a7d135f112024e54b1ccd201a diff --git a/manifest.uuid b/manifest.uuid index fa815bb210..4e41b5c0e4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -718905367ff3f86a449c2c27f724089ba31dea3a \ No newline at end of file +8b7ca8a09f7b69db1fe766616cba0307e681a6f3 \ No newline at end of file diff --git a/src/mutex_w32.c b/src/mutex_w32.c index bfd9dacf6c..901256be07 100644 --- a/src/mutex_w32.c +++ b/src/mutex_w32.c @@ -114,7 +114,11 @@ static int winMutexInit(void){ if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){ int i; for(i=0; i Date: Thu, 1 Mar 2012 21:19:39 +0000 Subject: [PATCH 04/59] Use WaitForSingleObjectEx() as a substitute for Sleep on winRT. FossilOrigin-Name: bf897be0daa2f7e16f63b78849ffb76ce02d48f1 --- Makefile.msc | 2 +- manifest | 14 ++++++------- manifest.uuid | 2 +- src/os_win.c | 55 ++++++++++++++++++++++++++++++++++++++------------- 4 files changed, 50 insertions(+), 23 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 84efa4f58f..06677c98e4 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -47,7 +47,7 @@ BCC = cl.exe # will run on the target platform. (BCC and TCC are usually the # same unless your are cross-compiling.) # -TCC = cl.exe -W3 -DSQLITE_OS_WIN=1 -DSQLITE_OS_WINRT=1 -I. -I$(TOP)\src -fp:precise +TCC = cl.exe -W3 -DSQLITE_OS_WIN=1 -DSQLITE_OS_WINRT=0 -I. -I$(TOP)\src -fp:precise # The mksqlite3c.tcl and mksqlite3h.tcl scripts will pull in # any extension header files by default. For non-amalgamation diff --git a/manifest b/manifest index 053f4b5391..983a310380 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Add\srecognition\sof\sthe\sSQLITE_OS_WINRT\scompile-time\soption.\s\s\nUse\sInitializeCriticalSectionEx()\sunder\swinRT. -D 2012-03-01T20:05:41.277 +C Use\sWaitForSingleObjectEx()\sas\sa\ssubstitute\sfor\sSleep\son\swinRT. +D 2012-03-01T21:19:39.132 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 0e67f253439ebc333b7b49f373d5932a93209c6a +F Makefile.msc 2aa54dceaafea890a19cd7f06ac7c168aff669d8 F Makefile.vxworks 1deb39c8bb047296c30161ffa10c1b5423e632f9 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION bb4c2a86abe53ea3c1d6ea515b69a426040e2414 @@ -167,7 +167,7 @@ F src/os.h c3a9db9e8e16f564e1a40cea1687dad69634262c F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c 5ac061ae1326a71500cee578ed0fd9113b4f6a37 +F src/os_win.c b9c36459cf8f37d16a24f35cca934c21d74f0e5b F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 718905367ff3f86a449c2c27f724089ba31dea3a -R 465a0789e63e9500d164032936751907 +P 8b7ca8a09f7b69db1fe766616cba0307e681a6f3 +R 8f274d295cc98eee7dadf7a129e9b0df U drh -Z 36d2e47a7d135f112024e54b1ccd201a +Z a00ee944783dbe7653fdca656eaa2c07 diff --git a/manifest.uuid b/manifest.uuid index 4e41b5c0e4..aee07f3b30 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8b7ca8a09f7b69db1fe766616cba0307e681a6f3 \ No newline at end of file +bf897be0daa2f7e16f63b78849ffb76ce02d48f1 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 8b86c7ed59..9730e6bda9 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -168,17 +168,11 @@ int sqlite3_os_type = 0; static int sqlite3_os_type = 0; #endif -/* -** Many system calls are accessed through pointer-to-functions so that -** they may be overridden at runtime to facilitate fault injection during -** testing and sandboxing. The following array holds the names and pointers -** to all overrideable system calls. -*/ -#if !SQLITE_OS_WINCE +#if !SQLITE_OS_WINCE || SQLITE_OS_WINRT # define SQLITE_WIN32_HAS_ANSI #endif -#if SQLITE_OS_WINCE || SQLITE_OS_WINNT +#if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT # define SQLITE_WIN32_HAS_WIDE #endif @@ -207,6 +201,12 @@ static int sqlite3_os_type = 0; # define osLockFileEx LockFileEx #endif +/* +** Many system calls are accessed through pointer-to-functions so that +** they may be overridden at runtime to facilitate fault injection during +** testing and sandboxing. The following array holds the names and pointers +** to all overrideable system calls. +*/ static struct win_syscall { const char *zName; /* Name of the sytem call */ sqlite3_syscall_ptr pCurrent; /* Current value of the system call */ @@ -572,7 +572,11 @@ static struct win_syscall { #define osSetFilePointer ((DWORD(WINAPI*)(HANDLE,LONG,PLONG, \ DWORD))aSyscall[52].pCurrent) +#if SQLITE_OS_WINRT + { "Sleep", (SYSCALL)0, 0 }, +#else { "Sleep", (SYSCALL)Sleep, 0 }, +#endif #define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[53].pCurrent) @@ -698,6 +702,21 @@ static const char *winNextSystemCall(sqlite3_vfs *p, const char *zName){ return 0; } +/* +** The following routine Suspends the thread for at least ms milliseconds. This is equivalent +** to the win32 Sleep() interface. +*/ +#if SQLITE_OS_WINRT +static HANDLE sleepObj; +static void portableSleep(int ms){ + WaitForSingleObjectEx(sleepObj, ms, FALSE); +} +#else +static void portableSleep(int ms){ + osSleep(ms); +} +#endif + /* ** Return true (non-zero) if we are running under WinNT, Win2K, WinXP, ** or WinCE. Return false (zero) for Win95, Win98, or WinME. @@ -709,7 +728,7 @@ static const char *winNextSystemCall(sqlite3_vfs *p, const char *zName){ ** WinNT/2K/XP so that we will know whether or not we can safely call ** the LockFileEx() API. */ -#if SQLITE_OS_WINCE +#if SQLITE_OS_WINCE || SQLITE_OS_WINRT # define isNT() (1) #else static int isNT(void){ @@ -1190,7 +1209,7 @@ static int retryIoerr(int *pnRetry, DWORD *pError){ if( e==ERROR_ACCESS_DENIED || e==ERROR_LOCK_VIOLATION || e==ERROR_SHARING_VIOLATION ){ - osSleep(win32IoerrRetryDelay*(1+*pnRetry)); + portableSleep(win32IoerrRetryDelay*(1+*pnRetry)); ++*pnRetry; return 1; } @@ -1599,7 +1618,7 @@ static int winClose(sqlite3_file *id){ do{ rc = osCloseHandle(pFile->h); /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */ - }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (osSleep(100), 1) ); + }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (portableSleep(100), 1) ); #if SQLITE_OS_WINCE #define WINCE_DELETION_ATTEMPTS 3 winceDestroyLock(pFile); @@ -1610,7 +1629,7 @@ static int winClose(sqlite3_file *id){ && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff && cnt++ < WINCE_DELETION_ATTEMPTS ){ - osSleep(100); /* Wait a little before trying again */ + portableSleep(100); /* Wait a little before trying again */ } sqlite3_free(pFile->zDeleteOnClose); } @@ -1976,7 +1995,7 @@ static int winLock(sqlite3_file *id, int locktype){ ** copy this retry logic. It is a hack intended for Windows only. */ OSTRACE(("could not get a PENDING lock. cnt=%d\n", cnt)); - if( cnt ) osSleep(1); + if( cnt ) portableSleep(1); } gotPendingLock = res; if( !res ){ @@ -3535,7 +3554,7 @@ static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){ ** Sleep for a little while. Return the amount of time slept. */ static int winSleep(sqlite3_vfs *pVfs, int microsec){ - osSleep((microsec+999)/1000); + portableSleep((microsec+999)/1000); UNUSED_PARAMETER(pVfs); return ((microsec+999)/1000)*1000; } @@ -3679,6 +3698,11 @@ int sqlite3_os_init(void){ ** correctly. See ticket [bb3a86e890c8e96ab] */ assert( ArraySize(aSyscall)==60 ); +#if SQLITE_OS_WINRT + sleepObj = CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, + EVENT_ALL_ACCESS); +#endif + #ifndef SQLITE_OMIT_WAL /* get memory map allocation granularity */ memset(&winSysInfo, 0, sizeof(SYSTEM_INFO)); @@ -3691,6 +3715,9 @@ int sqlite3_os_init(void){ } int sqlite3_os_end(void){ +#if SQLITE_OS_WINRT + CloseHandle(sleepObj); +#endif return SQLITE_OK; } From 8045df0a7dd1c634e7ddc9edf90e637d496d943a Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 1 Mar 2012 22:06:30 +0000 Subject: [PATCH 05/59] Use SetFilePointerEx() instead of SetFilePointer() on winRT. FossilOrigin-Name: 36efafc618017b6448f222776d0143e5f98d1e65 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 983a310380..086698b523 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sWaitForSingleObjectEx()\sas\sa\ssubstitute\sfor\sSleep\son\swinRT. -D 2012-03-01T21:19:39.132 +C Use\sSetFilePointerEx()\sinstead\sof\sSetFilePointer()\son\swinRT. +D 2012-03-01T22:06:30.213 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h c3a9db9e8e16f564e1a40cea1687dad69634262c F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c b9c36459cf8f37d16a24f35cca934c21d74f0e5b +F src/os_win.c f5d551ef6c6988fb5ed96c4f60eb67bd5cce78e4 F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 8b7ca8a09f7b69db1fe766616cba0307e681a6f3 -R 8f274d295cc98eee7dadf7a129e9b0df +P bf897be0daa2f7e16f63b78849ffb76ce02d48f1 +R c83dc412475e58f58086f3dd45db2c02 U drh -Z a00ee944783dbe7653fdca656eaa2c07 +Z c05dce97a97e437048d5758229e96bc3 diff --git a/manifest.uuid b/manifest.uuid index aee07f3b30..f7ff822478 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bf897be0daa2f7e16f63b78849ffb76ce02d48f1 \ No newline at end of file +36efafc618017b6448f222776d0143e5f98d1e65 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 9730e6bda9..526dd5a844 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -567,7 +567,11 @@ static struct win_syscall { #define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[51].pCurrent) +#if SQLITE_OS_WINRT + { "SetFilePointer", (SYSCALL)0, 0 }, +#else { "SetFilePointer", (SYSCALL)SetFilePointer, 0 }, +#endif #define osSetFilePointer ((DWORD(WINAPI*)(HANDLE,LONG,PLONG, \ DWORD))aSyscall[52].pCurrent) @@ -1563,6 +1567,7 @@ static BOOL winceLockFileEx( # define INVALID_SET_FILE_POINTER ((DWORD)-1) #endif +#if SQLITE_OS_WINRT==0 /* ** Move the current position of the file handle passed as the first ** argument to offset iOffset within the file. If successful, return 0. @@ -1596,6 +1601,17 @@ static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){ return 0; } +#else /* if SQLITE_OS_WINRT==1 */ +/* +** Same function as above, except that this implementation works for +** windowsRT. +*/ +static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){ + LARGE_INTEGER x; + x.QuadPart = iOffset; + return SetFilePointerEx(pFile->h, x, 0, FILE_BEGIN) ? 0 : 1; +} +#endif /* ** Close a file. From ee3a77de4547793ec1d20e20faf767db5b218e6b Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 1 Mar 2012 22:33:41 +0000 Subject: [PATCH 06/59] Do not run the large file tests if a file named "skip-big-file" exists in the test directory. This enables tests to be run much faster on systems that lack sparse file support. FossilOrigin-Name: 5a83912352ad6626970efd72e70c433e3a219b6b --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/bigfile.test | 2 ++ test/bigfile2.test | 2 ++ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 086698b523..891f0fae2f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sSetFilePointerEx()\sinstead\sof\sSetFilePointer()\son\swinRT. -D 2012-03-01T22:06:30.213 +C Do\snot\srun\sthe\slarge\sfile\stests\sif\sa\sfile\snamed\s"skip-big-file"\sexists\nin\sthe\stest\sdirectory.\s\sThis\senables\stests\sto\sbe\srun\smuch\sfaster\son\nsystems\sthat\slack\ssparse\sfile\ssupport. +D 2012-03-01T22:33:41.379 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -296,8 +296,8 @@ F test/backup_malloc.test 7162d604ec2b4683c4b3799a48657fb8b5e2d450 F test/badutf.test d5360fc31f643d37a973ab0d8b4fb85799c3169f F test/badutf2.test f5bc7f2d280670ecd79b9cf4f0f1760c607fe51f F test/between.test 16b1776c6323faadb097a52d673e8e3d8be7d070 -F test/bigfile.test a8ec8073a20207456dab01a29ad9cde42b0dd103 -F test/bigfile2.test f8e83eca9abef60692a34255a2ebcb96aff897fc +F test/bigfile.test 40922053e5fa37b5e1277183d8392d7ce9fe632f +F test/bigfile2.test 284026c778fcb97d16a4438c921458ad6e2ecd09 F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747 F test/bind.test 3c7b320969000c441a70952b0b15938fbb66237c F test/bindxfer.test efecd12c580c14df5f4ad3b3e83c667744a4f7e0 @@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P bf897be0daa2f7e16f63b78849ffb76ce02d48f1 -R c83dc412475e58f58086f3dd45db2c02 +P 36efafc618017b6448f222776d0143e5f98d1e65 +R 86df3dcfb999c945a7ab3c5f3898aaba U drh -Z c05dce97a97e437048d5758229e96bc3 +Z a38013646615f1ec6a50fcd20d1bf262 diff --git a/manifest.uuid b/manifest.uuid index f7ff822478..6932e7e039 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -36efafc618017b6448f222776d0143e5f98d1e65 \ No newline at end of file +5a83912352ad6626970efd72e70c433e3a219b6b \ No newline at end of file diff --git a/test/bigfile.test b/test/bigfile.test index 52d74edbe6..404194fe58 100644 --- a/test/bigfile.test +++ b/test/bigfile.test @@ -15,6 +15,8 @@ # $Id: bigfile.test,v 1.12 2009/03/05 04:27:08 shane Exp $ # +if {[file exists skip-big-file]} return + set testdir [file dirname $argv0] source $testdir/tester.tcl diff --git a/test/bigfile2.test b/test/bigfile2.test index 9810d3a0f3..bfeed4de72 100644 --- a/test/bigfile2.test +++ b/test/bigfile2.test @@ -13,6 +13,8 @@ # files larger than 4GB. # +if {[file exists skip-big-file]} return + set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix bigfile2 From 24560d16e9bd1830eb60531e8f9f14e0f3444212 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 1 Mar 2012 22:44:56 +0000 Subject: [PATCH 07/59] Use GetInformationByHandleEx() instead of GetFileSize() on winRT. FossilOrigin-Name: 119f251de77aa88cf8ff9fcc72bfbecbe6b741e3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 42 +++++++++++++++++++++++++++++++----------- 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 891f0fae2f..584968e7cd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\srun\sthe\slarge\sfile\stests\sif\sa\sfile\snamed\s"skip-big-file"\sexists\nin\sthe\stest\sdirectory.\s\sThis\senables\stests\sto\sbe\srun\smuch\sfaster\son\nsystems\sthat\slack\ssparse\sfile\ssupport. -D 2012-03-01T22:33:41.379 +C Use\sGetInformationByHandleEx()\sinstead\sof\sGetFileSize()\son\swinRT. +D 2012-03-01T22:44:56.767 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h c3a9db9e8e16f564e1a40cea1687dad69634262c F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c f5d551ef6c6988fb5ed96c4f60eb67bd5cce78e4 +F src/os_win.c c7fc501c60d979dc038de0d893c37aff2af754c3 F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 36efafc618017b6448f222776d0143e5f98d1e65 -R 86df3dcfb999c945a7ab3c5f3898aaba +P 5a83912352ad6626970efd72e70c433e3a219b6b +R 97ff50ee0fb884b5de3a1afe57f30d4e U drh -Z a38013646615f1ec6a50fcd20d1bf262 +Z de1a0224f4c15abe9eff3a7b951c1850 diff --git a/manifest.uuid b/manifest.uuid index 6932e7e039..693bf5bf2a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5a83912352ad6626970efd72e70c433e3a219b6b \ No newline at end of file +119f251de77aa88cf8ff9fcc72bfbecbe6b741e3 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 526dd5a844..91ecaaebc7 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -388,7 +388,11 @@ static struct win_syscall { #define osGetFileAttributesExW ((BOOL(WINAPI*)(LPCWSTR,GET_FILEEX_INFO_LEVELS, \ LPVOID))aSyscall[22].pCurrent) +#if SQLITE_OS_WINRT + { "GetFileSize", (SYSCALL)0, 0 }, +#else { "GetFileSize", (SYSCALL)GetFileSize, 0 }, +#endif #define osGetFileSize ((DWORD(WINAPI*)(HANDLE,LPDWORD))aSyscall[23].pCurrent) @@ -1861,23 +1865,39 @@ static int winSync(sqlite3_file *id, int flags){ ** Determine the current size of a file in bytes */ static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){ - DWORD upperBits; - DWORD lowerBits; winFile *pFile = (winFile*)id; - DWORD lastErrno; + int rc = SQLITE_OK; assert( id!=0 ); SimulateIOError(return SQLITE_IOERR_FSTAT); - lowerBits = osGetFileSize(pFile->h, &upperBits); - if( (lowerBits == INVALID_FILE_SIZE) - && ((lastErrno = osGetLastError())!=NO_ERROR) ) +#if SQLITE_OS_WINRT { - pFile->lastErrno = lastErrno; - return winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno, - "winFileSize", pFile->zPath); + FILE_STANDARD_INFO info; + if( GetFileInformationByHandleEx(pFile->h, FileStandardInfo, + &info, sizeof(info)) ){ + *pSize = info.EndOfFile.QuadPart; + }else{ + rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno, + "winFileSize", pFile->zPath); + } } - *pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits; - return SQLITE_OK; +#else + { + DWORD upperBits; + DWORD lowerBits; + DWORD lastErrno; + + lowerBits = osGetFileSize(pFile->h, &upperBits); + *pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits; + if( (lowerBits == INVALID_FILE_SIZE) + && ((lastErrno = osGetLastError())!=NO_ERROR) ){ + pFile->lastErrno = lastErrno; + rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno, + "winFileSize", pFile->zPath); + } + } +#endif + return rc; } /* From d52ee7298e3e449a1420057847c11e1456b12e77 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 2 Mar 2012 00:00:47 +0000 Subject: [PATCH 08/59] Omit all ANSI APIs for winRT. FossilOrigin-Name: cbf23b461f599d0b025c0f42dd3189cfa4e84bac --- manifest | 12 +++--- manifest.uuid | 2 +- src/os_win.c | 115 ++++++++++++++++++++------------------------------ 3 files changed, 52 insertions(+), 77 deletions(-) diff --git a/manifest b/manifest index 584968e7cd..5c40cd08c1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sGetInformationByHandleEx()\sinstead\sof\sGetFileSize()\son\swinRT. -D 2012-03-01T22:44:56.767 +C Omit\sall\sANSI\sAPIs\sfor\swinRT. +D 2012-03-02T00:00:47.578 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h c3a9db9e8e16f564e1a40cea1687dad69634262c F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c c7fc501c60d979dc038de0d893c37aff2af754c3 +F src/os_win.c 5593c84adc6717f6bf5c458d1f07cc4791a934e0 F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 5a83912352ad6626970efd72e70c433e3a219b6b -R 97ff50ee0fb884b5de3a1afe57f30d4e +P 119f251de77aa88cf8ff9fcc72bfbecbe6b741e3 +R 28c9f3fe3a37af201beee74056883c04 U drh -Z de1a0224f4c15abe9eff3a7b951c1850 +Z 229978c984d0d009c0d2a08c187d7dfd diff --git a/manifest.uuid b/manifest.uuid index 693bf5bf2a..40c8a48a07 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -119f251de77aa88cf8ff9fcc72bfbecbe6b741e3 \ No newline at end of file +cbf23b461f599d0b025c0f42dd3189cfa4e84bac \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 91ecaaebc7..5c590e2591 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -168,7 +168,7 @@ int sqlite3_os_type = 0; static int sqlite3_os_type = 0; #endif -#if !SQLITE_OS_WINCE || SQLITE_OS_WINRT +#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT # define SQLITE_WIN32_HAS_ANSI #endif @@ -1109,12 +1109,9 @@ static int getLastErrorMsg(DWORD lastErrno, int nBuf, char *zBuf){ /* free the system buffer allocated by FormatMessage */ osLocalFree(zTempWide); } -/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. -** Since the ANSI version of these Windows API do not exist for WINCE, -** it's important to not reference them for WINCE builds. -*/ -#if SQLITE_OS_WINCE==0 - }else{ + } +#ifdef SQLITE_WIN32_HAS_ANSI + else{ char *zTemp = NULL; dwLen = osFormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | @@ -1133,8 +1130,8 @@ static int getLastErrorMsg(DWORD lastErrno, int nBuf, char *zBuf){ /* free the system buffer allocated by FormatMessage */ osLocalFree(zTemp); } -#endif } +#endif if( 0 == dwLen ){ sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", lastErrno, lastErrno); }else{ @@ -1921,16 +1918,15 @@ static int getReadLock(winFile *pFile){ ovlp.hEvent = 0; res = osLockFileEx(pFile->h, LOCKFILE_FAIL_IMMEDIATELY, 0, SHARED_SIZE, 0, &ovlp); -/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. -*/ -#if SQLITE_OS_WINCE==0 - }else{ + } +#ifdef SQLITE_WIN32_HAS_ANSI + else{ int lk; sqlite3_randomness(sizeof(lk), &lk); pFile->sharedLockByte = (short)((lk & 0x7fffffff)%(SHARED_SIZE - 1)); res = osLockFile(pFile->h, SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0); -#endif } +#endif if( res == 0 ){ pFile->lastErrno = osGetLastError(); /* No need to log a failure to lock */ @@ -1946,13 +1942,12 @@ static int unlockReadLock(winFile *pFile){ DWORD lastErrno; if( isNT() ){ res = osUnlockFile(pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0); -/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. -*/ -#if SQLITE_OS_WINCE==0 - }else{ - res = osUnlockFile(pFile->h, SHARED_FIRST + pFile->sharedLockByte, 0, 1, 0); -#endif } +#ifdef SQLITE_WIN32_HAS_ANSI + else{ + res = osUnlockFile(pFile->h, SHARED_FIRST + pFile->sharedLockByte, 0, 1, 0); + } +#endif if( res==0 && ((lastErrno = osGetLastError())!=ERROR_NOT_LOCKED) ){ pFile->lastErrno = lastErrno; winLogError(SQLITE_IOERR_UNLOCK, pFile->lastErrno, @@ -2962,13 +2957,12 @@ static void *convertUtf8Filename(const char *zFilename){ void *zConverted = 0; if( isNT() ){ zConverted = utf8ToUnicode(zFilename); -/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. -*/ -#if SQLITE_OS_WINCE==0 - }else{ - zConverted = sqlite3_win32_utf8_to_mbcs(zFilename); -#endif } +#ifdef SQLITE_WIN32_HAS_ANSI + else{ + zConverted = sqlite3_win32_utf8_to_mbcs(zFilename); + } +#endif /* caller will handle out of memory */ return zConverted; } @@ -3004,12 +2998,9 @@ static int getTempname(int nBuf, char *zBuf){ }else{ return SQLITE_IOERR_NOMEM; } -/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. -** Since the ANSI version of these Windows API do not exist for WINCE, -** it's important to not reference them for WINCE builds. -*/ -#if SQLITE_OS_WINCE==0 - }else{ + } +#ifdef SQLITE_WIN32_HAS_ANSI + else{ char *zUtf8; char zMbcsPath[MAX_PATH]; osGetTempPathA(MAX_PATH-30, zMbcsPath); @@ -3020,8 +3011,8 @@ static int getTempname(int nBuf, char *zBuf){ }else{ return SQLITE_IOERR_NOMEM; } -#endif } +#endif /* Check that the output buffer is large enough for the temporary file ** name. If it is not, return SQLITE_ERROR. @@ -3203,12 +3194,9 @@ static int winOpen( dwFlagsAndAttributes, NULL))==INVALID_HANDLE_VALUE && retryIoerr(&cnt, &lastErrno) ){} -/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. -** Since the ANSI version of these Windows API do not exist for WINCE, -** it's important to not reference them for WINCE builds. -*/ -#if SQLITE_OS_WINCE==0 - }else{ + } +#ifdef SQLITE_WIN32_HAS_ANSI + else{ while( (h = osCreateFileA((LPCSTR)zConverted, dwDesiredAccess, dwShareMode, NULL, @@ -3216,9 +3204,8 @@ static int winOpen( dwFlagsAndAttributes, NULL))==INVALID_HANDLE_VALUE && retryIoerr(&cnt, &lastErrno) ){} -#endif } - +#endif logIoerr(cnt); OSTRACE(("OPEN %d %s 0x%lx %s\n", @@ -3310,18 +3297,15 @@ static int winDelete( while( osGetFileAttributesW(zConverted)!=INVALID_FILE_ATTRIBUTES && (rc = osDeleteFileW(zConverted))==0 && retryIoerr(&cnt, &lastErrno) ){} rc = rc ? SQLITE_OK : SQLITE_ERROR; -/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. -** Since the ANSI version of these Windows API do not exist for WINCE, -** it's important to not reference them for WINCE builds. -*/ -#if SQLITE_OS_WINCE==0 - }else{ + } +#ifdef SQLITE_WIN32_HAS_ANSI + else{ rc = 1; while( osGetFileAttributesA(zConverted)!=INVALID_FILE_ATTRIBUTES && (rc = osDeleteFileA(zConverted))==0 && retryIoerr(&cnt, &lastErrno) ){} rc = rc ? SQLITE_OK : SQLITE_ERROR; -#endif } +#endif if( rc ){ rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, "winDelete", zFilename); @@ -3381,15 +3365,12 @@ static int winAccess( attr = INVALID_FILE_ATTRIBUTES; } } -/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. -** Since the ANSI version of these Windows API do not exist for WINCE, -** it's important to not reference them for WINCE builds. -*/ -#if SQLITE_OS_WINCE==0 - }else{ - attr = osGetFileAttributesA((char*)zConverted); -#endif } +#ifdef SQLITE_WIN32_HAS_ANSI + else{ + attr = osGetFileAttributesA((char*)zConverted); + } +#endif sqlite3_free(zConverted); switch( flags ){ case SQLITE_ACCESS_READ: @@ -3470,12 +3451,9 @@ static int winFullPathname( sqlite3_free(zConverted); zOut = unicodeToUtf8(zTemp); sqlite3_free(zTemp); -/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. -** Since the ANSI version of these Windows API do not exist for WINCE, -** it's important to not reference them for WINCE builds. -*/ -#if SQLITE_OS_WINCE==0 - }else{ + } +#ifdef SQLITE_WIN32_HAS_ANSI + else{ char *zTemp; nByte = osGetFullPathNameA((char*)zConverted, 0, 0, 0) + 3; zTemp = sqlite3_malloc( nByte*sizeof(zTemp[0]) ); @@ -3487,8 +3465,8 @@ static int winFullPathname( sqlite3_free(zConverted); zOut = sqlite3_win32_mbcs_to_utf8(zTemp); sqlite3_free(zTemp); -#endif } +#endif if( zOut ){ sqlite3_snprintf(pVfs->mxPathname, zFull, "%s", zOut); sqlite3_free(zOut); @@ -3517,15 +3495,12 @@ static void *winDlOpen(sqlite3_vfs *pVfs, const char *zFilename){ } if( isNT() ){ h = osLoadLibraryW((LPCWSTR)zConverted); -/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. -** Since the ANSI version of these Windows API do not exist for WINCE, -** it's important to not reference them for WINCE builds. -*/ -#if SQLITE_OS_WINCE==0 - }else{ - h = osLoadLibraryA((char*)zConverted); -#endif } +#ifdef SQLITE_WIN32_HAS_ANSI + else{ + h = osLoadLibraryA((char*)zConverted); + } +#endif sqlite3_free(zConverted); return (void*)h; } From 75b70a2087dbb4b4f41772fe4c49309a41a52797 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 2 Mar 2012 13:47:16 +0000 Subject: [PATCH 09/59] Add new Win32 APIs used to the system call table. Add error handling code for SetFilePointerEx. Make sure the last error number is saved from the call to GetFileInformationByHandleEx. FossilOrigin-Name: a782d2dc3cd4ef49ed46b361cdd331be846c3d50 --- manifest | 14 +++++------ manifest.uuid | 2 +- src/os_win.c | 69 +++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 69 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 5c40cd08c1..2f9e043fbf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\sall\sANSI\sAPIs\sfor\swinRT. -D 2012-03-02T00:00:47.578 +C Add\snew\sWin32\sAPIs\sused\sto\sthe\ssystem\scall\stable.\s\sAdd\serror\shandling\scode\sfor\sSetFilePointerEx.\s\sMake\ssure\sthe\slast\serror\snumber\sis\ssaved\sfrom\sthe\scall\sto\sGetFileInformationByHandleEx. +D 2012-03-02T13:47:16.837 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h c3a9db9e8e16f564e1a40cea1687dad69634262c F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c 5593c84adc6717f6bf5c458d1f07cc4791a934e0 +F src/os_win.c 7378d50e4f8c3dafc0c11ca99615801c84329a4d F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 119f251de77aa88cf8ff9fcc72bfbecbe6b741e3 -R 28c9f3fe3a37af201beee74056883c04 -U drh -Z 229978c984d0d009c0d2a08c187d7dfd +P cbf23b461f599d0b025c0f42dd3189cfa4e84bac +R f72d2ca1c8333360bf3d39a3248646ef +U mistachkin +Z bc3c857da09d5ea46a27e32ed356379b diff --git a/manifest.uuid b/manifest.uuid index 40c8a48a07..30bb20d31a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cbf23b461f599d0b025c0f42dd3189cfa4e84bac \ No newline at end of file +a782d2dc3cd4ef49ed46b361cdd331be846c3d50 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 5c590e2591..bc8bf3e267 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -625,6 +625,47 @@ static struct win_syscall { #define osWriteFile ((BOOL(WINAPI*)(HANDLE,LPCVOID,DWORD,LPDWORD, \ LPOVERLAPPED))aSyscall[59].pCurrent) +#if !SQLITE_OS_WINCE + { "CreateEventEx", (SYSCALL)CreateEventEx, 0 }, + +#define osCreateEventEx ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,LPCTSTR, \ + DWORD,DWORD))aSyscall[60].pCurrent) +#else + { "CreateEventEx", (SYSCALL)0, 0 }, +#endif + + { "WaitForSingleObject", (SYSCALL)WaitForSingleObject, 0 }, + +#define osWaitForSingleObject ((DWORD(WINAPI*)(HANDLE, \ + DWORD))aSyscall[61].pCurrent) + +#if !SQLITE_OS_WINCE + { "WaitForSingleObjectEx", (SYSCALL)WaitForSingleObjectEx, 0 }, + +#define osWaitForSingleObjectEx ((DWORD(WINAPI*)(HANDLE,DWORD, \ + BOOL))aSyscall[62].pCurrent) +#else + { "WaitForSingleObjectEx", (SYSCALL)0, 0 }, +#endif + +#if !SQLITE_OS_WINCE + { "SetFilePointerEx", (SYSCALL)SetFilePointerEx, 0 }, + +#define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \ + PLARGE_INTEGER,DWORD))aSyscall[63].pCurrent) +#else + { "SetFilePointerEx", (SYSCALL)0, 0 }, +#endif + +#if !SQLITE_OS_WINCE + { "GetFileInformationByHandleEx", (SYSCALL)GetFileInformationByHandleEx, 0 }, + +#define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \ + FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[64].pCurrent) +#else + { "GetFileInformationByHandleEx", (SYSCALL)0, 0 }, +#endif + }; /* End of the overrideable system calls */ /* @@ -717,7 +758,7 @@ static const char *winNextSystemCall(sqlite3_vfs *p, const char *zName){ #if SQLITE_OS_WINRT static HANDLE sleepObj; static void portableSleep(int ms){ - WaitForSingleObjectEx(sleepObj, ms, FALSE); + osWaitForSingleObjectEx(sleepObj, ms, FALSE); } #else static void portableSleep(int ms){ @@ -1275,7 +1316,7 @@ struct tm *__cdecl localtime(const time_t *t) static void winceMutexAcquire(HANDLE h){ DWORD dwErr; do { - dwErr = WaitForSingleObject(h, INFINITE); + dwErr = osWaitForSingleObject(h, INFINITE); } while (dwErr != WAIT_OBJECT_0 && dwErr != WAIT_ABANDONED); } /* @@ -1608,9 +1649,20 @@ static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){ ** windowsRT. */ static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){ - LARGE_INTEGER x; + LARGE_INTEGER x; /* The new offset */ + BOOL bRet; /* Value returned by SetFilePointerEx() */ + x.QuadPart = iOffset; - return SetFilePointerEx(pFile->h, x, 0, FILE_BEGIN) ? 0 : 1; + bRet = osSetFilePointerEx(pFile->h, x, 0, FILE_BEGIN); + + if(!bRet){ + pFile->lastErrno = osGetLastError(); + winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno, + "seekWinFile", pFile->zPath); + return 1; + } + + return 0; } #endif @@ -1870,10 +1922,11 @@ static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){ #if SQLITE_OS_WINRT { FILE_STANDARD_INFO info; - if( GetFileInformationByHandleEx(pFile->h, FileStandardInfo, + if( osGetFileInformationByHandleEx(pFile->h, FileStandardInfo, &info, sizeof(info)) ){ *pSize = info.EndOfFile.QuadPart; }else{ + pFile->lastErrno = osGetLastError(); rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno, "winFileSize", pFile->zPath); } @@ -3707,10 +3760,10 @@ int sqlite3_os_init(void){ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ - assert( ArraySize(aSyscall)==60 ); + assert( ArraySize(aSyscall)==65 ); #if SQLITE_OS_WINRT - sleepObj = CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, + sleepObj = osCreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS); #endif @@ -3727,7 +3780,7 @@ int sqlite3_os_init(void){ int sqlite3_os_end(void){ #if SQLITE_OS_WINRT - CloseHandle(sleepObj); + osCloseHandle(sleepObj); #endif return SQLITE_OK; } From 2a5cfb31fdf2f94a3c3ef0ac63177b31a044f8a5 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 2 Mar 2012 22:38:49 +0000 Subject: [PATCH 10/59] When running on Windows with an NT-based kernel, always use the LockFileEx/UnlockFileEx functions (with the correct flags). FossilOrigin-Name: 3e7ba3ddb956056b8132ed383feed4f329c634e0 --- manifest | 12 ++--- manifest.uuid | 2 +- src/os_win.c | 118 +++++++++++++++++++++++++++++++++++++------------- 3 files changed, 96 insertions(+), 36 deletions(-) diff --git a/manifest b/manifest index 2f9e043fbf..3a094cf7f5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\snew\sWin32\sAPIs\sused\sto\sthe\ssystem\scall\stable.\s\sAdd\serror\shandling\scode\sfor\sSetFilePointerEx.\s\sMake\ssure\sthe\slast\serror\snumber\sis\ssaved\sfrom\sthe\scall\sto\sGetFileInformationByHandleEx. -D 2012-03-02T13:47:16.837 +C When\srunning\son\sWindows\swith\san\sNT-based\skernel,\salways\suse\sthe\sLockFileEx/UnlockFileEx\sfunctions\s(with\sthe\scorrect\sflags). +D 2012-03-02T22:38:49.501 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h c3a9db9e8e16f564e1a40cea1687dad69634262c F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c 7378d50e4f8c3dafc0c11ca99615801c84329a4d +F src/os_win.c f6b9fa7a93d16779b0504d8c5d438fdd0ef022bb F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P cbf23b461f599d0b025c0f42dd3189cfa4e84bac -R f72d2ca1c8333360bf3d39a3248646ef +P a782d2dc3cd4ef49ed46b361cdd331be846c3d50 +R 5657a63a45c0ba0c63e40023bb562ed0 U mistachkin -Z bc3c857da09d5ea46a27e32ed356379b +Z a7d3129db9e33b537945aea438ba067d diff --git a/manifest.uuid b/manifest.uuid index 30bb20d31a..7b9f86ea2e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a782d2dc3cd4ef49ed46b361cdd331be846c3d50 \ No newline at end of file +3e7ba3ddb956056b8132ed383feed4f329c634e0 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index bc8bf3e267..4c56392a6d 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -1277,6 +1277,49 @@ static void logIoerr(int nRetry){ } } +/* +** Lock a file region. +*/ +static BOOL winLockFile( + HANDLE hFile, + DWORD flags, + DWORD offsetLow, + DWORD offsetHigh, + DWORD numBytesLow, + DWORD numBytesHigh +){ + if( isNT() ){ + OVERLAPPED ovlp; + memset(&ovlp, 0, sizeof(OVERLAPPED)); + ovlp.Offset = offsetLow; + ovlp.OffsetHigh = offsetHigh; + return osLockFileEx(hFile, flags, 0, numBytesLow, numBytesHigh, &ovlp); + }else{ + return osLockFile(hFile, offsetLow, offsetHigh, numBytesLow, numBytesHigh); + } +} + +/* +** Unlock a file region. + */ +static BOOL winUnlockFile( + HANDLE hFile, + DWORD offsetLow, + DWORD offsetHigh, + DWORD numBytesLow, + DWORD numBytesHigh +){ + if( isNT() ){ + OVERLAPPED ovlp; + memset(&ovlp, 0, sizeof(OVERLAPPED)); + ovlp.Offset = offsetLow; + ovlp.OffsetHigh = offsetHigh; + return osUnlockFileEx(hFile, 0, numBytesLow, numBytesHigh, &ovlp); + }else{ + return osUnlockFile(hFile, offsetLow, offsetHigh, numBytesLow, numBytesHigh); + } +} + #if SQLITE_OS_WINCE /************************************************************************* ** This section contains code for WinCE only. @@ -1957,6 +2000,30 @@ static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){ # define LOCKFILE_FAIL_IMMEDIATELY 1 #endif +#ifndef LOCKFILE_EXCLUSIVE_LOCK +# define LOCKFILE_EXCLUSIVE_LOCK 2 +#endif + +/* +** Historically, SQLite has used both the LockFile and LockFileEx functions. +** When the LockFile function was used, it was always expected to fail +** immediately if the lock could not be obtained. Also, it always expected to +** obtain an exclusive lock. These flags are used with the LockFileEx function +** and reflect those expectations; therefore, they should not be changed. +*/ +#ifndef SQLITE_LOCKFILE_FLAGS +# define SQLITE_LOCKFILE_FLAGS (LOCKFILE_FAIL_IMMEDIATELY | \ + LOCKFILE_EXCLUSIVE_LOCK) +#endif + +/* +** Currently, SQLite never calls the LockFileEx function without wanting the +** call to fail immediately if the lock cannot be obtained. +*/ +#ifndef SQLITE_LOCKFILEEX_FLAGS +# define SQLITE_LOCKFILEEX_FLAGS (LOCKFILE_FAIL_IMMEDIATELY) +#endif + /* ** Acquire a reader lock. ** Different API routines are called depending on whether or not this @@ -1965,19 +2032,16 @@ static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){ static int getReadLock(winFile *pFile){ int res; if( isNT() ){ - OVERLAPPED ovlp; - ovlp.Offset = SHARED_FIRST; - ovlp.OffsetHigh = 0; - ovlp.hEvent = 0; - res = osLockFileEx(pFile->h, LOCKFILE_FAIL_IMMEDIATELY, - 0, SHARED_SIZE, 0, &ovlp); + res = winLockFile(pFile->h, SQLITE_LOCKFILEEX_FLAGS, SHARED_FIRST, 0, + SHARED_SIZE, 0); } #ifdef SQLITE_WIN32_HAS_ANSI else{ int lk; sqlite3_randomness(sizeof(lk), &lk); pFile->sharedLockByte = (short)((lk & 0x7fffffff)%(SHARED_SIZE - 1)); - res = osLockFile(pFile->h, SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0); + res = winLockFile(pFile->h, SQLITE_LOCKFILE_FLAGS, + SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0); } #endif if( res == 0 ){ @@ -1994,11 +2058,11 @@ static int unlockReadLock(winFile *pFile){ int res; DWORD lastErrno; if( isNT() ){ - res = osUnlockFile(pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0); + res = winUnlockFile(pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0); } #ifdef SQLITE_WIN32_HAS_ANSI else{ - res = osUnlockFile(pFile->h, SHARED_FIRST + pFile->sharedLockByte, 0, 1, 0); + res = winUnlockFile(pFile->h, SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0); } #endif if( res==0 && ((lastErrno = osGetLastError())!=ERROR_NOT_LOCKED) ){ @@ -2071,7 +2135,8 @@ static int winLock(sqlite3_file *id, int locktype){ && (pFile->locktype==RESERVED_LOCK)) ){ int cnt = 3; - while( cnt-->0 && (res = osLockFile(pFile->h, PENDING_BYTE, 0, 1, 0))==0 ){ + while( cnt-->0 && (res = winLockFile(pFile->h, SQLITE_LOCKFILE_FLAGS, + PENDING_BYTE, 0, 1, 0))==0 ){ /* Try 3 times to get the pending lock. This is needed to work ** around problems caused by indexing and/or anti-virus software on ** Windows systems. @@ -2103,7 +2168,7 @@ static int winLock(sqlite3_file *id, int locktype){ */ if( locktype==RESERVED_LOCK && res ){ assert( pFile->locktype==SHARED_LOCK ); - res = osLockFile(pFile->h, RESERVED_BYTE, 0, 1, 0); + res = winLockFile(pFile->h, SQLITE_LOCKFILE_FLAGS, RESERVED_BYTE, 0, 1, 0); if( res ){ newLocktype = RESERVED_LOCK; }else{ @@ -2124,7 +2189,8 @@ static int winLock(sqlite3_file *id, int locktype){ assert( pFile->locktype>=SHARED_LOCK ); res = unlockReadLock(pFile); OSTRACE(("unreadlock = %d\n", res)); - res = osLockFile(pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0); + res = winLockFile(pFile->h, SQLITE_LOCKFILE_FLAGS, SHARED_FIRST, 0, + SHARED_SIZE, 0); if( res ){ newLocktype = EXCLUSIVE_LOCK; }else{ @@ -2138,7 +2204,7 @@ static int winLock(sqlite3_file *id, int locktype){ ** release it now. */ if( gotPendingLock && locktype==SHARED_LOCK ){ - osUnlockFile(pFile->h, PENDING_BYTE, 0, 1, 0); + winUnlockFile(pFile->h, PENDING_BYTE, 0, 1, 0); } /* Update the state of the lock has held in the file descriptor then @@ -2172,9 +2238,9 @@ static int winCheckReservedLock(sqlite3_file *id, int *pResOut){ rc = 1; OSTRACE(("TEST WR-LOCK %d %d (local)\n", pFile->h, rc)); }else{ - rc = osLockFile(pFile->h, RESERVED_BYTE, 0, 1, 0); + rc = winLockFile(pFile->h, SQLITE_LOCKFILE_FLAGS, RESERVED_BYTE, 0, 1, 0); if( rc ){ - osUnlockFile(pFile->h, RESERVED_BYTE, 0, 1, 0); + winUnlockFile(pFile->h, RESERVED_BYTE, 0, 1, 0); } rc = !rc; OSTRACE(("TEST WR-LOCK %d %d (remote)\n", pFile->h, rc)); @@ -2204,7 +2270,7 @@ static int winUnlock(sqlite3_file *id, int locktype){ pFile->locktype, pFile->sharedLockByte)); type = pFile->locktype; if( type>=EXCLUSIVE_LOCK ){ - osUnlockFile(pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0); + winUnlockFile(pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0); if( locktype==SHARED_LOCK && !getReadLock(pFile) ){ /* This should never happen. We should always be able to ** reacquire the read lock */ @@ -2213,13 +2279,13 @@ static int winUnlock(sqlite3_file *id, int locktype){ } } if( type>=RESERVED_LOCK ){ - osUnlockFile(pFile->h, RESERVED_BYTE, 0, 1, 0); + winUnlockFile(pFile->h, RESERVED_BYTE, 0, 1, 0); } if( locktype==NO_LOCK && type>=SHARED_LOCK ){ unlockReadLock(pFile); } if( type>=PENDING_LOCK ){ - osUnlockFile(pFile->h, PENDING_BYTE, 0, 1, 0); + winUnlockFile(pFile->h, PENDING_BYTE, 0, 1, 0); } pFile->locktype = (u8)locktype; return rc; @@ -2457,25 +2523,19 @@ static int winShmSystemLock( int ofst, /* Offset to first byte to be locked/unlocked */ int nByte /* Number of bytes to lock or unlock */ ){ - OVERLAPPED ovlp; - DWORD dwFlags; int rc = 0; /* Result code form Lock/UnlockFileEx() */ /* Access to the winShmNode object is serialized by the caller */ assert( sqlite3_mutex_held(pFile->mutex) || pFile->nRef==0 ); - /* Initialize the locking parameters */ - dwFlags = LOCKFILE_FAIL_IMMEDIATELY; - if( lockType == _SHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK; - - memset(&ovlp, 0, sizeof(OVERLAPPED)); - ovlp.Offset = ofst; - /* Release/Acquire the system-level lock */ if( lockType==_SHM_UNLCK ){ - rc = osUnlockFileEx(pFile->hFile.h, 0, nByte, 0, &ovlp); + rc = winUnlockFile(pFile->hFile.h, ofst, 0, nByte, 0); }else{ - rc = osLockFileEx(pFile->hFile.h, dwFlags, 0, nByte, 0, &ovlp); + /* Initialize the locking parameters */ + DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY; + if( lockType == _SHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK; + rc = winLockFile(pFile->hFile.h, dwFlags, ofst, 0, nByte, 0); } if( rc!= 0 ){ From 62d1924fc53aacdc30fc2e62f66bf3ffb82baa2c Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 2 Mar 2012 23:53:54 +0000 Subject: [PATCH 11/59] When compiled for WinRT, avoid using the FORMAT_MESSAGE_ALLOCATE_BUFFER flag to FormatMessage (i.e. because LocalFree is unavailable). FossilOrigin-Name: 9eb331be7e905d11d9075ce1596478b55a7f488b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 3a094cf7f5..d7e73c5cf1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\srunning\son\sWindows\swith\san\sNT-based\skernel,\salways\suse\sthe\sLockFileEx/UnlockFileEx\sfunctions\s(with\sthe\scorrect\sflags). -D 2012-03-02T22:38:49.501 +C When\scompiled\sfor\sWinRT,\savoid\susing\sthe\sFORMAT_MESSAGE_ALLOCATE_BUFFER\sflag\sto\sFormatMessage\s(i.e.\sbecause\sLocalFree\sis\sunavailable). +D 2012-03-02T23:53:54.759 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h c3a9db9e8e16f564e1a40cea1687dad69634262c F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c f6b9fa7a93d16779b0504d8c5d438fdd0ef022bb +F src/os_win.c bde6f1867d1fca808dabf43f8caaa7130b3e666a F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P a782d2dc3cd4ef49ed46b361cdd331be846c3d50 -R 5657a63a45c0ba0c63e40023bb562ed0 +P 3e7ba3ddb956056b8132ed383feed4f329c634e0 +R fa5ae504586a17ee7bea7c3ad368dd9c U mistachkin -Z a7d3129db9e33b537945aea438ba067d +Z c2c4f50ec9e4a87a7802b817ca07287e diff --git a/manifest.uuid b/manifest.uuid index 7b9f86ea2e..e7a6bb185c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3e7ba3ddb956056b8132ed383feed4f329c634e0 \ No newline at end of file +9eb331be7e905d11d9075ce1596478b55a7f488b \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 4c56392a6d..4dddece33c 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -1132,6 +1132,17 @@ static int getLastErrorMsg(DWORD lastErrno, int nBuf, char *zBuf){ char *zOut = 0; if( isNT() ){ +#if SQLITE_OS_WINRT + WCHAR zTempWide[MAX_PATH+1]; /* NOTE: Somewhat arbitrary. */ + dwLen = osFormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + lastErrno, + 0, + zTempWide, + MAX_PATH, + 0); +#else LPWSTR zTempWide = NULL; dwLen = osFormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | @@ -1142,13 +1153,16 @@ static int getLastErrorMsg(DWORD lastErrno, int nBuf, char *zBuf){ (LPWSTR) &zTempWide, 0, 0); +#endif if( dwLen > 0 ){ /* allocate a buffer and convert to UTF8 */ sqlite3BeginBenignMalloc(); zOut = unicodeToUtf8(zTempWide); sqlite3EndBenignMalloc(); +#if !SQLITE_OS_WINRT /* free the system buffer allocated by FormatMessage */ osLocalFree(zTempWide); +#endif } } #ifdef SQLITE_WIN32_HAS_ANSI From 287a48d67bf56c6a9d276393d1268e4c1fd8ef53 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 3 Mar 2012 13:15:25 +0000 Subject: [PATCH 12/59] When compiled for WinRT, avoid using MapViewOfFile and GetFileAttributes. Also, reset the private 'sleep' event handle when the VFS is cleaned up. FossilOrigin-Name: 38df8fc1b49d55b61cb168a61134b4a314a62f21 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 24 +++++++++++++++++++++--- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index d7e73c5cf1..6da3310223 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\scompiled\sfor\sWinRT,\savoid\susing\sthe\sFORMAT_MESSAGE_ALLOCATE_BUFFER\sflag\sto\sFormatMessage\s(i.e.\sbecause\sLocalFree\sis\sunavailable). -D 2012-03-02T23:53:54.759 +C When\scompiled\sfor\sWinRT,\savoid\susing\sMapViewOfFile\sand\sGetFileAttributes.\s\sAlso,\sreset\sthe\sprivate\s'sleep'\sevent\shandle\swhen\sthe\sVFS\sis\scleaned\sup. +D 2012-03-03T13:15:25.497 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h c3a9db9e8e16f564e1a40cea1687dad69634262c F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c bde6f1867d1fca808dabf43f8caaa7130b3e666a +F src/os_win.c 26867d8bafe695eeb48b24859bbd7a2d56cbd9fe F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 3e7ba3ddb956056b8132ed383feed4f329c634e0 -R fa5ae504586a17ee7bea7c3ad368dd9c +P 9eb331be7e905d11d9075ce1596478b55a7f488b +R aeb2dd36cdcdc79eb8c1f0db8889436a U mistachkin -Z c2c4f50ec9e4a87a7802b817ca07287e +Z 3283741a5ac47d4e9a6c7dd3f7a23bf5 diff --git a/manifest.uuid b/manifest.uuid index e7a6bb185c..de170bbabb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9eb331be7e905d11d9075ce1596478b55a7f488b \ No newline at end of file +38df8fc1b49d55b61cb168a61134b4a314a62f21 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 4dddece33c..d48b2f9aa2 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -666,6 +666,11 @@ static struct win_syscall { { "GetFileInformationByHandleEx", (SYSCALL)0, 0 }, #endif + { "MapViewOfFileEx", (SYSCALL)MapViewOfFileEx, 0 }, + +#define osMapViewOfFileEx ((LPVOID(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,SIZE_T, \ + LPVOID))aSyscall[65].pCurrent) + }; /* End of the overrideable system calls */ /* @@ -2996,9 +3001,15 @@ static int winShmMap( if( hMap ){ int iOffset = pShmNode->nRegion*szRegion; int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity; +#if SQLITE_OS_WINRT + pMap = osMapViewOfFileEx(hMap, FILE_MAP_WRITE | FILE_MAP_READ, + 0, iOffset - iOffsetShift, szRegion + iOffsetShift, NULL + ); +#else pMap = osMapViewOfFile(hMap, FILE_MAP_WRITE | FILE_MAP_READ, 0, iOffset - iOffsetShift, szRegion + iOffsetShift ); +#endif OSTRACE(("SHM-MAP pid-%d map region=%d offset=%d size=%d %s\n", (int)osGetCurrentProcessId(), pShmNode->nRegion, iOffset, szRegion, pMap ? "ok" : "failed")); @@ -3419,15 +3430,21 @@ static int winDelete( if( zConverted==0 ){ return SQLITE_IOERR_NOMEM; } + rc = 1; if( isNT() ){ - rc = 1; +#if SQLITE_OS_WINRT + WIN32_FILE_ATTRIBUTE_DATA sAttrData; + memset(&sAttrData, 0, sizeof(sAttrData)); + while( osGetFileAttributesExW(zConverted, GetFileExInfoStandard, + &sAttrData) && +#else while( osGetFileAttributesW(zConverted)!=INVALID_FILE_ATTRIBUTES && +#endif (rc = osDeleteFileW(zConverted))==0 && retryIoerr(&cnt, &lastErrno) ){} rc = rc ? SQLITE_OK : SQLITE_ERROR; } #ifdef SQLITE_WIN32_HAS_ANSI else{ - rc = 1; while( osGetFileAttributesA(zConverted)!=INVALID_FILE_ATTRIBUTES && (rc = osDeleteFileA(zConverted))==0 && retryIoerr(&cnt, &lastErrno) ){} rc = rc ? SQLITE_OK : SQLITE_ERROR; @@ -3834,7 +3851,7 @@ int sqlite3_os_init(void){ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ - assert( ArraySize(aSyscall)==65 ); + assert( ArraySize(aSyscall)==66 ); #if SQLITE_OS_WINRT sleepObj = osCreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, @@ -3855,6 +3872,7 @@ int sqlite3_os_init(void){ int sqlite3_os_end(void){ #if SQLITE_OS_WINRT osCloseHandle(sleepObj); + sleepObj = NULL; #endif return SQLITE_OK; } From 9668e24e62f095eeba92c1189cbc9594b2d60984 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sun, 4 Mar 2012 02:56:10 +0000 Subject: [PATCH 13/59] When creating the event used to sleep on WinRT, request the minimum access rights required for the desired operations on it (i.e. SYNCHRONIZE). FossilOrigin-Name: ed603d75941ace159773b1a22ace84d51b630ad5 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 6da3310223..ca2be09591 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\scompiled\sfor\sWinRT,\savoid\susing\sMapViewOfFile\sand\sGetFileAttributes.\s\sAlso,\sreset\sthe\sprivate\s'sleep'\sevent\shandle\swhen\sthe\sVFS\sis\scleaned\sup. -D 2012-03-03T13:15:25.497 +C When\screating\sthe\sevent\sused\sto\ssleep\son\sWinRT,\srequest\sthe\sminimum\saccess\srights\srequired\sfor\sthe\sdesired\soperations\son\sit\s(i.e.\sSYNCHRONIZE). +D 2012-03-04T02:56:10.693 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h c3a9db9e8e16f564e1a40cea1687dad69634262c F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c 26867d8bafe695eeb48b24859bbd7a2d56cbd9fe +F src/os_win.c a6f5e7b3aaa40a0f6d48f80ba6a6154eea5524a4 F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 9eb331be7e905d11d9075ce1596478b55a7f488b -R aeb2dd36cdcdc79eb8c1f0db8889436a +P 38df8fc1b49d55b61cb168a61134b4a314a62f21 +R bea8bcdd3011a76417163c65bc816faf U mistachkin -Z 3283741a5ac47d4e9a6c7dd3f7a23bf5 +Z e26bbcbaddc8562992c3187976bdb602 diff --git a/manifest.uuid b/manifest.uuid index de170bbabb..8cc2cd9f4e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -38df8fc1b49d55b61cb168a61134b4a314a62f21 \ No newline at end of file +ed603d75941ace159773b1a22ace84d51b630ad5 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index d48b2f9aa2..ead1a76c81 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -3855,7 +3855,7 @@ int sqlite3_os_init(void){ #if SQLITE_OS_WINRT sleepObj = osCreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, - EVENT_ALL_ACCESS); + SYNCHRONIZE); #endif #ifndef SQLITE_OMIT_WAL From c548465435e99d17659005308e664db4c7a65122 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 5 Mar 2012 22:52:33 +0000 Subject: [PATCH 14/59] Add compile-time define to indicate if the VFS supports the concept of a current directory (as WinCE and WinRT do not). Avoid using the GetTempPath and GetFullPathName APIs on WinRT. Some tests still need adjustments. FossilOrigin-Name: 86c049a171acc3f4a43771f3e7176a90210d7799 --- manifest | 26 +++++++++++++------------- manifest.uuid | 2 +- src/ctime.c | 3 +++ src/os.h | 8 ++++++++ src/os_win.c | 15 ++++++++++----- src/test_config.c | 6 ++++++ test/misc1.test | 6 ++++++ test/pager1.test | 35 +++++++++++++++++++++++++++++++---- test/tester.tcl | 7 +++++++ test/wal.test | 6 +++++- 10 files changed, 90 insertions(+), 24 deletions(-) diff --git a/manifest b/manifest index ca2be09591..20c56c9715 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\screating\sthe\sevent\sused\sto\ssleep\son\sWinRT,\srequest\sthe\sminimum\saccess\srights\srequired\sfor\sthe\sdesired\soperations\son\sit\s(i.e.\sSYNCHRONIZE). -D 2012-03-04T02:56:10.693 +C Add\scompile-time\sdefine\sto\sindicate\sif\sthe\sVFS\ssupports\sthe\sconcept\sof\sa\scurrent\sdirectory\s(as\sWinCE\sand\sWinRT\sdo\snot).\s\sAvoid\susing\sthe\sGetTempPath\sand\sGetFullPathName\sAPIs\son\sWinRT.\s\sSome\stests\sstill\sneed\sadjustments. +D 2012-03-05T22:52:33.397 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -131,7 +131,7 @@ F src/btreeInt.h 26d8ca625b141927fe6620c1d2cf58eaf494ca0c F src/build.c c4d36e527f457f9992a6663365871dfa7c5094b8 F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac -F src/ctime.c a9c26822515f81ec21588cbb482ca6724be02e33 +F src/ctime.c 500d019da966631ad957c37705642be87524463b F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4 F src/delete.c 51d32f0a9c880663e54ce309f52e40c325d5e112 F src/expr.c 00675123e0beec98f999aa4594d2cbe1fec33c1b @@ -163,11 +163,11 @@ F src/mutex_unix.c c3a4e00f96ba068a8dbef34084465979aaf369cc F src/mutex_w32.c ddd2a783230e22831ab44fca181b5904e48a7318 F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c -F src/os.h c3a9db9e8e16f564e1a40cea1687dad69634262c +F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c a6f5e7b3aaa40a0f6d48f80ba6a6154eea5524a4 +F src/os_win.c 75d5de49067252dbd98fb8b1a2b2fabe7938e53c F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -202,7 +202,7 @@ F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e F src/test_backup.c c129c91127e9b46e335715ae2e75756e25ba27de F src/test_btree.c 47cd771250f09cdc6e12dda5bc71bc0b3abc96e2 -F src/test_config.c a036a69b550ebc477ab9ca2b37269201f888436e +F src/test_config.c f82aa7dd51f42256ac18ffba3217ebffa9db85a3 F src/test_demovfs.c 20a4975127993f4959890016ae9ce5535a880094 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc F src/test_func.c 6232d722a4ddb193035aa13a03796bf57d6c12fd @@ -603,7 +603,7 @@ F test/minmax.test 722d80816f7e096bf2c04f4111f1a6c1ba65453d F test/minmax2.test 33504c01a03bd99226144e4b03f7631a274d66e0 F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354 F test/minmax4.test 536a3360470633a177e42fbc19660d146b51daef -F test/misc1.test 55cb2bfbf4a8cd61f4be1effc30426ad41696bff +F test/misc1.test 889b40722442380a2f6575f30831b32b2372d70e F test/misc2.test 00d7de54eda90e237fc9a38b9e5ccc769ebf6d4d F test/misc3.test fe55130a43e444ee75e2156ff75dc96e964b5738 F test/misc4.test 9c078510fbfff05a9869a0b6d8b86a623ad2c4f6 @@ -624,7 +624,7 @@ F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347 F test/null.test a8b09b8ed87852742343b33441a9240022108993 F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394 F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3 -F test/pager1.test efef0bb4035d7180ec58308f1d449475e4670b48 +F test/pager1.test a306c33e6fbc4d0e5e22529381226fb71d2bef43 F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1 F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f F test/pagerfault.test 452f2cc23e3bfcfa935f4442aec1da4fe1dc0442 @@ -718,7 +718,7 @@ F test/tclsqlite.test 1597d353308531527583481d14d9da52ea8ed0af F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c F test/temptable.test 51edd31c65ed1560dd600b1796e8325df96318e2 F test/temptrigger.test 26670ed7a39cf2296a7f0a9e0a1d7bdb7abe936d -F test/tester.tcl 001051eaf28c1040800f588a64c63e0bd0e1f36b +F test/tester.tcl 31baf0d92ca1151903b56c0e137ef6a038597c21 F test/thread001.test 7cc2ce08f9cde95964736d11e91f9ab610f82f91 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -906,7 +906,7 @@ F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 F test/vtab_shared.test 82f463886e18d7f8395a4b6167c91815efe54839 -F test/wal.test edefe316b4125d7f68004ea53c5e73c398d436cc +F test/wal.test 396be04083914d3a2970d4a494e321545026c6e2 F test/wal2.test 8871e7fd2c86711ff415a5817d68ea3101a15312 F test/wal3.test 6504bbf348b2d6dfade64a064f1050fd617e8706 F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c @@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 38df8fc1b49d55b61cb168a61134b4a314a62f21 -R bea8bcdd3011a76417163c65bc816faf +P ed603d75941ace159773b1a22ace84d51b630ad5 +R 8dc77ea6ed646d5c79820ac4402d9981 U mistachkin -Z e26bbcbaddc8562992c3187976bdb602 +Z 687362d63f53a7c55f33c0c80d00dc38 diff --git a/manifest.uuid b/manifest.uuid index 8cc2cd9f4e..6c9223a44c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ed603d75941ace159773b1a22ace84d51b630ad5 \ No newline at end of file +86c049a171acc3f4a43771f3e7176a90210d7799 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index 1688069cb3..61cf4e3df1 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -48,6 +48,9 @@ static const char * const azCompileOpt[] = { #ifdef SQLITE_COVERAGE_TEST "COVERAGE_TEST", #endif +#ifdef SQLITE_CURDIR + "CURDIR", +#endif #ifdef SQLITE_DEBUG "DEBUG", #endif diff --git a/src/os.h b/src/os.h index 1416b4672b..2efffff9b6 100644 --- a/src/os.h +++ b/src/os.h @@ -123,6 +123,14 @@ # define SQLITE_OS_WINRT 0 #endif +/* +** When compiled for WinCE or WinRT, there is no concept of the current +** directory. + */ +#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT +# define SQLITE_CURDIR 1 +#endif + /* If the SET_FULLSYNC macro is not defined above, then make it ** a no-op */ diff --git a/src/os_win.c b/src/os_win.c index ead1a76c81..6607120830 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -405,7 +405,7 @@ static struct win_syscall { #define osGetFullPathNameA ((DWORD(WINAPI*)(LPCSTR,DWORD,LPSTR, \ LPSTR*))aSyscall[24].pCurrent) -#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE) +#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) { "GetFullPathNameW", (SYSCALL)GetFullPathNameW, 0 }, #else { "GetFullPathNameW", (SYSCALL)0, 0 }, @@ -455,7 +455,7 @@ static struct win_syscall { #define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent) -#if defined(SQLITE_WIN32_HAS_WIDE) +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) { "GetTempPathW", (SYSCALL)GetTempPathW, 0 }, #else { "GetTempPathW", (SYSCALL)0, 0 }, @@ -3123,9 +3123,13 @@ static int getTempname(int nBuf, char *zBuf){ */ SimulateIOError( return SQLITE_IOERR ); + memset(zTempPath, 0, MAX_PATH+2); + if( sqlite3_temp_directory ){ sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory); - }else if( isNT() ){ + } +#if !SQLITE_OS_WINRT + else if( isNT() ){ char *zMulti; WCHAR zWidePath[MAX_PATH]; osGetTempPathW(MAX_PATH-30, zWidePath); @@ -3150,6 +3154,7 @@ static int getTempname(int nBuf, char *zBuf){ return SQLITE_IOERR_NOMEM; } } +#endif #endif /* Check that the output buffer is large enough for the temporary file @@ -3552,7 +3557,7 @@ static int winFullPathname( return SQLITE_OK; #endif -#if SQLITE_OS_WINCE +#if SQLITE_OS_WINCE || SQLITE_OS_WINRT SimulateIOError( return SQLITE_ERROR ); UNUSED_PARAMETER(nFull); /* WinCE has no concept of a relative pathname, or so I am told. */ @@ -3560,7 +3565,7 @@ static int winFullPathname( return SQLITE_OK; #endif -#if !SQLITE_OS_WINCE && !defined(__CYGWIN__) +#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__) int nByte; void *zConverted; char *zOut; diff --git a/src/test_config.c b/src/test_config.c index 18442a49e0..08ee1c32c3 100644 --- a/src/test_config.c +++ b/src/test_config.c @@ -57,6 +57,12 @@ static void set_options(Tcl_Interp *interp){ Tcl_SetVar2(interp, "sqlite_options","casesensitivelike","0",TCL_GLOBAL_ONLY); #endif +#ifdef SQLITE_CURDIR + Tcl_SetVar2(interp, "sqlite_options", "curdir", "1", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "curdir", "0", TCL_GLOBAL_ONLY); +#endif + #ifdef SQLITE_DEBUG Tcl_SetVar2(interp, "sqlite_options", "debug", "1", TCL_GLOBAL_ONLY); #else diff --git a/test/misc1.test b/test/misc1.test index e3f1b9555a..188a2837ba 100644 --- a/test/misc1.test +++ b/test/misc1.test @@ -472,6 +472,11 @@ ifcapable subquery { } {1 2 3 4 5 6 7 8 9 10 11} } +# +# The following tests can only work if the current SQLite VFS has the concept +# of a current directory. +# +ifcapable curdir { # Make sure a database connection still works after changing the # working directory. # @@ -495,6 +500,7 @@ do_test misc1-14.3 { execsql {COMMIT} file exists ./test.db-journal } {0} +} # A failed create table should not leave the table in the internal # data structures. Ticket #238. diff --git a/test/pager1.test b/test/pager1.test index 415eb6ab81..1a21f36f31 100644 --- a/test/pager1.test +++ b/test/pager1.test @@ -524,18 +524,27 @@ db close # file-system is saved just before the xDelete() call to remove the # master journal file from the file-system. # +set pwd [pwd] testvfs tv -default 1 tv script copy_on_mj_delete set ::mj_filename_length 0 proc copy_on_mj_delete {method filename args} { if {[string match *mj* [file tail $filename]]} { - set ::mj_filename_length [string length $filename] + # + # NOTE: Is the file name relative? If so, add the length of the current + # directory. + # + if {[is_relative_file $filename]} { + set ::mj_filename_length \ + [expr {[string length $filename] + [string length $::pwd]}] + } else { + set ::mj_filename_length [string length $filename] + } faultsim_save } return SQLITE_OK } -set pwd [pwd] foreach {tn1 tcl} { 1 { set prefix "test.db" } 2 { @@ -1001,8 +1010,17 @@ do_test pager1-5.4.1 { # the master-journal name encoded as utf-8 with no nul term. # set mj_pointer [expr { - 20 + [string length [pwd]] + [string length "/test.db-mjXXXXXX9XX"] + 20 + [string length "test.db-mjXXXXXX9XX"] }] + # + # NOTE: For item 3 above, if the current SQLite VFS lacks the concept of a + # current directory, the length of the current directory name plus 1 + # character for the directory separator character are NOT counted as + # part of the total size; otherwise, they are. + # + ifcapable curdir { + set mj_pointer [expr {$mj_pointer + [string length [pwd]] + 1}] + } expr {$::max_journal==(512+2*(1024+8)+$mj_pointer)} } 1 do_test pager1-5.4.2 { @@ -1020,8 +1038,17 @@ do_test pager1-5.4.2 { # written starting at the next (in this case 512 byte) sector boundary. # set mj_pointer [expr { - 20 + [string length [pwd]] + [string length "/test.db-mjXXXXXX9XX"] + 20 + [string length "test.db-mjXXXXXX9XX"] }] + # + # NOTE: If the current SQLite VFS lacks the concept of a current directory, + # the length of the current directory name plus 1 character for the + # directory separator character are NOT counted as part of the total + # size; otherwise, they are. + # + ifcapable curdir { + set mj_pointer [expr {$mj_pointer + [string length [pwd]] + 1}] + } expr {$::max_journal==(((512+2*(1024+8)+511)/512)*512 + $mj_pointer)} } 1 db close diff --git a/test/tester.tcl b/test/tester.tcl index e27a483f41..95d3d34365 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -19,6 +19,7 @@ # # Commands to manipulate the db and the file-system at a high level: # +# is_relative_file # copy_file FROM TO # delete_file FILENAME # drop_all_tables ?DB? @@ -193,6 +194,12 @@ proc do_copy_file {force from to} { } } +# Check if a file name is relative +# +proc is_relative_file { file } { + return [expr {[file pathtype $file] != "absolute"}] +} + # Delete a file or directory # proc delete_file {args} { diff --git a/test/wal.test b/test/wal.test index 3b63d3e792..75debb21b5 100644 --- a/test/wal.test +++ b/test/wal.test @@ -1477,7 +1477,11 @@ foreach pgsz {512 1024 2048 4096 8192 16384 32768 65536} { # Test that when 1 or more pages are recovered from a WAL file, # sqlite3_log() is invoked to report this to the user. # -set walfile [file nativename [file join [pwd] test.db-wal]] +ifcapable curdir { + set walfile [file nativename [file join [pwd] test.db-wal]] +} else { + set walfile test.db-wal +} catch {db close} forcedelete test.db do_test wal-23.1 { From 4a41f3455294e3eacb2c5ba8d0f3f9c13a1d237b Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 6 Mar 2012 03:00:49 +0000 Subject: [PATCH 15/59] Fix for test issues when there is no current directory support due to being compiled for WinRT. FossilOrigin-Name: a811cb01528beab8afd899411d187d4d960ddcc8 --- manifest | 22 +++++++++++----------- manifest.uuid | 2 +- test/e_uri.test | 16 ++++++++-------- test/quota.test | 7 +++++++ test/quota2.test | 7 +++++++ test/shared.test | 8 +++++--- test/tester.tcl | 23 +++++++++++++++++++++++ test/uri.test | 8 +++++--- 8 files changed, 67 insertions(+), 26 deletions(-) diff --git a/manifest b/manifest index 20c56c9715..f9aca85bef 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\scompile-time\sdefine\sto\sindicate\sif\sthe\sVFS\ssupports\sthe\sconcept\sof\sa\scurrent\sdirectory\s(as\sWinCE\sand\sWinRT\sdo\snot).\s\sAvoid\susing\sthe\sGetTempPath\sand\sGetFullPathName\sAPIs\son\sWinRT.\s\sSome\stests\sstill\sneed\sadjustments. -D 2012-03-05T22:52:33.397 +C Fix\sfor\stest\sissues\swhen\sthere\sis\sno\scurrent\sdirectory\ssupport\sdue\sto\sbeing\scompiled\sfor\sWinRT. +D 2012-03-06T03:00:49.815 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -389,7 +389,7 @@ F test/e_resolve.test dcce9308fb13b934ce29591105d031d3e14fbba6 F test/e_select.test f5d4b81205701deacfae42051ae200969c41d2c0 F test/e_select2.test 5c3d3da19c7b3e90ae444579db2b70098599ab92 F test/e_update.test 161d5dc6a3ed9dd08f5264d13e20735d7a89f00c -F test/e_uri.test 6f35b491f80dac005c8144f38b2dfb4d96483596 +F test/e_uri.test 2a9f7fbc259751f49019cd8cb778a2e40eebb607 F test/e_vacuum.test 331da289ae186656cf5f2eb27f577a89c0c221af F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea F test/enc2.test 796c59832e2b9a52842f382ffda8f3e989db03ad @@ -642,8 +642,8 @@ F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota-glob.test 32901e9eed6705d68ca3faee2a06b73b57cb3c26 -F test/quota.test af47d25c166aa7b33ef25f21bb7f2afb29d82c77 -F test/quota2.test 1b8df088e604f2df573f96e726b5e518cb0cddaa +F test/quota.test 6911189e2854b7a30420af284fb096e650683f7c +F test/quota2.test 964ef836996cb512a1cb29aee4dbb4874544fb0d F test/quote.test 215897dbe8de1a6f701265836d6601cc6ed103e6 F test/randexpr1.tcl 40dec52119ed3a2b8b2a773bce24b63a3a746459 F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df @@ -679,7 +679,7 @@ F test/selectA.test 06d1032fa9009314c95394f2ca2e60d9f7ae8532 F test/selectB.test 954e4e49cf1f896d61794e440669e03a27ceea25 F test/selectC.test 871fb55d884d3de5943c4057ebd22c2459e71977 F test/server1.test 46803bd3fe8b99b30dbc5ff38ffc756f5c13a118 -F test/shared.test 34945a516532b11182c3eb26e31247eee3c9ae48 +F test/shared.test 52e637790cc98727a64c3bdba330005354cebcab F test/shared2.test 03eb4a8d372e290107d34b6ce1809919a698e879 F test/shared3.test ebf77f023f4bdaa8f74f65822b559e86ce5c6257 F test/shared4.test 72d90821e8d2fc918a08f16d32880868d8ee8e9d @@ -718,7 +718,7 @@ F test/tclsqlite.test 1597d353308531527583481d14d9da52ea8ed0af F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c F test/temptable.test 51edd31c65ed1560dd600b1796e8325df96318e2 F test/temptrigger.test 26670ed7a39cf2296a7f0a9e0a1d7bdb7abe936d -F test/tester.tcl 31baf0d92ca1151903b56c0e137ef6a038597c21 +F test/tester.tcl 89ff87968ca1f8101c2ea5dfae430ccd6ec69cad F test/thread001.test 7cc2ce08f9cde95964736d11e91f9ab610f82f91 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -879,7 +879,7 @@ F test/unique.test 083c7fff74695bcc27a71d75699deba3595bc9c2 F test/unixexcl.test a9870e46cc6f8390a494513d4f2bf55b5a8b3e46 F test/unordered.test f53095cee37851bf30130fa1bf299a8845e837bb F test/update.test 8bc86fd7ef1a00014f76dc6a6a7c974df4aef172 -F test/uri.test 0d289d32396bdbc491e9dc845f1a52e13f861e0b +F test/uri.test 7ef16ff2213177c5e44f57b8dda75fa363eeb2d2 F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae F test/vacuum.test ce91c39f7f91a4273bf620efad21086b5aa6ef1d F test/vacuum2.test af432e6e3bfc0ea20a80cb86a03c7d9876d38324 @@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P ed603d75941ace159773b1a22ace84d51b630ad5 -R 8dc77ea6ed646d5c79820ac4402d9981 +P 86c049a171acc3f4a43771f3e7176a90210d7799 +R 314d419e8c040139a13a4d217d38fb16 U mistachkin -Z 687362d63f53a7c55f33c0c80d00dc38 +Z 7d9d47d1c51b3cc8f2a457004146579d diff --git a/manifest.uuid b/manifest.uuid index 6c9223a44c..72f995512a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -86c049a171acc3f4a43771f3e7176a90210d7799 \ No newline at end of file +a811cb01528beab8afd899411d187d4d960ddcc8 \ No newline at end of file diff --git a/test/e_uri.test b/test/e_uri.test index 5275ec1b54..c4449bd328 100644 --- a/test/e_uri.test +++ b/test/e_uri.test @@ -131,10 +131,10 @@ sqlite3_config_uri 1 if {$tcl_platform(platform) == "unix"} { set flags [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI] foreach {tn uri error} " - 1 {file://localhost[pwd]/test.db} {not an error} - 2 {file://[pwd]/test.db} {not an error} - 3 {file://x[pwd]/test.db} {invalid uri authority: x} - 4 {file://invalid[pwd]/test.db} {invalid uri authority: invalid} + 1 {file://localhost[test_pwd /]test.db} {not an error} + 2 {file://[test_pwd /]test.db} {not an error} + 3 {file://x[test_pwd /]test.db} {invalid uri authority: x} + 4 {file://invalid[test_pwd /]test.db} {invalid uri authority: invalid} " { do_test 2.$tn { set DB [sqlite3_open_v2 $uri $flags ""] @@ -153,9 +153,9 @@ if {$tcl_platform(platform) == "unix"} { # parameters passed through to the VFS xOpen() methods. # foreach {tn uri parse} " - 1 {file:test.db#abc} {[pwd]/test.db {}} - 2 {file:test.db?a=b#abc} {[pwd]/test.db {a b}} - 3 {file:test.db?a=b#?c=d} {[pwd]/test.db {a b}} + 1 {file:test.db#abc} {[test_pwd / {}]test.db {}} + 2 {file:test.db?a=b#abc} {[test_pwd / {}]test.db {a b}} + 3 {file:test.db?a=b#?c=d} {[test_pwd / {}]test.db {a b}} " { do_filepath_test 3.$tn { parse_uri $uri } $parse } @@ -171,7 +171,7 @@ foreach {tn uri parse} " # path is interpreted as a relative path. # foreach {tn uri parse} " - 1 {file:test.db} {[pwd]/test.db {}} + 1 {file:test.db} {[test_pwd / {}]test.db {}} 2 {file:/test.db} {/test.db {}} 3 {file:///test.db} {/test.db {}} 4 {file://localhost/test.db} {/test.db {}} diff --git a/test/quota.test b/test/quota.test index e12b83a429..b052a85ee1 100644 --- a/test/quota.test +++ b/test/quota.test @@ -12,6 +12,13 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl + +# If SQLITE_CURDIR is not defined, omit this file. +ifcapable !curdir { + finish_test + return +} + source $testdir/malloc_common.tcl unset -nocomplain defaultVfs diff --git a/test/quota2.test b/test/quota2.test index cf3449dafc..cea2112aeb 100644 --- a/test/quota2.test +++ b/test/quota2.test @@ -12,6 +12,13 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl + +# If SQLITE_CURDIR is not defined, omit this file. +ifcapable !curdir { + finish_test + return +} + source $testdir/malloc_common.tcl db close diff --git a/test/shared.test b/test/shared.test index 37564e6967..26f159b07c 100644 --- a/test/shared.test +++ b/test/shared.test @@ -904,9 +904,11 @@ do_test shared-$av.11.8 { set res } {1 4 {} 7} if {[llength [info command sqlite3_shared_cache_report]]==1} { - do_test shared-$av.11.9 { - string tolower [sqlite3_shared_cache_report] - } [string tolower [list [file nativename [file normalize test.db]] 2]] + ifcapable curdir { + do_test shared-$av.11.9 { + string tolower [sqlite3_shared_cache_report] + } [string tolower [list [file nativename [file normalize test.db]] 2]] + } } do_test shared-$av.11.11 { diff --git a/test/tester.tcl b/test/tester.tcl index 95d3d34365..b819610d15 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -20,6 +20,7 @@ # Commands to manipulate the db and the file-system at a high level: # # is_relative_file +# test_pwd # copy_file FROM TO # delete_file FILENAME # drop_all_tables ?DB? @@ -200,6 +201,28 @@ proc is_relative_file { file } { return [expr {[file pathtype $file] != "absolute"}] } +# If the VFS supports using the current directory, returns [pwd]; +# otherwise, it returns only the provided suffix string (which is +# empty by default). +# +proc test_pwd { args } { + if {[llength $args] > 0} { + set suffix1 [lindex $args 0] + if {[llength $args] > 1} { + set suffix2 [lindex $args 1] + } else { + set suffix2 $suffix1 + } + } else { + set suffix1 ""; set suffix2 "" + } + ifcapable curdir { + return "[pwd]$suffix1" + } else { + return $suffix2 + } +} + # Delete a file or directory # proc delete_file {args} { diff --git a/test/uri.test b/test/uri.test index 90074d0d27..764fa15ef7 100644 --- a/test/uri.test +++ b/test/uri.test @@ -52,13 +52,15 @@ foreach {tn uri file} { 16 file://localhostPWD/test.db%3Fhello test.db?hello } { + + ifcapable !curdir { if {$tn==3} break } + if {$tcl_platform(platform)=="windows"} { if {$tn>14} break - set uri [string map [list PWD /[pwd]] $uri] - } else { - set uri [string map [list PWD [pwd]] $uri] } + set uri [string map [list PWD/ [test_pwd /]] $uri] + if {[file isdir $file]} {error "$file is a directory"} forcedelete $file do_test 1.$tn.1 { file exists $file } 0 From 5483f772b1d34c7228c102ce486f78710b237dd4 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 7 Mar 2012 20:11:47 +0000 Subject: [PATCH 16/59] When compiled for WinRT, use the CreateFile2 and LoadPackagedLibrary functions instead of CreateFile and LoadLibrary. FossilOrigin-Name: 27d6942ca270d6e724ffd230ed58a8683d67dfa4 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_win.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 39bbc25274..930e43b823 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sin\sthe\slatest\strunk\schanges. -D 2012-03-07T16:52:38.729 +C When\scompiled\sfor\sWinRT,\suse\sthe\sCreateFile2\sand\sLoadPackagedLibrary\sfunctions\sinstead\sof\sCreateFile\sand\sLoadLibrary. +D 2012-03-07T20:11:47.006 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c 75d5de49067252dbd98fb8b1a2b2fabe7938e53c +F src/os_win.c ca9ff6340c72aa45adf5a444a036f3c87f437f0f F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P a811cb01528beab8afd899411d187d4d960ddcc8 b00ccda307caae597c143ab0586f90acb77f79cf -R 94c51b7fbb263e5f4c52b0a46e76906b -U drh -Z b68dd77698ec2e059d1157847d82dd91 +P ca4708531a5e0debbe3d0999a4d210ef2a347972 +R a847917f3cb0516bcd40d98583b4bef4 +U mistachkin +Z f23820be67631a5e2a405c3799a1a747 diff --git a/manifest.uuid b/manifest.uuid index 8305724f22..173aa9cec6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ca4708531a5e0debbe3d0999a4d210ef2a347972 \ No newline at end of file +27d6942ca270d6e724ffd230ed58a8683d67dfa4 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 6607120830..6447d368be 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -31,6 +31,14 @@ # define INVALID_FILE_ATTRIBUTES ((DWORD)-1) #endif +#ifndef FILE_FLAG_MASK +# define FILE_FLAG_MASK (0xFF3C0000) +#endif + +#ifndef FILE_ATTRIBUTE_MASK +# define FILE_ATTRIBUTE_MASK (0x0003FFF7) +#endif + /* Forward references */ typedef struct winShm winShm; /* A connection to shared-memory */ typedef struct winShmNode winShmNode; /* A region of shared-memory */ @@ -671,6 +679,24 @@ static struct win_syscall { #define osMapViewOfFileEx ((LPVOID(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,SIZE_T, \ LPVOID))aSyscall[65].pCurrent) +#if SQLITE_OS_WINRT && 0 /* DISABLED: Can be compiled with WinRT only. */ + { "CreateFile2", (SYSCALL)CreateFile2, 0 }, +#else + { "CreateFile2", (SYSCALL)0, 0 }, +#endif + +#define osCreateFile2 ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD,DWORD, \ + LPCREATEFILE2_EXTENDED_PARAMETERS))aSyscall[66].pCurrent) + +#if SQLITE_OS_WINRT && 0 /* DISABLED: Can be compiled with WinRT only. */ + { "LoadPackagedLibrary", (SYSCALL)LoadPackagedLibrary, 0 }, +#else + { "LoadPackagedLibrary", (SYSCALL)0, 0 }, +#endif + +#define osLoadPackagedLibrary ((HMODULE(WINAPI*)(LPCWSTR, \ + DWORD))aSyscall[67].pCurrent) + }; /* End of the overrideable system calls */ /* @@ -3330,6 +3356,22 @@ static int winOpen( #endif if( isNT() ){ +#if SQLITE_OS_WINRT && 0 /* DISABLED: Can be compiled with WinRT only. */ + CREATEFILE2_EXTENDED_PARAMETERS extendedParameters; + extendedParameters.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS); + extendedParameters.dwFileAttributes = + dwFlagsAndAttributes & FILE_ATTRIBUTE_MASK; + extendedParameters.dwFileFlags = dwFlagsAndAttributes & FILE_FLAG_MASK; + extendedParameters.dwSecurityQosFlags = SECURITY_ANONYMOUS; + extendedParameters.lpSecurityAttributes = NULL; + extendedParameters.hTemplateFile = NULL; + while( (h = osCreateFile2((LPCWSTR)zConverted, + dwDesiredAccess, + dwShareMode, + dwCreationDisposition, + &extendedParameters))==INVALID_HANDLE_VALUE && + retryIoerr(&cnt, &lastErrno) ){} +#else while( (h = osCreateFileW((LPCWSTR)zConverted, dwDesiredAccess, dwShareMode, NULL, @@ -3337,6 +3379,7 @@ static int winOpen( dwFlagsAndAttributes, NULL))==INVALID_HANDLE_VALUE && retryIoerr(&cnt, &lastErrno) ){} +#endif } #ifdef SQLITE_WIN32_HAS_ANSI else{ @@ -3643,7 +3686,11 @@ static void *winDlOpen(sqlite3_vfs *pVfs, const char *zFilename){ return 0; } if( isNT() ){ +#if SQLITE_OS_WINRT && 0 /* DISABLED: Can be compiled with WinRT only. */ + h = osLoadPackagedLibrary((LPCWSTR)zConverted, 0); +#else h = osLoadLibraryW((LPCWSTR)zConverted); +#endif } #ifdef SQLITE_WIN32_HAS_ANSI else{ @@ -3856,7 +3903,7 @@ int sqlite3_os_init(void){ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ - assert( ArraySize(aSyscall)==66 ); + assert( ArraySize(aSyscall)==68 ); #if SQLITE_OS_WINRT sleepObj = osCreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, From df562d5535ce32cc5e64f23863f3a7b095483170 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 13 Mar 2012 01:16:57 +0000 Subject: [PATCH 17/59] More changes required to compile for WinRT using VS 11 beta. Also, replace more APIs with their WinRT alternatives. FossilOrigin-Name: 6b997d9c32076c480ff4f101ff93bae3f443e252 --- manifest | 14 ++-- manifest.uuid | 2 +- src/mutex_w32.c | 8 +++ src/os_win.c | 183 ++++++++++++++++++++++++++++++++---------------- 4 files changed, 140 insertions(+), 67 deletions(-) diff --git a/manifest b/manifest index f7030f8aaf..7e9bd5d38f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\stest\scurrent\sdirectory\svalue\sfix\sfrom\strunk\sand\sfix\suri\stests. -D 2012-03-08T20:39:08.983 +C More\schanges\srequired\sto\scompile\sfor\sWinRT\susing\sVS\s11\sbeta.\s\sAlso,\sreplace\smore\sAPIs\swith\stheir\sWinRT\salternatives. +D 2012-03-13T01:16:57.353 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -160,14 +160,14 @@ F src/mutex.h 2a79e0c10c26412546b501ee0f3d92b42decf63e F src/mutex_noop.c 7682796b7d8d39bf1c138248858efcd10c9e1553 F src/mutex_os2.c 882d735098c07c8c6a5472b8dd66e19675fe117f F src/mutex_unix.c c3a4e00f96ba068a8dbef34084465979aaf369cc -F src/mutex_w32.c ddd2a783230e22831ab44fca181b5904e48a7318 +F src/mutex_w32.c be6dc2be432aa27e1b0d0a19a0da7bace9e4e441 F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c ca9ff6340c72aa45adf5a444a036f3c87f437f0f +F src/os_win.c 3dc4b1a7bafdca23f71439b0ca691668fb65f3c1 F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 5eecdb44dd809e91002b8ecf59ada72f4b56549a efee39e64bd95c284220fdb0ae8ee6c1847fadab -R 4259e5e6648b2026d8327fd947148d80 +P 88963c33c19a051280f7f31bdc1b322d6837cf43 +R d6ea1d137f9bbc6d3552b399f2e0cfe5 U mistachkin -Z 18b9a0728cfebb78df49400835a7c03c +Z 69539dbb9e14faecbb37484031cfeaaf diff --git a/manifest.uuid b/manifest.uuid index aa5d7a410d..9df339aea0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -88963c33c19a051280f7f31bdc1b322d6837cf43 \ No newline at end of file +6b997d9c32076c480ff4f101ff93bae3f443e252 \ No newline at end of file diff --git a/src/mutex_w32.c b/src/mutex_w32.c index 901256be07..4c3855faf4 100644 --- a/src/mutex_w32.c +++ b/src/mutex_w32.c @@ -124,7 +124,11 @@ static int winMutexInit(void){ }else{ /* Someone else is in the process of initing the static mutexes */ while( !winMutex_isInit ){ +#if SQLITE_OS_WINRT + Yield(); /* NOP */ +#else Sleep(1); +#endif } } return SQLITE_OK; @@ -198,7 +202,11 @@ static sqlite3_mutex *winMutexAlloc(int iType){ #ifdef SQLITE_DEBUG p->id = iType; #endif +#if SQLITE_OS_WINRT + InitializeCriticalSectionEx(&p->mutex, 0, 0); +#else InitializeCriticalSection(&p->mutex); +#endif } break; } diff --git a/src/os_win.c b/src/os_win.c index 6447d368be..7f2a06b872 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -203,12 +203,19 @@ static int sqlite3_os_type = 0; ** defines here refer to the macros defined just above. */ -# define osAreFileApisANSI() 1 # define osLockFile LockFile # define osUnlockFile UnlockFile # define osLockFileEx LockFileEx #endif +/* +** This function is not available on Windows CE or WinRT. + */ + +#if SQLITE_OS_WINCE || SQLITE_OS_WINRT +# define osAreFileApisANSI() 1 +#endif + /* ** Many system calls are accessed through pointer-to-functions so that ** they may be overridden at runtime to facilitate fault injection during @@ -220,14 +227,14 @@ static struct win_syscall { sqlite3_syscall_ptr pCurrent; /* Current value of the system call */ sqlite3_syscall_ptr pDefault; /* Default value */ } aSyscall[] = { -#if !SQLITE_OS_WINCE +#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT { "AreFileApisANSI", (SYSCALL)AreFileApisANSI, 0 }, - -#define osAreFileApisANSI ((BOOL(WINAPI*)(VOID))aSyscall[0].pCurrent) #else { "AreFileApisANSI", (SYSCALL)0, 0 }, #endif +#define osAreFileApisANSI ((BOOL(WINAPI*)(VOID))aSyscall[0].pCurrent) + #if SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE) { "CharLowerW", (SYSCALL)CharLowerW, 0 }, #else @@ -257,7 +264,7 @@ static struct win_syscall { #define osCreateFileA ((HANDLE(WINAPI*)(LPCSTR,DWORD,DWORD, \ LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[4].pCurrent) -#if defined(SQLITE_WIN32_HAS_WIDE) +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) { "CreateFileW", (SYSCALL)CreateFileW, 0 }, #else { "CreateFileW", (SYSCALL)0, 0 }, @@ -266,10 +273,8 @@ static struct win_syscall { #define osCreateFileW ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD, \ LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[5].pCurrent) - { "CreateFileMapping", (SYSCALL)CreateFileMapping, 0 }, - -#define osCreateFileMapping ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \ - DWORD,DWORD,DWORD,LPCTSTR))aSyscall[6].pCurrent) + /* TODO: REMOVE */ + { "CreateFileMapping", (SYSCALL)0, 0 }, #if defined(SQLITE_WIN32_HAS_WIDE) { "CreateFileMappingW", (SYSCALL)CreateFileMappingW, 0 }, @@ -280,7 +285,7 @@ static struct win_syscall { #define osCreateFileMappingW ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \ DWORD,DWORD,DWORD,LPCWSTR))aSyscall[7].pCurrent) -#if defined(SQLITE_WIN32_HAS_WIDE) +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) { "CreateMutexW", (SYSCALL)CreateMutexW, 0 }, #else { "CreateMutexW", (SYSCALL)0, 0 }, @@ -362,7 +367,7 @@ static struct win_syscall { #define osGetDiskFreeSpaceA ((BOOL(WINAPI*)(LPCSTR,LPDWORD,LPDWORD,LPDWORD, \ LPDWORD))aSyscall[18].pCurrent) -#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE) +#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) { "GetDiskFreeSpaceW", (SYSCALL)GetDiskFreeSpaceW, 0 }, #else { "GetDiskFreeSpaceW", (SYSCALL)0, 0 }, @@ -379,7 +384,7 @@ static struct win_syscall { #define osGetFileAttributesA ((DWORD(WINAPI*)(LPCSTR))aSyscall[20].pCurrent) -#if defined(SQLITE_WIN32_HAS_WIDE) +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) { "GetFileAttributesW", (SYSCALL)GetFileAttributesW, 0 }, #else { "GetFileAttributesW", (SYSCALL)0, 0 }, @@ -396,10 +401,10 @@ static struct win_syscall { #define osGetFileAttributesExW ((BOOL(WINAPI*)(LPCWSTR,GET_FILEEX_INFO_LEVELS, \ LPVOID))aSyscall[22].pCurrent) -#if SQLITE_OS_WINRT - { "GetFileSize", (SYSCALL)0, 0 }, -#else +#if !SQLITE_OS_WINRT { "GetFileSize", (SYSCALL)GetFileSize, 0 }, +#else + { "GetFileSize", (SYSCALL)0, 0 }, #endif #define osGetFileSize ((DWORD(WINAPI*)(HANDLE,LPDWORD))aSyscall[23].pCurrent) @@ -438,7 +443,11 @@ static struct win_syscall { #define osGetProcAddressA ((FARPROC(WINAPI*)(HMODULE, \ LPCSTR))aSyscall[27].pCurrent) +#if !SQLITE_OS_WINRT { "GetSystemInfo", (SYSCALL)GetSystemInfo, 0 }, +#else + { "GetSystemInfo", (SYSCALL)0, 0 }, +#endif #define osGetSystemInfo ((VOID(WINAPI*)(LPSYSTEM_INFO))aSyscall[28].pCurrent) @@ -471,7 +480,11 @@ static struct win_syscall { #define osGetTempPathW ((DWORD(WINAPI*)(DWORD,LPWSTR))aSyscall[32].pCurrent) +#if !SQLITE_OS_WINRT { "GetTickCount", (SYSCALL)GetTickCount, 0 }, +#else + { "GetTickCount", (SYSCALL)0, 0 }, +#endif #define osGetTickCount ((DWORD(WINAPI*)(VOID))aSyscall[33].pCurrent) @@ -489,12 +502,20 @@ static struct win_syscall { #define osHeapAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD, \ SIZE_T))aSyscall[35].pCurrent) +#if !SQLITE_OS_WINRT { "HeapCreate", (SYSCALL)HeapCreate, 0 }, +#else + { "HeapCreate", (SYSCALL)0, 0 }, +#endif #define osHeapCreate ((HANDLE(WINAPI*)(DWORD,SIZE_T, \ SIZE_T))aSyscall[36].pCurrent) +#if !SQLITE_OS_WINRT { "HeapDestroy", (SYSCALL)HeapDestroy, 0 }, +#else + { "HeapDestroy", (SYSCALL)0, 0 }, +#endif #define osHeapDestroy ((BOOL(WINAPI*)(HANDLE))aSyscall[37].pCurrent) @@ -512,7 +533,11 @@ static struct win_syscall { #define osHeapSize ((SIZE_T(WINAPI*)(HANDLE,DWORD, \ LPCVOID))aSyscall[40].pCurrent) +#if !SQLITE_OS_WINRT { "HeapValidate", (SYSCALL)HeapValidate, 0 }, +#else + { "HeapValidate", (SYSCALL)0, 0 }, +#endif #define osHeapValidate ((BOOL(WINAPI*)(HANDLE,DWORD, \ LPCVOID))aSyscall[41].pCurrent) @@ -525,7 +550,7 @@ static struct win_syscall { #define osLoadLibraryA ((HMODULE(WINAPI*)(LPCSTR))aSyscall[42].pCurrent) -#if defined(SQLITE_WIN32_HAS_WIDE) +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) { "LoadLibraryW", (SYSCALL)LoadLibraryW, 0 }, #else { "LoadLibraryW", (SYSCALL)0, 0 }, @@ -533,19 +558,23 @@ static struct win_syscall { #define osLoadLibraryW ((HMODULE(WINAPI*)(LPCWSTR))aSyscall[43].pCurrent) +#if !SQLITE_OS_WINRT { "LocalFree", (SYSCALL)LocalFree, 0 }, +#else + { "LocalFree", (SYSCALL)0, 0 }, +#endif #define osLocalFree ((HLOCAL(WINAPI*)(HLOCAL))aSyscall[44].pCurrent) -#if !SQLITE_OS_WINCE +#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT { "LockFile", (SYSCALL)LockFile, 0 }, - -#define osLockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ - DWORD))aSyscall[45].pCurrent) #else { "LockFile", (SYSCALL)0, 0 }, #endif +#define osLockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ + DWORD))aSyscall[45].pCurrent) + #if !SQLITE_OS_WINCE { "LockFileEx", (SYSCALL)LockFileEx, 0 }, @@ -555,7 +584,11 @@ static struct win_syscall { { "LockFileEx", (SYSCALL)0, 0 }, #endif +#if !SQLITE_OS_WINRT { "MapViewOfFile", (SYSCALL)MapViewOfFile, 0 }, +#else + { "MapViewOfFile", (SYSCALL)0, 0 }, +#endif #define osMapViewOfFile ((LPVOID(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ SIZE_T))aSyscall[47].pCurrent) @@ -579,19 +612,19 @@ static struct win_syscall { #define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[51].pCurrent) -#if SQLITE_OS_WINRT - { "SetFilePointer", (SYSCALL)0, 0 }, -#else +#if !SQLITE_OS_WINRT { "SetFilePointer", (SYSCALL)SetFilePointer, 0 }, +#else + { "SetFilePointer", (SYSCALL)0, 0 }, #endif #define osSetFilePointer ((DWORD(WINAPI*)(HANDLE,LONG,PLONG, \ DWORD))aSyscall[52].pCurrent) -#if SQLITE_OS_WINRT - { "Sleep", (SYSCALL)0, 0 }, -#else +#if !SQLITE_OS_WINRT { "Sleep", (SYSCALL)Sleep, 0 }, +#else + { "Sleep", (SYSCALL)0, 0 }, #endif #define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[53].pCurrent) @@ -601,24 +634,24 @@ static struct win_syscall { #define osSystemTimeToFileTime ((BOOL(WINAPI*)(CONST SYSTEMTIME*, \ LPFILETIME))aSyscall[54].pCurrent) -#if !SQLITE_OS_WINCE +#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT { "UnlockFile", (SYSCALL)UnlockFile, 0 }, - -#define osUnlockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ - DWORD))aSyscall[55].pCurrent) #else { "UnlockFile", (SYSCALL)0, 0 }, #endif +#define osUnlockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ + DWORD))aSyscall[55].pCurrent) + #if !SQLITE_OS_WINCE { "UnlockFileEx", (SYSCALL)UnlockFileEx, 0 }, - -#define osUnlockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ - LPOVERLAPPED))aSyscall[56].pCurrent) #else { "UnlockFileEx", (SYSCALL)0, 0 }, #endif +#define osUnlockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ + LPOVERLAPPED))aSyscall[56].pCurrent) + { "UnmapViewOfFile", (SYSCALL)UnmapViewOfFile, 0 }, #define osUnmapViewOfFile ((BOOL(WINAPI*)(LPCVOID))aSyscall[57].pCurrent) @@ -634,15 +667,19 @@ static struct win_syscall { LPOVERLAPPED))aSyscall[59].pCurrent) #if !SQLITE_OS_WINCE - { "CreateEventEx", (SYSCALL)CreateEventEx, 0 }, - -#define osCreateEventEx ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,LPCTSTR, \ - DWORD,DWORD))aSyscall[60].pCurrent) + { "CreateEventExW", (SYSCALL)CreateEventExW, 0 }, #else - { "CreateEventEx", (SYSCALL)0, 0 }, + { "CreateEventExW", (SYSCALL)0, 0 }, #endif +#define osCreateEventExW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,LPCWSTR, \ + DWORD,DWORD))aSyscall[60].pCurrent) + +#if !SQLITE_OS_WINRT { "WaitForSingleObject", (SYSCALL)WaitForSingleObject, 0 }, +#else + { "WaitForSingleObject", (SYSCALL)0, 0 }, +#endif #define osWaitForSingleObject ((DWORD(WINAPI*)(HANDLE, \ DWORD))aSyscall[61].pCurrent) @@ -679,24 +716,41 @@ static struct win_syscall { #define osMapViewOfFileEx ((LPVOID(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,SIZE_T, \ LPVOID))aSyscall[65].pCurrent) -#if SQLITE_OS_WINRT && 0 /* DISABLED: Can be compiled with WinRT only. */ - { "CreateFile2", (SYSCALL)CreateFile2, 0 }, +#if SQLITE_OS_WINRT + { "CreateFile2", (SYSCALL)CreateFile2, 0 }, #else - { "CreateFile2", (SYSCALL)0, 0 }, + { "CreateFile2", (SYSCALL)0, 0 }, #endif #define osCreateFile2 ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD,DWORD, \ LPCREATEFILE2_EXTENDED_PARAMETERS))aSyscall[66].pCurrent) -#if SQLITE_OS_WINRT && 0 /* DISABLED: Can be compiled with WinRT only. */ - { "LoadPackagedLibrary", (SYSCALL)LoadPackagedLibrary, 0 }, +#if SQLITE_OS_WINRT + { "LoadPackagedLibrary", (SYSCALL)LoadPackagedLibrary, 0 }, #else - { "LoadPackagedLibrary", (SYSCALL)0, 0 }, + { "LoadPackagedLibrary", (SYSCALL)0, 0 }, #endif #define osLoadPackagedLibrary ((HMODULE(WINAPI*)(LPCWSTR, \ DWORD))aSyscall[67].pCurrent) +#if SQLITE_OS_WINRT + { "GetTickCount64", (SYSCALL)GetTickCount64, 0 }, +#else + { "GetTickCount64", (SYSCALL)0, 0 }, +#endif + +#define osGetTickCount64 ((ULONGLONG(WINAPI*)(VOID))aSyscall[68].pCurrent) + +#if SQLITE_OS_WINRT + { "GetNativeSystemInfo", (SYSCALL)GetNativeSystemInfo, 0 }, +#else + { "GetNativeSystemInfo", (SYSCALL)0, 0 }, +#endif + +#define osGetNativeSystemInfo ((VOID(WINAPI*)( \ + LPSYSTEM_INFO))aSyscall[69].pCurrent) + }; /* End of the overrideable system calls */ /* @@ -808,7 +862,7 @@ static void portableSleep(int ms){ ** WinNT/2K/XP so that we will know whether or not we can safely call ** the LockFileEx() API. */ -#if SQLITE_OS_WINCE || SQLITE_OS_WINRT +#if SQLITE_OS_WINCE || SQLITE_OS_WINRT # define isNT() (1) #else static int isNT(void){ @@ -1697,13 +1751,13 @@ static BOOL winceLockFileEx( # define INVALID_SET_FILE_POINTER ((DWORD)-1) #endif -#if SQLITE_OS_WINRT==0 /* ** Move the current position of the file handle passed as the first ** argument to offset iOffset within the file. If successful, return 0. ** Otherwise, set pFile->lastErrno and return non-zero. */ static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){ +#if !SQLITE_OS_WINRT LONG upperBits; /* Most sig. 32 bits of new offset */ LONG lowerBits; /* Least sig. 32 bits of new offset */ DWORD dwRet; /* Value returned by SetFilePointer() */ @@ -1730,13 +1784,11 @@ static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){ } return 0; -} -#else /* if SQLITE_OS_WINRT==1 */ -/* -** Same function as above, except that this implementation works for -** windowsRT. -*/ -static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){ +#else + /* + ** Same as above, except that this implementation works for WinRT. + */ + LARGE_INTEGER x; /* The new offset */ BOOL bRet; /* Value returned by SetFilePointerEx() */ @@ -1751,8 +1803,8 @@ static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){ } return 0; -} #endif +} /* ** Close a file. @@ -3018,7 +3070,7 @@ static int winShmMap( HANDLE hMap; /* file-mapping handle */ void *pMap = 0; /* Mapped memory region */ - hMap = osCreateFileMapping(pShmNode->hFile.h, + hMap = osCreateFileMappingW(pShmNode->hFile.h, NULL, PAGE_READWRITE, 0, nByte, NULL ); OSTRACE(("SHM-MAP pid-%d create region=%d nbyte=%d %s\n", @@ -3356,7 +3408,7 @@ static int winOpen( #endif if( isNT() ){ -#if SQLITE_OS_WINRT && 0 /* DISABLED: Can be compiled with WinRT only. */ +#if SQLITE_OS_WINRT CREATEFILE2_EXTENDED_PARAMETERS extendedParameters; extendedParameters.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS); extendedParameters.dwFileAttributes = @@ -3604,6 +3656,7 @@ static int winFullPathname( SimulateIOError( return SQLITE_ERROR ); UNUSED_PARAMETER(nFull); /* WinCE has no concept of a relative pathname, or so I am told. */ + /* WinRT has no way to convert a relative path to an absolute one. */ sqlite3_snprintf(pVfs->mxPathname, zFull, "%s", zRelative); return SQLITE_OK; #endif @@ -3686,7 +3739,7 @@ static void *winDlOpen(sqlite3_vfs *pVfs, const char *zFilename){ return 0; } if( isNT() ){ -#if SQLITE_OS_WINRT && 0 /* DISABLED: Can be compiled with WinRT only. */ +#if SQLITE_OS_WINRT h = osLoadPackagedLibrary((LPCWSTR)zConverted, 0); #else h = osLoadLibraryW((LPCWSTR)zConverted); @@ -3741,11 +3794,19 @@ static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){ memcpy(&zBuf[n], &pid, sizeof(pid)); n += sizeof(pid); } +#if SQLITE_OS_WINRT + if( sizeof(ULONGLONG)<=nBuf-n ){ + ULONGLONG cnt = osGetTickCount64(); + memcpy(&zBuf[n], &cnt, sizeof(cnt)); + n += sizeof(cnt); + } +#else if( sizeof(DWORD)<=nBuf-n ){ DWORD cnt = osGetTickCount(); memcpy(&zBuf[n], &cnt, sizeof(cnt)); n += sizeof(cnt); } +#endif if( sizeof(LARGE_INTEGER)<=nBuf-n ){ LARGE_INTEGER i; osQueryPerformanceCounter(&i); @@ -3903,17 +3964,21 @@ int sqlite3_os_init(void){ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ - assert( ArraySize(aSyscall)==68 ); + assert( ArraySize(aSyscall)==70 ); #if SQLITE_OS_WINRT - sleepObj = osCreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, + sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET, SYNCHRONIZE); #endif #ifndef SQLITE_OMIT_WAL /* get memory map allocation granularity */ memset(&winSysInfo, 0, sizeof(SYSTEM_INFO)); +#if SQLITE_OS_WINRT + osGetNativeSystemInfo(&winSysInfo); +#else osGetSystemInfo(&winSysInfo); +#endif assert(winSysInfo.dwAllocationGranularity > 0); #endif From 5cfbeac070c7ec869941d1d5c6677f487e05cbaa Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 13 Mar 2012 01:30:20 +0000 Subject: [PATCH 18/59] Cleanup the Windows syscall table, removing the unused CreateFileMapping entry. FossilOrigin-Name: fb7d8bf6ec5c0ef9a948bc14c28770e34f57db1a --- manifest | 12 ++--- manifest.uuid | 2 +- src/os_win.c | 145 ++++++++++++++++++++++++-------------------------- 3 files changed, 78 insertions(+), 81 deletions(-) diff --git a/manifest b/manifest index 7e9bd5d38f..57619c3f91 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\schanges\srequired\sto\scompile\sfor\sWinRT\susing\sVS\s11\sbeta.\s\sAlso,\sreplace\smore\sAPIs\swith\stheir\sWinRT\salternatives. -D 2012-03-13T01:16:57.353 +C Cleanup\sthe\sWindows\ssyscall\stable,\sremoving\sthe\sunused\sCreateFileMapping\sentry. +D 2012-03-13T01:30:20.255 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c 3dc4b1a7bafdca23f71439b0ca691668fb65f3c1 +F src/os_win.c 8e0c3142f06e049cead46bc1d83bbc939f582a67 F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 88963c33c19a051280f7f31bdc1b322d6837cf43 -R d6ea1d137f9bbc6d3552b399f2e0cfe5 +P 6b997d9c32076c480ff4f101ff93bae3f443e252 +R 6cc20b48ffd82e276454874a3dd9ea0d U mistachkin -Z 69539dbb9e14faecbb37484031cfeaaf +Z b8edd09153177d0ea866248aa43a320b diff --git a/manifest.uuid b/manifest.uuid index 9df339aea0..85fee2b70b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6b997d9c32076c480ff4f101ff93bae3f443e252 \ No newline at end of file +fb7d8bf6ec5c0ef9a948bc14c28770e34f57db1a \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 7f2a06b872..35e3634e6f 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -273,9 +273,6 @@ static struct win_syscall { #define osCreateFileW ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD, \ LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[5].pCurrent) - /* TODO: REMOVE */ - { "CreateFileMapping", (SYSCALL)0, 0 }, - #if defined(SQLITE_WIN32_HAS_WIDE) { "CreateFileMappingW", (SYSCALL)CreateFileMappingW, 0 }, #else @@ -283,7 +280,7 @@ static struct win_syscall { #endif #define osCreateFileMappingW ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \ - DWORD,DWORD,DWORD,LPCWSTR))aSyscall[7].pCurrent) + DWORD,DWORD,DWORD,LPCWSTR))aSyscall[6].pCurrent) #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) { "CreateMutexW", (SYSCALL)CreateMutexW, 0 }, @@ -292,7 +289,7 @@ static struct win_syscall { #endif #define osCreateMutexW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,BOOL, \ - LPCWSTR))aSyscall[8].pCurrent) + LPCWSTR))aSyscall[7].pCurrent) #if defined(SQLITE_WIN32_HAS_ANSI) { "DeleteFileA", (SYSCALL)DeleteFileA, 0 }, @@ -300,7 +297,7 @@ static struct win_syscall { { "DeleteFileA", (SYSCALL)0, 0 }, #endif -#define osDeleteFileA ((BOOL(WINAPI*)(LPCSTR))aSyscall[9].pCurrent) +#define osDeleteFileA ((BOOL(WINAPI*)(LPCSTR))aSyscall[8].pCurrent) #if defined(SQLITE_WIN32_HAS_WIDE) { "DeleteFileW", (SYSCALL)DeleteFileW, 0 }, @@ -308,7 +305,7 @@ static struct win_syscall { { "DeleteFileW", (SYSCALL)0, 0 }, #endif -#define osDeleteFileW ((BOOL(WINAPI*)(LPCWSTR))aSyscall[10].pCurrent) +#define osDeleteFileW ((BOOL(WINAPI*)(LPCWSTR))aSyscall[9].pCurrent) #if SQLITE_OS_WINCE { "FileTimeToLocalFileTime", (SYSCALL)FileTimeToLocalFileTime, 0 }, @@ -317,7 +314,7 @@ static struct win_syscall { #endif #define osFileTimeToLocalFileTime ((BOOL(WINAPI*)(CONST FILETIME*, \ - LPFILETIME))aSyscall[11].pCurrent) + LPFILETIME))aSyscall[10].pCurrent) #if SQLITE_OS_WINCE { "FileTimeToSystemTime", (SYSCALL)FileTimeToSystemTime, 0 }, @@ -326,11 +323,11 @@ static struct win_syscall { #endif #define osFileTimeToSystemTime ((BOOL(WINAPI*)(CONST FILETIME*, \ - LPSYSTEMTIME))aSyscall[12].pCurrent) + LPSYSTEMTIME))aSyscall[11].pCurrent) { "FlushFileBuffers", (SYSCALL)FlushFileBuffers, 0 }, -#define osFlushFileBuffers ((BOOL(WINAPI*)(HANDLE))aSyscall[13].pCurrent) +#define osFlushFileBuffers ((BOOL(WINAPI*)(HANDLE))aSyscall[12].pCurrent) #if defined(SQLITE_WIN32_HAS_ANSI) { "FormatMessageA", (SYSCALL)FormatMessageA, 0 }, @@ -339,7 +336,7 @@ static struct win_syscall { #endif #define osFormatMessageA ((DWORD(WINAPI*)(DWORD,LPCVOID,DWORD,DWORD,LPSTR, \ - DWORD,va_list*))aSyscall[14].pCurrent) + DWORD,va_list*))aSyscall[13].pCurrent) #if defined(SQLITE_WIN32_HAS_WIDE) { "FormatMessageW", (SYSCALL)FormatMessageW, 0 }, @@ -348,15 +345,15 @@ static struct win_syscall { #endif #define osFormatMessageW ((DWORD(WINAPI*)(DWORD,LPCVOID,DWORD,DWORD,LPWSTR, \ - DWORD,va_list*))aSyscall[15].pCurrent) + DWORD,va_list*))aSyscall[14].pCurrent) { "FreeLibrary", (SYSCALL)FreeLibrary, 0 }, -#define osFreeLibrary ((BOOL(WINAPI*)(HMODULE))aSyscall[16].pCurrent) +#define osFreeLibrary ((BOOL(WINAPI*)(HMODULE))aSyscall[15].pCurrent) { "GetCurrentProcessId", (SYSCALL)GetCurrentProcessId, 0 }, -#define osGetCurrentProcessId ((DWORD(WINAPI*)(VOID))aSyscall[17].pCurrent) +#define osGetCurrentProcessId ((DWORD(WINAPI*)(VOID))aSyscall[16].pCurrent) #if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_ANSI) { "GetDiskFreeSpaceA", (SYSCALL)GetDiskFreeSpaceA, 0 }, @@ -365,7 +362,7 @@ static struct win_syscall { #endif #define osGetDiskFreeSpaceA ((BOOL(WINAPI*)(LPCSTR,LPDWORD,LPDWORD,LPDWORD, \ - LPDWORD))aSyscall[18].pCurrent) + LPDWORD))aSyscall[17].pCurrent) #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) { "GetDiskFreeSpaceW", (SYSCALL)GetDiskFreeSpaceW, 0 }, @@ -374,7 +371,7 @@ static struct win_syscall { #endif #define osGetDiskFreeSpaceW ((BOOL(WINAPI*)(LPCWSTR,LPDWORD,LPDWORD,LPDWORD, \ - LPDWORD))aSyscall[19].pCurrent) + LPDWORD))aSyscall[18].pCurrent) #if defined(SQLITE_WIN32_HAS_ANSI) { "GetFileAttributesA", (SYSCALL)GetFileAttributesA, 0 }, @@ -382,7 +379,7 @@ static struct win_syscall { { "GetFileAttributesA", (SYSCALL)0, 0 }, #endif -#define osGetFileAttributesA ((DWORD(WINAPI*)(LPCSTR))aSyscall[20].pCurrent) +#define osGetFileAttributesA ((DWORD(WINAPI*)(LPCSTR))aSyscall[19].pCurrent) #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) { "GetFileAttributesW", (SYSCALL)GetFileAttributesW, 0 }, @@ -390,7 +387,7 @@ static struct win_syscall { { "GetFileAttributesW", (SYSCALL)0, 0 }, #endif -#define osGetFileAttributesW ((DWORD(WINAPI*)(LPCWSTR))aSyscall[21].pCurrent) +#define osGetFileAttributesW ((DWORD(WINAPI*)(LPCWSTR))aSyscall[20].pCurrent) #if defined(SQLITE_WIN32_HAS_WIDE) { "GetFileAttributesExW", (SYSCALL)GetFileAttributesExW, 0 }, @@ -399,7 +396,7 @@ static struct win_syscall { #endif #define osGetFileAttributesExW ((BOOL(WINAPI*)(LPCWSTR,GET_FILEEX_INFO_LEVELS, \ - LPVOID))aSyscall[22].pCurrent) + LPVOID))aSyscall[21].pCurrent) #if !SQLITE_OS_WINRT { "GetFileSize", (SYSCALL)GetFileSize, 0 }, @@ -407,7 +404,7 @@ static struct win_syscall { { "GetFileSize", (SYSCALL)0, 0 }, #endif -#define osGetFileSize ((DWORD(WINAPI*)(HANDLE,LPDWORD))aSyscall[23].pCurrent) +#define osGetFileSize ((DWORD(WINAPI*)(HANDLE,LPDWORD))aSyscall[22].pCurrent) #if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_ANSI) { "GetFullPathNameA", (SYSCALL)GetFullPathNameA, 0 }, @@ -416,7 +413,7 @@ static struct win_syscall { #endif #define osGetFullPathNameA ((DWORD(WINAPI*)(LPCSTR,DWORD,LPSTR, \ - LPSTR*))aSyscall[24].pCurrent) + LPSTR*))aSyscall[23].pCurrent) #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) { "GetFullPathNameW", (SYSCALL)GetFullPathNameW, 0 }, @@ -425,11 +422,11 @@ static struct win_syscall { #endif #define osGetFullPathNameW ((DWORD(WINAPI*)(LPCWSTR,DWORD,LPWSTR, \ - LPWSTR*))aSyscall[25].pCurrent) + LPWSTR*))aSyscall[24].pCurrent) { "GetLastError", (SYSCALL)GetLastError, 0 }, -#define osGetLastError ((DWORD(WINAPI*)(VOID))aSyscall[26].pCurrent) +#define osGetLastError ((DWORD(WINAPI*)(VOID))aSyscall[25].pCurrent) #if SQLITE_OS_WINCE /* The GetProcAddressA() routine is only available on Windows CE. */ @@ -441,7 +438,7 @@ static struct win_syscall { #endif #define osGetProcAddressA ((FARPROC(WINAPI*)(HMODULE, \ - LPCSTR))aSyscall[27].pCurrent) + LPCSTR))aSyscall[26].pCurrent) #if !SQLITE_OS_WINRT { "GetSystemInfo", (SYSCALL)GetSystemInfo, 0 }, @@ -449,11 +446,11 @@ static struct win_syscall { { "GetSystemInfo", (SYSCALL)0, 0 }, #endif -#define osGetSystemInfo ((VOID(WINAPI*)(LPSYSTEM_INFO))aSyscall[28].pCurrent) +#define osGetSystemInfo ((VOID(WINAPI*)(LPSYSTEM_INFO))aSyscall[27].pCurrent) { "GetSystemTime", (SYSCALL)GetSystemTime, 0 }, -#define osGetSystemTime ((VOID(WINAPI*)(LPSYSTEMTIME))aSyscall[29].pCurrent) +#define osGetSystemTime ((VOID(WINAPI*)(LPSYSTEMTIME))aSyscall[28].pCurrent) #if !SQLITE_OS_WINCE { "GetSystemTimeAsFileTime", (SYSCALL)GetSystemTimeAsFileTime, 0 }, @@ -462,7 +459,7 @@ static struct win_syscall { #endif #define osGetSystemTimeAsFileTime ((VOID(WINAPI*)( \ - LPFILETIME))aSyscall[30].pCurrent) + LPFILETIME))aSyscall[29].pCurrent) #if defined(SQLITE_WIN32_HAS_ANSI) { "GetTempPathA", (SYSCALL)GetTempPathA, 0 }, @@ -470,7 +467,7 @@ static struct win_syscall { { "GetTempPathA", (SYSCALL)0, 0 }, #endif -#define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent) +#define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[30].pCurrent) #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) { "GetTempPathW", (SYSCALL)GetTempPathW, 0 }, @@ -478,7 +475,7 @@ static struct win_syscall { { "GetTempPathW", (SYSCALL)0, 0 }, #endif -#define osGetTempPathW ((DWORD(WINAPI*)(DWORD,LPWSTR))aSyscall[32].pCurrent) +#define osGetTempPathW ((DWORD(WINAPI*)(DWORD,LPWSTR))aSyscall[31].pCurrent) #if !SQLITE_OS_WINRT { "GetTickCount", (SYSCALL)GetTickCount, 0 }, @@ -486,7 +483,7 @@ static struct win_syscall { { "GetTickCount", (SYSCALL)0, 0 }, #endif -#define osGetTickCount ((DWORD(WINAPI*)(VOID))aSyscall[33].pCurrent) +#define osGetTickCount ((DWORD(WINAPI*)(VOID))aSyscall[32].pCurrent) #if defined(SQLITE_WIN32_HAS_ANSI) { "GetVersionExA", (SYSCALL)GetVersionExA, 0 }, @@ -495,12 +492,12 @@ static struct win_syscall { #endif #define osGetVersionExA ((BOOL(WINAPI*)( \ - LPOSVERSIONINFOA))aSyscall[34].pCurrent) + LPOSVERSIONINFOA))aSyscall[33].pCurrent) { "HeapAlloc", (SYSCALL)HeapAlloc, 0 }, #define osHeapAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD, \ - SIZE_T))aSyscall[35].pCurrent) + SIZE_T))aSyscall[34].pCurrent) #if !SQLITE_OS_WINRT { "HeapCreate", (SYSCALL)HeapCreate, 0 }, @@ -509,7 +506,7 @@ static struct win_syscall { #endif #define osHeapCreate ((HANDLE(WINAPI*)(DWORD,SIZE_T, \ - SIZE_T))aSyscall[36].pCurrent) + SIZE_T))aSyscall[35].pCurrent) #if !SQLITE_OS_WINRT { "HeapDestroy", (SYSCALL)HeapDestroy, 0 }, @@ -517,21 +514,21 @@ static struct win_syscall { { "HeapDestroy", (SYSCALL)0, 0 }, #endif -#define osHeapDestroy ((BOOL(WINAPI*)(HANDLE))aSyscall[37].pCurrent) +#define osHeapDestroy ((BOOL(WINAPI*)(HANDLE))aSyscall[36].pCurrent) { "HeapFree", (SYSCALL)HeapFree, 0 }, -#define osHeapFree ((BOOL(WINAPI*)(HANDLE,DWORD,LPVOID))aSyscall[38].pCurrent) +#define osHeapFree ((BOOL(WINAPI*)(HANDLE,DWORD,LPVOID))aSyscall[37].pCurrent) { "HeapReAlloc", (SYSCALL)HeapReAlloc, 0 }, #define osHeapReAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD,LPVOID, \ - SIZE_T))aSyscall[39].pCurrent) + SIZE_T))aSyscall[38].pCurrent) { "HeapSize", (SYSCALL)HeapSize, 0 }, #define osHeapSize ((SIZE_T(WINAPI*)(HANDLE,DWORD, \ - LPCVOID))aSyscall[40].pCurrent) + LPCVOID))aSyscall[39].pCurrent) #if !SQLITE_OS_WINRT { "HeapValidate", (SYSCALL)HeapValidate, 0 }, @@ -540,7 +537,7 @@ static struct win_syscall { #endif #define osHeapValidate ((BOOL(WINAPI*)(HANDLE,DWORD, \ - LPCVOID))aSyscall[41].pCurrent) + LPCVOID))aSyscall[40].pCurrent) #if defined(SQLITE_WIN32_HAS_ANSI) { "LoadLibraryA", (SYSCALL)LoadLibraryA, 0 }, @@ -548,7 +545,7 @@ static struct win_syscall { { "LoadLibraryA", (SYSCALL)0, 0 }, #endif -#define osLoadLibraryA ((HMODULE(WINAPI*)(LPCSTR))aSyscall[42].pCurrent) +#define osLoadLibraryA ((HMODULE(WINAPI*)(LPCSTR))aSyscall[41].pCurrent) #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) { "LoadLibraryW", (SYSCALL)LoadLibraryW, 0 }, @@ -556,7 +553,7 @@ static struct win_syscall { { "LoadLibraryW", (SYSCALL)0, 0 }, #endif -#define osLoadLibraryW ((HMODULE(WINAPI*)(LPCWSTR))aSyscall[43].pCurrent) +#define osLoadLibraryW ((HMODULE(WINAPI*)(LPCWSTR))aSyscall[42].pCurrent) #if !SQLITE_OS_WINRT { "LocalFree", (SYSCALL)LocalFree, 0 }, @@ -564,7 +561,7 @@ static struct win_syscall { { "LocalFree", (SYSCALL)0, 0 }, #endif -#define osLocalFree ((HLOCAL(WINAPI*)(HLOCAL))aSyscall[44].pCurrent) +#define osLocalFree ((HLOCAL(WINAPI*)(HLOCAL))aSyscall[43].pCurrent) #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT { "LockFile", (SYSCALL)LockFile, 0 }, @@ -573,17 +570,17 @@ static struct win_syscall { #endif #define osLockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ - DWORD))aSyscall[45].pCurrent) + DWORD))aSyscall[44].pCurrent) #if !SQLITE_OS_WINCE { "LockFileEx", (SYSCALL)LockFileEx, 0 }, - -#define osLockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,DWORD, \ - LPOVERLAPPED))aSyscall[46].pCurrent) #else { "LockFileEx", (SYSCALL)0, 0 }, #endif +#define osLockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,DWORD, \ + LPOVERLAPPED))aSyscall[45].pCurrent) + #if !SQLITE_OS_WINRT { "MapViewOfFile", (SYSCALL)MapViewOfFile, 0 }, #else @@ -591,26 +588,26 @@ static struct win_syscall { #endif #define osMapViewOfFile ((LPVOID(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ - SIZE_T))aSyscall[47].pCurrent) + SIZE_T))aSyscall[46].pCurrent) { "MultiByteToWideChar", (SYSCALL)MultiByteToWideChar, 0 }, #define osMultiByteToWideChar ((int(WINAPI*)(UINT,DWORD,LPCSTR,int,LPWSTR, \ - int))aSyscall[48].pCurrent) + int))aSyscall[47].pCurrent) { "QueryPerformanceCounter", (SYSCALL)QueryPerformanceCounter, 0 }, #define osQueryPerformanceCounter ((BOOL(WINAPI*)( \ - LARGE_INTEGER*))aSyscall[49].pCurrent) + LARGE_INTEGER*))aSyscall[48].pCurrent) { "ReadFile", (SYSCALL)ReadFile, 0 }, #define osReadFile ((BOOL(WINAPI*)(HANDLE,LPVOID,DWORD,LPDWORD, \ - LPOVERLAPPED))aSyscall[50].pCurrent) + LPOVERLAPPED))aSyscall[49].pCurrent) { "SetEndOfFile", (SYSCALL)SetEndOfFile, 0 }, -#define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[51].pCurrent) +#define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[50].pCurrent) #if !SQLITE_OS_WINRT { "SetFilePointer", (SYSCALL)SetFilePointer, 0 }, @@ -619,7 +616,7 @@ static struct win_syscall { #endif #define osSetFilePointer ((DWORD(WINAPI*)(HANDLE,LONG,PLONG, \ - DWORD))aSyscall[52].pCurrent) + DWORD))aSyscall[51].pCurrent) #if !SQLITE_OS_WINRT { "Sleep", (SYSCALL)Sleep, 0 }, @@ -627,12 +624,12 @@ static struct win_syscall { { "Sleep", (SYSCALL)0, 0 }, #endif -#define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[53].pCurrent) +#define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[52].pCurrent) { "SystemTimeToFileTime", (SYSCALL)SystemTimeToFileTime, 0 }, #define osSystemTimeToFileTime ((BOOL(WINAPI*)(CONST SYSTEMTIME*, \ - LPFILETIME))aSyscall[54].pCurrent) + LPFILETIME))aSyscall[53].pCurrent) #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT { "UnlockFile", (SYSCALL)UnlockFile, 0 }, @@ -641,7 +638,7 @@ static struct win_syscall { #endif #define osUnlockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ - DWORD))aSyscall[55].pCurrent) + DWORD))aSyscall[54].pCurrent) #if !SQLITE_OS_WINCE { "UnlockFileEx", (SYSCALL)UnlockFileEx, 0 }, @@ -650,21 +647,21 @@ static struct win_syscall { #endif #define osUnlockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ - LPOVERLAPPED))aSyscall[56].pCurrent) + LPOVERLAPPED))aSyscall[55].pCurrent) { "UnmapViewOfFile", (SYSCALL)UnmapViewOfFile, 0 }, -#define osUnmapViewOfFile ((BOOL(WINAPI*)(LPCVOID))aSyscall[57].pCurrent) +#define osUnmapViewOfFile ((BOOL(WINAPI*)(LPCVOID))aSyscall[56].pCurrent) { "WideCharToMultiByte", (SYSCALL)WideCharToMultiByte, 0 }, #define osWideCharToMultiByte ((int(WINAPI*)(UINT,DWORD,LPCWSTR,int,LPSTR,int, \ - LPCSTR,LPBOOL))aSyscall[58].pCurrent) + LPCSTR,LPBOOL))aSyscall[57].pCurrent) { "WriteFile", (SYSCALL)WriteFile, 0 }, #define osWriteFile ((BOOL(WINAPI*)(HANDLE,LPCVOID,DWORD,LPDWORD, \ - LPOVERLAPPED))aSyscall[59].pCurrent) + LPOVERLAPPED))aSyscall[58].pCurrent) #if !SQLITE_OS_WINCE { "CreateEventExW", (SYSCALL)CreateEventExW, 0 }, @@ -673,7 +670,7 @@ static struct win_syscall { #endif #define osCreateEventExW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,LPCWSTR, \ - DWORD,DWORD))aSyscall[60].pCurrent) + DWORD,DWORD))aSyscall[59].pCurrent) #if !SQLITE_OS_WINRT { "WaitForSingleObject", (SYSCALL)WaitForSingleObject, 0 }, @@ -682,39 +679,39 @@ static struct win_syscall { #endif #define osWaitForSingleObject ((DWORD(WINAPI*)(HANDLE, \ - DWORD))aSyscall[61].pCurrent) + DWORD))aSyscall[60].pCurrent) #if !SQLITE_OS_WINCE { "WaitForSingleObjectEx", (SYSCALL)WaitForSingleObjectEx, 0 }, - -#define osWaitForSingleObjectEx ((DWORD(WINAPI*)(HANDLE,DWORD, \ - BOOL))aSyscall[62].pCurrent) #else { "WaitForSingleObjectEx", (SYSCALL)0, 0 }, #endif +#define osWaitForSingleObjectEx ((DWORD(WINAPI*)(HANDLE,DWORD, \ + BOOL))aSyscall[61].pCurrent) + #if !SQLITE_OS_WINCE { "SetFilePointerEx", (SYSCALL)SetFilePointerEx, 0 }, - -#define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \ - PLARGE_INTEGER,DWORD))aSyscall[63].pCurrent) #else { "SetFilePointerEx", (SYSCALL)0, 0 }, #endif +#define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \ + PLARGE_INTEGER,DWORD))aSyscall[62].pCurrent) + #if !SQLITE_OS_WINCE { "GetFileInformationByHandleEx", (SYSCALL)GetFileInformationByHandleEx, 0 }, - -#define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \ - FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[64].pCurrent) #else { "GetFileInformationByHandleEx", (SYSCALL)0, 0 }, #endif +#define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \ + FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[63].pCurrent) + { "MapViewOfFileEx", (SYSCALL)MapViewOfFileEx, 0 }, #define osMapViewOfFileEx ((LPVOID(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,SIZE_T, \ - LPVOID))aSyscall[65].pCurrent) + LPVOID))aSyscall[64].pCurrent) #if SQLITE_OS_WINRT { "CreateFile2", (SYSCALL)CreateFile2, 0 }, @@ -723,7 +720,7 @@ static struct win_syscall { #endif #define osCreateFile2 ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD,DWORD, \ - LPCREATEFILE2_EXTENDED_PARAMETERS))aSyscall[66].pCurrent) + LPCREATEFILE2_EXTENDED_PARAMETERS))aSyscall[65].pCurrent) #if SQLITE_OS_WINRT { "LoadPackagedLibrary", (SYSCALL)LoadPackagedLibrary, 0 }, @@ -732,7 +729,7 @@ static struct win_syscall { #endif #define osLoadPackagedLibrary ((HMODULE(WINAPI*)(LPCWSTR, \ - DWORD))aSyscall[67].pCurrent) + DWORD))aSyscall[66].pCurrent) #if SQLITE_OS_WINRT { "GetTickCount64", (SYSCALL)GetTickCount64, 0 }, @@ -740,7 +737,7 @@ static struct win_syscall { { "GetTickCount64", (SYSCALL)0, 0 }, #endif -#define osGetTickCount64 ((ULONGLONG(WINAPI*)(VOID))aSyscall[68].pCurrent) +#define osGetTickCount64 ((ULONGLONG(WINAPI*)(VOID))aSyscall[67].pCurrent) #if SQLITE_OS_WINRT { "GetNativeSystemInfo", (SYSCALL)GetNativeSystemInfo, 0 }, @@ -749,7 +746,7 @@ static struct win_syscall { #endif #define osGetNativeSystemInfo ((VOID(WINAPI*)( \ - LPSYSTEM_INFO))aSyscall[69].pCurrent) + LPSYSTEM_INFO))aSyscall[68].pCurrent) }; /* End of the overrideable system calls */ From f4f327ce07d1d6409735e0192f3d9ce637fc89f1 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 13 Mar 2012 03:35:07 +0000 Subject: [PATCH 19/59] Defer creation of the sleep event object until it is needed. Added sqlite3_win32_write_debug and sqlite3_win32_sleep APIs to assist in portability to WinRT. FossilOrigin-Name: 7af88ad306612dd316827c506dbf8df7477b2ec1 --- manifest | 14 +++--- manifest.uuid | 2 +- src/mutex_w32.c | 8 ++-- src/os_win.c | 115 ++++++++++++++++++++++++++++++++++++++---------- 4 files changed, 103 insertions(+), 36 deletions(-) diff --git a/manifest b/manifest index 57619c3f91..635f1985a7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Cleanup\sthe\sWindows\ssyscall\stable,\sremoving\sthe\sunused\sCreateFileMapping\sentry. -D 2012-03-13T01:30:20.255 +C Defer\screation\sof\sthe\ssleep\sevent\sobject\suntil\sit\sis\sneeded.\s\sAdded\ssqlite3_win32_write_debug\sand\ssqlite3_win32_sleep\sAPIs\sto\sassist\sin\sportability\sto\sWinRT. +D 2012-03-13T03:35:07.176 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -160,14 +160,14 @@ F src/mutex.h 2a79e0c10c26412546b501ee0f3d92b42decf63e F src/mutex_noop.c 7682796b7d8d39bf1c138248858efcd10c9e1553 F src/mutex_os2.c 882d735098c07c8c6a5472b8dd66e19675fe117f F src/mutex_unix.c c3a4e00f96ba068a8dbef34084465979aaf369cc -F src/mutex_w32.c be6dc2be432aa27e1b0d0a19a0da7bace9e4e441 +F src/mutex_w32.c 1170f64d08dc35cd43f6d0bfa833cac5da979279 F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c 8e0c3142f06e049cead46bc1d83bbc939f582a67 +F src/os_win.c 30a479f366f206b663d4d5a6c647aa76d18055d0 F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 6b997d9c32076c480ff4f101ff93bae3f443e252 -R 6cc20b48ffd82e276454874a3dd9ea0d +P fb7d8bf6ec5c0ef9a948bc14c28770e34f57db1a +R 4746d41be07bb3c220103324ba770fee U mistachkin -Z b8edd09153177d0ea866248aa43a320b +Z d05d3c51b5da1f2a8562520fe1f66220 diff --git a/manifest.uuid b/manifest.uuid index 85fee2b70b..98bbae7cfa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fb7d8bf6ec5c0ef9a948bc14c28770e34f57db1a \ No newline at end of file +7af88ad306612dd316827c506dbf8df7477b2ec1 \ No newline at end of file diff --git a/src/mutex_w32.c b/src/mutex_w32.c index 4c3855faf4..3717900608 100644 --- a/src/mutex_w32.c +++ b/src/mutex_w32.c @@ -109,6 +109,8 @@ static int winMutex_isInit = 0; */ static long winMutex_lock = 0; +extern void sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */ + static int winMutexInit(void){ /* The first to increment to 1 does actual initialization */ if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){ @@ -124,11 +126,7 @@ static int winMutexInit(void){ }else{ /* Someone else is in the process of initing the static mutexes */ while( !winMutex_isInit ){ -#if SQLITE_OS_WINRT - Yield(); /* NOP */ -#else - Sleep(1); -#endif + sqlite3_win32_sleep(1); } } return SQLITE_OK; diff --git a/src/os_win.c b/src/os_win.c index 35e3634e6f..3f676c7df6 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -24,6 +24,13 @@ */ #include "os_common.h" +/* +** Macro to find the minimum of two numeric values. +*/ +#ifndef MIN +# define MIN(x,y) ((x)<(y)?(x):(y)) +#endif + /* ** Some Microsoft compilers lack this definition. */ @@ -87,6 +94,13 @@ struct winFile { #define WINFILE_PERSIST_WAL 0x04 /* Persistent WAL mode */ #define WINFILE_PSOW 0x10 /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */ +/* + * The size of the buffer used by sqlite3_win32_write_debug(). + */ +#ifndef SQLITE_WIN32_DBG_BUF_SIZE +# define SQLITE_WIN32_DBG_BUF_SIZE (4096-sizeof(DWORD)) +#endif + /* * If compiled with SQLITE_WIN32_MALLOC on Windows, we will use the * various Win32 API heap functions instead of our own. @@ -748,6 +762,22 @@ static struct win_syscall { #define osGetNativeSystemInfo ((VOID(WINAPI*)( \ LPSYSTEM_INFO))aSyscall[68].pCurrent) +#if defined(SQLITE_WIN32_HAS_ANSI) + { "OutputDebugStringA", (SYSCALL)OutputDebugStringA, 0 }, +#else + { "OutputDebugStringA", (SYSCALL)0, 0 }, +#endif + +#define osOutputDebugStringA ((VOID(WINAPI*)(LPCSTR))aSyscall[69].pCurrent) + +#if defined(SQLITE_WIN32_HAS_WIDE) + { "OutputDebugStringW", (SYSCALL)OutputDebugStringW, 0 }, +#else + { "OutputDebugStringW", (SYSCALL)0, 0 }, +#endif + +#define osOutputDebugStringW ((VOID(WINAPI*)(LPCWSTR))aSyscall[70].pCurrent) + }; /* End of the overrideable system calls */ /* @@ -834,20 +864,62 @@ static const char *winNextSystemCall(sqlite3_vfs *p, const char *zName){ } /* -** The following routine Suspends the thread for at least ms milliseconds. This is equivalent -** to the win32 Sleep() interface. +** This function outputs the specified (ANSI) string to the Win32 debugger +** (if available). +*/ + +void sqlite3_win32_write_debug(char *zBuf, int nBuf){ + char zDbgBuf[SQLITE_WIN32_DBG_BUF_SIZE]; + int nMin = MIN(nBuf,SQLITE_WIN32_DBG_BUF_SIZE-1); /* may be negative. */ + if( nMin<-1 ) nMin = -1; /* all negative values become -1. */ +#if defined(SQLITE_WIN32_HAS_ANSI) + if( nMin>0 ){ + memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE); + memcpy(zDbgBuf, zBuf, nMin); + OutputDebugStringA(zDbgBuf); + }else{ + OutputDebugStringA(zBuf); + } +#elif defined(SQLITE_WIN32_HAS_WIDE) + memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE); + if ( osMultiByteToWideChar( + osAreFileApisANSI() ? CP_ACP : CP_OEMCP, 0, zBuf, + nMin, zDbgBuf, SQLITE_WIN32_DBG_BUF_SIZE/sizeof(WCHAR))<=0 ){ + return; + } + OutputDebugStringW(zDbgBuf); +#else + if( nMin>0 ){ + memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE); + memcpy(zDbgBuf, zBuf, nMin); + fprintf(stderr, "%s", zDbgBuf); + }else{ + fprintf(stderr, "%s", zBuf); + } +#endif +} + +/* +** The following routine suspends the current thread for at least ms +** milliseconds. This is equivalent to the Win32 Sleep() interface. */ #if SQLITE_OS_WINRT -static HANDLE sleepObj; -static void portableSleep(int ms){ - osWaitForSingleObjectEx(sleepObj, ms, FALSE); -} -#else -static void portableSleep(int ms){ - osSleep(ms); -} +static HANDLE sleepObj = NULL; #endif +void sqlite3_win32_sleep(DWORD milliseconds){ +#if SQLITE_OS_WINRT + if ( sleepObj==NULL ){ + sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET, + SYNCHRONIZE); + } + assert( sleepObj!=NULL ); + osWaitForSingleObjectEx(sleepObj, milliseconds, FALSE); +#else + osSleep(milliseconds); +#endif +} + /* ** Return true (non-zero) if we are running under WinNT, Win2K, WinXP, ** or WinCE. Return false (zero) for Win95, Win98, or WinME. @@ -1351,7 +1423,7 @@ static int retryIoerr(int *pnRetry, DWORD *pError){ if( e==ERROR_ACCESS_DENIED || e==ERROR_LOCK_VIOLATION || e==ERROR_SHARING_VIOLATION ){ - portableSleep(win32IoerrRetryDelay*(1+*pnRetry)); + sqlite3_win32_sleep(win32IoerrRetryDelay*(1+*pnRetry)); ++*pnRetry; return 1; } @@ -1824,7 +1896,7 @@ static int winClose(sqlite3_file *id){ do{ rc = osCloseHandle(pFile->h); /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */ - }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (portableSleep(100), 1) ); + }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (sqlite3_win32_sleep(100), 1) ); #if SQLITE_OS_WINCE #define WINCE_DELETION_ATTEMPTS 3 winceDestroyLock(pFile); @@ -1835,7 +1907,7 @@ static int winClose(sqlite3_file *id){ && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff && cnt++ < WINCE_DELETION_ATTEMPTS ){ - portableSleep(100); /* Wait a little before trying again */ + sqlite3_win32_sleep(100); /* Wait a little before trying again */ } sqlite3_free(pFile->zDeleteOnClose); } @@ -2238,7 +2310,7 @@ static int winLock(sqlite3_file *id, int locktype){ ** copy this retry logic. It is a hack intended for Windows only. */ OSTRACE(("could not get a PENDING lock. cnt=%d\n", cnt)); - if( cnt ) portableSleep(1); + if( cnt ) sqlite3_win32_sleep(1); } gotPendingLock = res; if( !res ){ @@ -3819,7 +3891,7 @@ static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){ ** Sleep for a little while. Return the amount of time slept. */ static int winSleep(sqlite3_vfs *pVfs, int microsec){ - portableSleep((microsec+999)/1000); + sqlite3_win32_sleep((microsec+999)/1000); UNUSED_PARAMETER(pVfs); return ((microsec+999)/1000)*1000; } @@ -3961,12 +4033,7 @@ int sqlite3_os_init(void){ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ - assert( ArraySize(aSyscall)==70 ); - -#if SQLITE_OS_WINRT - sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET, - SYNCHRONIZE); -#endif + assert( ArraySize(aSyscall)==71 ); #ifndef SQLITE_OMIT_WAL /* get memory map allocation granularity */ @@ -3985,8 +4052,10 @@ int sqlite3_os_init(void){ int sqlite3_os_end(void){ #if SQLITE_OS_WINRT - osCloseHandle(sleepObj); - sleepObj = NULL; + if( sleepObj != NULL ){ + osCloseHandle(sleepObj); + sleepObj = NULL; + } #endif return SQLITE_OK; } From 5ff72401c9964c119057eeba3efa7b16a71ab21c Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 13 Mar 2012 03:38:22 +0000 Subject: [PATCH 20/59] Add assert to verify the number of characters to write in sqlite3_win32_write_debug. FossilOrigin-Name: 8083f6164f3308c1c1d4f4d84be1894e382fe2e6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 635f1985a7..c71ea05a4c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Defer\screation\sof\sthe\ssleep\sevent\sobject\suntil\sit\sis\sneeded.\s\sAdded\ssqlite3_win32_write_debug\sand\ssqlite3_win32_sleep\sAPIs\sto\sassist\sin\sportability\sto\sWinRT. -D 2012-03-13T03:35:07.176 +C Add\sassert\sto\sverify\sthe\snumber\sof\scharacters\sto\swrite\sin\ssqlite3_win32_write_debug. +D 2012-03-13T03:38:22.981 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c 30a479f366f206b663d4d5a6c647aa76d18055d0 +F src/os_win.c c47a86a8b8a958fc8cae06a45e56ed3217a686e4 F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P fb7d8bf6ec5c0ef9a948bc14c28770e34f57db1a -R 4746d41be07bb3c220103324ba770fee +P 7af88ad306612dd316827c506dbf8df7477b2ec1 +R 733fe38048c4d65e48f1419dbebc0b16 U mistachkin -Z d05d3c51b5da1f2a8562520fe1f66220 +Z ac12a0ffda13979ead9c043455a8d437 diff --git a/manifest.uuid b/manifest.uuid index 98bbae7cfa..5704843a77 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7af88ad306612dd316827c506dbf8df7477b2ec1 \ No newline at end of file +8083f6164f3308c1c1d4f4d84be1894e382fe2e6 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 3f676c7df6..6a8a4f3cdd 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -872,6 +872,7 @@ void sqlite3_win32_write_debug(char *zBuf, int nBuf){ char zDbgBuf[SQLITE_WIN32_DBG_BUF_SIZE]; int nMin = MIN(nBuf,SQLITE_WIN32_DBG_BUF_SIZE-1); /* may be negative. */ if( nMin<-1 ) nMin = -1; /* all negative values become -1. */ + assert( nMin==-1 || nMin==0 || nMin0 ){ memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE); From a112d140ae186dcaa9a10021923fdc5c3bb1cf64 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 14 Mar 2012 00:44:01 +0000 Subject: [PATCH 21/59] Add experimental support for resolving relative database file paths using a fixed user-defined directory. FossilOrigin-Name: 7354ae8fd3eccee2cf9f6501da5b1a014c31556f --- manifest | 22 ++++++------ manifest.uuid | 2 +- src/main.c | 9 +++++ src/os_win.c | 90 ++++++++++++++++++++++++++++++++++++++++++++---- src/pragma.c | 42 ++++++++++++++++++++++ src/sqlite.h.in | 33 ++++++++++++++++++ src/test1.c | 2 ++ test/pragma.test | 40 +++++++++++++++++++++ 8 files changed, 222 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index c71ea05a4c..60cc762898 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sassert\sto\sverify\sthe\snumber\sof\scharacters\sto\swrite\sin\ssqlite3_win32_write_debug. -D 2012-03-13T03:38:22.981 +C Add\sexperimental\ssupport\sfor\sresolving\srelative\sdatabase\sfile\spaths\susing\sa\sfixed\suser-defined\sdirectory. +D 2012-03-14T00:44:01.952 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -147,7 +147,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416 F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d -F src/main.c dcb4a15254dca9cc59dba63e813a8c140c021832 +F src/main.c 5808bc6e2d2a80c3d73c42622fa162dc3cc24893 F src/malloc.c 15afac5e59b6584efe072e9933aefb4230e74f97 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c b3677415e69603d6a0e7c5410a1b3731d55beda1 @@ -167,14 +167,14 @@ F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c c47a86a8b8a958fc8cae06a45e56ed3217a686e4 +F src/os_win.c ed4f4f5cad8c708d5e443139df0d65e9354b8368 F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c F src/pcache1.c b30b1c35908346ecc43d8d9d17f2ddf6817f8f60 -F src/pragma.c e708b3bb5704605816f617e0b1d63a5488060715 +F src/pragma.c 149d8400ff783741d41389176832241cbff8f856 F src/prepare.c ec4989f7f480544bdc4192fe663470d2a2d7d61e F src/printf.c 7ffb4ebb8b341f67e049695ba031da717b3d2699 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 @@ -182,14 +182,14 @@ F src/resolve.c 3d3e80a98f203ac6b9329e9621e29eda85ddfd40 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 44ccdcb5d2a1c48622c179b2d72167b716388581 F src/shell.c aa28f117033ba3e44b5eaaf2ad572222bcdfd66e -F src/sqlite.h.in f46e368d1a28b09d876e35444785674d170f2d62 +F src/sqlite.h.in 21d17ec95bc6004908f8d8158ffd9021790d1b06 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqliteInt.h b013dab7d43fb67c3ca2f0253d7863abb37e233c F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 4568e72dfd36b6a5911f93457364deb072e0b03a F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c 2aeb69958965dad0842d5ea1456f1a958ef296e6 -F src/test1.c 328cbe4a4ee6d10d67ece2a7adaa2770569fae0f +F src/test1.c 8e1e72e09d7941d9d22fd6a544df39e2e3f4efd9 F src/test2.c 711555927f1f7e8db9aab86b512bc6934a774abe F src/test3.c 91d3f1a09cfae3533ef17d8b484a160f3d1f1a21 F src/test4.c d1e5a5e904d4b444cf572391fdcb017638e36ff7 @@ -636,7 +636,7 @@ F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0 F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16 F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 F test/permutations.test 2b5a1b64a8e5114757457fbce9010387d1fe7682 -F test/pragma.test c51c148defe32bf4a419a522f95d26838d5cf677 +F test/pragma.test eba5bd337ae68870985cd1776659bb136b33dada F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947 F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552 F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 7af88ad306612dd316827c506dbf8df7477b2ec1 -R 733fe38048c4d65e48f1419dbebc0b16 +P 8083f6164f3308c1c1d4f4d84be1894e382fe2e6 +R ecb2eb3e3cb321cdfbc1971b31d42211 U mistachkin -Z ac12a0ffda13979ead9c043455a8d437 +Z 0c49ed1cd4cd58d4e2dd23c2fb64b825 diff --git a/manifest.uuid b/manifest.uuid index 5704843a77..b333b0d42b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8083f6164f3308c1c1d4f4d84be1894e382fe2e6 \ No newline at end of file +7354ae8fd3eccee2cf9f6501da5b1a014c31556f \ No newline at end of file diff --git a/src/main.c b/src/main.c index 3a1dff576a..601138b8df 100644 --- a/src/main.c +++ b/src/main.c @@ -74,6 +74,15 @@ void (*sqlite3IoTrace)(const char*, ...) = 0; */ char *sqlite3_temp_directory = 0; +/* +** If the following global variable points to a string which is the +** name of a directory, then that directory will be used to store +** all database files specified with a relative pathname. +** +** See also the "PRAGMA data_store_directory" SQL command. +*/ +char *sqlite3_data_directory = 0; + /* ** Initialize SQLite. ** diff --git a/src/os_win.c b/src/os_win.c index 6a8a4f3cdd..f286921820 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -3703,6 +3703,43 @@ static int winAccess( } +/* +** Returns non-zero if the specified path name should be used verbatim. If +** non-zero is returned from this function, the calling function must simply +** use the provided path name verbatim -OR- resolve it into a full path name +** using the GetFullPathName Win32 API function (if available). +*/ +static BOOL winIsVerbatimPathname( + const char *zPathname +){ + /* + ** If the path name starts with a forward slash or a backslash, it is either + ** a legal UNC name, a volume relative path, or an absolute path name in the + ** "Unix" format on Windows. There is no easy way to differentiate between + ** the final two cases; therefore, we return the safer return value of TRUE + ** so that callers of this function will simply use it verbatim. + */ + if ( zPathname[0]=='/' || zPathname[0]=='\\' ){ + return TRUE; + } + + /* + ** If the path name starts with a letter and a colon it is either a volume + ** relative path or an absolute path. Callers of this function must not + ** attempt to treat it as a relative path name (i.e. they should simply use + ** it verbatim). + */ + if ( sqlite3Isalpha(zPathname[0]) && zPathname[1]==':' ){ + return TRUE; + } + + /* + ** If we get to this point, the path name should almost certainly be a purely + ** relative one (i.e. not a UNC name, not absolute, and not volume relative). + */ + return FALSE; +} + /* ** Turn a relative pathname into a full pathname. Write the full ** pathname into zOut[]. zOut[] will be at least pVfs->mxPathname @@ -3718,16 +3755,47 @@ static int winFullPathname( #if defined(__CYGWIN__) SimulateIOError( return SQLITE_ERROR ); UNUSED_PARAMETER(nFull); - cygwin_conv_to_full_win32_path(zRelative, zFull); + assert( pVfs->mxPathname>=MAX_PATH ); + assert( nFull>=pVfs->mxPathname ); + if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ + /* + ** NOTE: We are dealing with a relative path name and the data + ** directory has been set. Therefore, use it as the basis + ** for converting the relative path name to an absolute + ** one by prepending the data directory and a slash. + */ + char zOut[MAX_PATH+1]; + memset(zOut, 0, MAX_PATH+1); + cygwin_conv_to_win32_path(zRelative, zOut); /* POSIX to Win32 */ + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s", + sqlite3_data_directory, zOut); + }else{ + /* + ** NOTE: The Cygwin docs state that the maximum length needed + ** for the buffer passed to cygwin_conv_to_full_win32_path + ** is MAX_PATH. + */ + cygwin_conv_to_full_win32_path(zRelative, zFull); + } return SQLITE_OK; #endif -#if SQLITE_OS_WINCE || SQLITE_OS_WINRT +#if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__) SimulateIOError( return SQLITE_ERROR ); - UNUSED_PARAMETER(nFull); /* WinCE has no concept of a relative pathname, or so I am told. */ /* WinRT has no way to convert a relative path to an absolute one. */ - sqlite3_snprintf(pVfs->mxPathname, zFull, "%s", zRelative); + if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ + /* + ** NOTE: We are dealing with a relative path name and the data + ** directory has been set. Therefore, use it as the basis + ** for converting the relative path name to an absolute + ** one by prepending the data directory and a backslash. + */ + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s", + sqlite3_data_directory, zRelative); + }else{ + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative); + } return SQLITE_OK; #endif @@ -3749,7 +3817,17 @@ static int winFullPathname( ** current working directory has been unlinked. */ SimulateIOError( return SQLITE_ERROR ); - UNUSED_PARAMETER(nFull); + if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ + /* + ** NOTE: We are dealing with a relative path name and the data + ** directory has been set. Therefore, use it as the basis + ** for converting the relative path name to an absolute + ** one by prepending the data directory and a backslash. + */ + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s", + sqlite3_data_directory, zRelative); + return SQLITE_OK; + } zConverted = convertUtf8Filename(zRelative); if( zConverted==0 ){ return SQLITE_IOERR_NOMEM; @@ -3783,7 +3861,7 @@ static int winFullPathname( } #endif if( zOut ){ - sqlite3_snprintf(pVfs->mxPathname, zFull, "%s", zOut); + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zOut); sqlite3_free(zOut); return SQLITE_OK; }else{ diff --git a/src/pragma.c b/src/pragma.c index 2db0b61508..2507acedf6 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -804,6 +804,48 @@ void sqlite3Pragma( } }else + /* + ** PRAGMA data_store_directory + ** PRAGMA data_store_directory = ""|"directory_name" + ** + ** Return or set the local value of the data_store_directory flag. Changing + ** the value sets a specific directory to be used for database files that + ** were specified with a relative pathname. Setting to a null string reverts + ** to the default database directory, which for database files specified with + ** a relative path will probably be based on the current directory for the + ** process. Database file specified with an absolute path are not impacted + ** by this setting, regardless of its value. + ** + */ + if( sqlite3StrICmp(zLeft, "data_store_directory")==0 ){ + if( !zRight ){ + if( sqlite3_data_directory ){ + sqlite3VdbeSetNumCols(v, 1); + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, + "data_store_directory", SQLITE_STATIC); + sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, sqlite3_data_directory, 0); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); + } + }else{ +#ifndef SQLITE_OMIT_WSD + if( zRight[0] ){ + int res; + rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res); + if( rc!=SQLITE_OK || res==0 ){ + sqlite3ErrorMsg(pParse, "not a writable directory"); + goto pragma_out; + } + } + sqlite3_free(sqlite3_data_directory); + if( zRight[0] ){ + sqlite3_data_directory = sqlite3_mprintf("%s", zRight); + }else{ + sqlite3_data_directory = 0; + } +#endif /* SQLITE_OMIT_WSD */ + } + }else + #if !defined(SQLITE_ENABLE_LOCKING_STYLE) # if defined(__APPLE__) # define SQLITE_ENABLE_LOCKING_STYLE 1 diff --git a/src/sqlite.h.in b/src/sqlite.h.in index b43fe208f8..44d52e828b 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -4443,6 +4443,39 @@ int sqlite3_sleep(int); */ SQLITE_EXTERN char *sqlite3_temp_directory; +/* +** CAPI3REF: Name Of The Folder Holding Database Files +** +** ^(If this global variable is made to point to a string which is +** the name of a folder (a.k.a. directory), then all database files +** specified with a relative pathname and created or accessed by +** SQLite when using a built-in [sqlite3_vfs | VFS] will be assumed +** to be relative to that directory.)^ ^If this variable is a NULL +** pointer, then SQLite assumes that all database files specified +** with a relative pathname are relative to the current directory +** for the process. +** +** It is not safe to read or modify this variable in more than one +** thread at a time. It is not safe to read or modify this variable +** if a [database connection] is being used at the same time in a separate +** thread. +** It is intended that this variable be set once +** as part of process initialization and before any SQLite interface +** routines have been called and that this variable remain unchanged +** thereafter. +** +** ^The [data_store_directory pragma] may modify this variable and cause +** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, +** the [data_store_directory pragma] always assumes that any string +** that this variable points to is held in memory obtained from +** [sqlite3_malloc] and the pragma may attempt to free that memory +** using [sqlite3_free]. +** Hence, if this variable is modified directly, either it should be +** made NULL or made to point to memory obtained from [sqlite3_malloc] +** or else the use of the [data_store_directory pragma] should be avoided. +*/ +SQLITE_EXTERN char *sqlite3_data_directory; + /* ** CAPI3REF: Test For Auto-Commit Mode ** KEYWORDS: {autocommit mode} diff --git a/src/test1.c b/src/test1.c index 281823d5a8..2e0bd932a2 100644 --- a/src/test1.c +++ b/src/test1.c @@ -6261,6 +6261,8 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ (char*)&sqlite_static_bind_nbyte, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite_temp_directory", (char*)&sqlite3_temp_directory, TCL_LINK_STRING); + Tcl_LinkVar(interp, "sqlite_data_directory", + (char*)&sqlite3_data_directory, TCL_LINK_STRING); Tcl_LinkVar(interp, "bitmask_size", (char*)&bitmask_size, TCL_LINK_INT|TCL_LINK_READ_ONLY); Tcl_LinkVar(interp, "sqlite_sync_count", diff --git a/test/pragma.test b/test/pragma.test index bb10327c3a..f8773f1b22 100644 --- a/test/pragma.test +++ b/test/pragma.test @@ -40,6 +40,7 @@ do_not_use_codec # pragma-15.*: Test that the value set using the cache_size pragma is not # reset when the schema is reloaded. # pragma-16.*: Test proxy locking +# pragma-20.*: Test data_store_directory. # ifcapable !pragma { @@ -1510,5 +1511,44 @@ do_test pragma-19.5 { file tail [lindex [execsql {PRAGMA filename}] 0] } {test.db} +# Test data_store_directory pragma +# +db close +sqlite3 db test.db +file mkdir data_dir +do_test pragma-20.1 { + catchsql {PRAGMA data_store_directory} +} {0 {}} +do_test pragma-20.2 { + set pwd [string map {' ''} [file nativename [get_pwd]]] + catchsql "PRAGMA data_store_directory='$pwd';" +} {0 {}} +do_test pragma-20.3 { + catchsql {PRAGMA data_store_directory} +} [list 0 [list [file nativename [get_pwd]]]] +do_test pragma-20.4 { + set pwd [string map {' ''} [file nativename \ + [file join [get_pwd] data_dir]]] + catchsql "PRAGMA data_store_directory='$pwd';" +} {0 {}} +do_test pragma-20.5 { + sqlite3 db2 test2.db + catchsql "PRAGMA database_list;" db2 +} [list 0 [list 0 main [file nativename \ + [file join [get_pwd] data_dir test2.db]]]] +catch {db2 close} +do_test pragma-20.6 { + sqlite3 db2 [file join [get_pwd] test2.db] + catchsql "PRAGMA database_list;" db2 +} [list 0 [list 0 main [file nativename \ + [file join [get_pwd] test2.db]]]] +catch {db2 close} +do_test pragma-20.7 { + catchsql "PRAGMA data_store_directory='';" +} {0 {}} +do_test pragma-20.8 { + catchsql {PRAGMA data_store_directory} +} {0 {}} +forcedelete data_dir finish_test From 184997c9a62f5bc8d81466ac21cb5180983c5315 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 14 Mar 2012 01:28:35 +0000 Subject: [PATCH 22/59] Add warning to the docs about changing the data directory when a database connection is open. FossilOrigin-Name: c07cd85ca9698b48f960b164cab3a38472a17640 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 60cc762898..363decb90d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sexperimental\ssupport\sfor\sresolving\srelative\sdatabase\sfile\spaths\susing\sa\sfixed\suser-defined\sdirectory. -D 2012-03-14T00:44:01.952 +C Add\swarning\sto\sthe\sdocs\sabout\schanging\sthe\sdata\sdirectory\swhen\sa\sdatabase\sconnection\sis\sopen. +D 2012-03-14T01:28:35.372 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -182,7 +182,7 @@ F src/resolve.c 3d3e80a98f203ac6b9329e9621e29eda85ddfd40 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 44ccdcb5d2a1c48622c179b2d72167b716388581 F src/shell.c aa28f117033ba3e44b5eaaf2ad572222bcdfd66e -F src/sqlite.h.in 21d17ec95bc6004908f8d8158ffd9021790d1b06 +F src/sqlite.h.in 733a91460165e21b868c6b716318637b893abb2c F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqliteInt.h b013dab7d43fb67c3ca2f0253d7863abb37e233c F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 8083f6164f3308c1c1d4f4d84be1894e382fe2e6 -R ecb2eb3e3cb321cdfbc1971b31d42211 +P 7354ae8fd3eccee2cf9f6501da5b1a014c31556f +R 170d0fdac9fdf0b052c62efc8d999504 U mistachkin -Z 0c49ed1cd4cd58d4e2dd23c2fb64b825 +Z aea70d1fe458e9c31aee5d47ae6bde38 diff --git a/manifest.uuid b/manifest.uuid index b333b0d42b..af9a7c1951 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7354ae8fd3eccee2cf9f6501da5b1a014c31556f \ No newline at end of file +c07cd85ca9698b48f960b164cab3a38472a17640 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 44d52e828b..f43cfa0c55 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -4455,6 +4455,9 @@ SQLITE_EXTERN char *sqlite3_temp_directory; ** with a relative pathname are relative to the current directory ** for the process. ** +** Changing the value of this variable while a database connection is +** open can result in a corrupt database. +** ** It is not safe to read or modify this variable in more than one ** thread at a time. It is not safe to read or modify this variable ** if a [database connection] is being used at the same time in a separate From 25cf4fe98826a75910dbb7e176c6fdadf0a38cff Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 14 Mar 2012 03:41:32 +0000 Subject: [PATCH 23/59] Remove SQLITE_OS_WINRT setting from MSVC makefile. FossilOrigin-Name: df4caf1326f5aa3ba11345e5e9604d7af4385fe8 --- Makefile.msc | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index a21223f022..2d8f44c733 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -47,7 +47,7 @@ BCC = cl.exe # will run on the target platform. (BCC and TCC are usually the # same unless your are cross-compiling.) # -TCC = cl.exe -W3 -DSQLITE_OS_WIN=1 -DSQLITE_OS_WINRT=0 -I. -I$(TOP)\src -fp:precise +TCC = cl.exe -W3 -DSQLITE_OS_WIN=1 -I. -I$(TOP)\src -fp:precise # The mksqlite3c.tcl and mksqlite3h.tcl scripts will pull in # any extension header files by default. For non-amalgamation diff --git a/manifest b/manifest index 363decb90d..37f6c99d5c 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Add\swarning\sto\sthe\sdocs\sabout\schanging\sthe\sdata\sdirectory\swhen\sa\sdatabase\sconnection\sis\sopen. -D 2012-03-14T01:28:35.372 +C Remove\sSQLITE_OS_WINRT\ssetting\sfrom\sMSVC\smakefile. +D 2012-03-14T03:41:32.617 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc c8e27f878adc9aa70682b9aa986e02e9d597b8d0 +F Makefile.msc 7849a871b6cdb20fd51baee6bbe5965a03326be4 F Makefile.vxworks 3b7fe7a0571fdadc61363ebc1b23732d2d6363ca F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION bb4c2a86abe53ea3c1d6ea515b69a426040e2414 @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 7354ae8fd3eccee2cf9f6501da5b1a014c31556f -R 170d0fdac9fdf0b052c62efc8d999504 +P c07cd85ca9698b48f960b164cab3a38472a17640 +R 25f557bcc396ad7a4290697a9464ba77 U mistachkin -Z aea70d1fe458e9c31aee5d47ae6bde38 +Z 55001cc87e573530757b1e4bf77ede4f diff --git a/manifest.uuid b/manifest.uuid index af9a7c1951..6b0e7d5382 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c07cd85ca9698b48f960b164cab3a38472a17640 \ No newline at end of file +df4caf1326f5aa3ba11345e5e9604d7af4385fe8 \ No newline at end of file From 0df898e27d5dabc8d995deadfa4241d05bcdb0b7 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 14 Mar 2012 20:17:34 +0000 Subject: [PATCH 24/59] Avoid redefining macros. Enable use of the Win32 native heap on WinRT. Use the syscall table to call OutputDebugStringW and fix type casting warnings. FossilOrigin-Name: 46c412a8f6470c9e8c4bdeafaf4db435fbb694ab --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 43 ++++++++++++++++++++++++++++++++++--------- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 37f6c99d5c..373fdaf5a7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sSQLITE_OS_WINRT\ssetting\sfrom\sMSVC\smakefile. -D 2012-03-14T03:41:32.617 +C Avoid\sredefining\smacros.\s\sEnable\suse\sof\sthe\sWin32\snative\sheap\son\sWinRT.\s\sUse\sthe\ssyscall\stable\sto\scall\sOutputDebugStringW\sand\sfix\stype\scasting\swarnings. +D 2012-03-14T20:17:34.431 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c ed4f4f5cad8c708d5e443139df0d65e9354b8368 +F src/os_win.c 7f5f9d8e2160512e42d446a69c7290fc2c3ba04b F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P c07cd85ca9698b48f960b164cab3a38472a17640 -R 25f557bcc396ad7a4290697a9464ba77 +P df4caf1326f5aa3ba11345e5e9604d7af4385fe8 +R 6d203715243f929ef5f7dee64f72709c U mistachkin -Z 55001cc87e573530757b1e4bf77ede4f +Z b2f77c539a50e8f1af539640575ebb2c diff --git a/manifest.uuid b/manifest.uuid index 6b0e7d5382..a332570030 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -df4caf1326f5aa3ba11345e5e9604d7af4385fe8 \ No newline at end of file +46c412a8f6470c9e8c4bdeafaf4db435fbb694ab \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index f286921820..a697e3774d 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -247,7 +247,9 @@ static struct win_syscall { { "AreFileApisANSI", (SYSCALL)0, 0 }, #endif +#ifndef osAreFileApisANSI #define osAreFileApisANSI ((BOOL(WINAPI*)(VOID))aSyscall[0].pCurrent) +#endif #if SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE) { "CharLowerW", (SYSCALL)CharLowerW, 0 }, @@ -583,8 +585,10 @@ static struct win_syscall { { "LockFile", (SYSCALL)0, 0 }, #endif +#ifndef osLockFile #define osLockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ DWORD))aSyscall[44].pCurrent) +#endif #if !SQLITE_OS_WINCE { "LockFileEx", (SYSCALL)LockFileEx, 0 }, @@ -592,8 +596,10 @@ static struct win_syscall { { "LockFileEx", (SYSCALL)0, 0 }, #endif +#ifndef osLockFileEx #define osLockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,DWORD, \ LPOVERLAPPED))aSyscall[45].pCurrent) +#endif #if !SQLITE_OS_WINRT { "MapViewOfFile", (SYSCALL)MapViewOfFile, 0 }, @@ -651,8 +657,10 @@ static struct win_syscall { { "UnlockFile", (SYSCALL)0, 0 }, #endif +#ifndef osUnlockFile #define osUnlockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ DWORD))aSyscall[54].pCurrent) +#endif #if !SQLITE_OS_WINCE { "UnlockFileEx", (SYSCALL)UnlockFileEx, 0 }, @@ -778,6 +786,10 @@ static struct win_syscall { #define osOutputDebugStringW ((VOID(WINAPI*)(LPCWSTR))aSyscall[70].pCurrent) + { "GetProcessHeap", (SYSCALL)GetProcessHeap, 0 }, + +#define osGetProcessHeap() ((HANDLE(WINAPI*)(VOID))aSyscall[71].pCurrent) + }; /* End of the overrideable system calls */ /* @@ -885,10 +897,10 @@ void sqlite3_win32_write_debug(char *zBuf, int nBuf){ memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE); if ( osMultiByteToWideChar( osAreFileApisANSI() ? CP_ACP : CP_OEMCP, 0, zBuf, - nMin, zDbgBuf, SQLITE_WIN32_DBG_BUF_SIZE/sizeof(WCHAR))<=0 ){ + nMin, (LPWSTR)zDbgBuf, SQLITE_WIN32_DBG_BUF_SIZE/sizeof(WCHAR))<=0 ){ return; } - OutputDebugStringW(zDbgBuf); + osOutputDebugStringW((LPCWSTR)zDbgBuf); #else if( nMin>0 ){ memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE); @@ -958,7 +970,7 @@ static void *winMemMalloc(int nBytes){ hHeap = winMemGetHeap(); assert( hHeap!=0 ); assert( hHeap!=INVALID_HANDLE_VALUE ); -#ifdef SQLITE_WIN32_MALLOC_VALIDATE +#ifdef !SQLITE_OS_WINRT && SQLITE_WIN32_MALLOC_VALIDATE assert ( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) ); #endif assert( nBytes>=0 ); @@ -980,7 +992,7 @@ static void winMemFree(void *pPrior){ hHeap = winMemGetHeap(); assert( hHeap!=0 ); assert( hHeap!=INVALID_HANDLE_VALUE ); -#ifdef SQLITE_WIN32_MALLOC_VALIDATE +#ifdef !SQLITE_OS_WINRT && SQLITE_WIN32_MALLOC_VALIDATE assert ( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ); #endif if( !pPrior ) return; /* Passing NULL to HeapFree is undefined. */ @@ -1001,7 +1013,7 @@ static void *winMemRealloc(void *pPrior, int nBytes){ hHeap = winMemGetHeap(); assert( hHeap!=0 ); assert( hHeap!=INVALID_HANDLE_VALUE ); -#ifdef SQLITE_WIN32_MALLOC_VALIDATE +#ifdef !SQLITE_OS_WINRT && SQLITE_WIN32_MALLOC_VALIDATE assert ( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ); #endif assert( nBytes>=0 ); @@ -1029,7 +1041,7 @@ static int winMemSize(void *p){ hHeap = winMemGetHeap(); assert( hHeap!=0 ); assert( hHeap!=INVALID_HANDLE_VALUE ); -#ifdef SQLITE_WIN32_MALLOC_VALIDATE +#ifdef !SQLITE_OS_WINRT && SQLITE_WIN32_MALLOC_VALIDATE assert ( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) ); #endif if( !p ) return 0; @@ -1057,6 +1069,8 @@ static int winMemInit(void *pAppData){ if( !pWinMemData ) return SQLITE_ERROR; assert( pWinMemData->magic==WINMEM_MAGIC ); + +#if !SQLITE_OS_WINRT if( !pWinMemData->hHeap ){ pWinMemData->hHeap = osHeapCreate(SQLITE_WIN32_HEAP_FLAGS, SQLITE_WIN32_HEAP_INIT_SIZE, @@ -1069,10 +1083,21 @@ static int winMemInit(void *pAppData){ return SQLITE_NOMEM; } pWinMemData->bOwned = TRUE; + assert( pWinMemData->bOwned ); } +#else + pWinMemData->hHeap = osGetProcessHeap(); + if( !pWinMemData->hHeap ){ + sqlite3_log(SQLITE_NOMEM, + "failed to GetProcessHeap (%d)", osGetLastError()); + return SQLITE_NOMEM; + } + pWinMemData->bOwned = FALSE; + assert( !pWinMemData->bOwned ); +#endif assert( pWinMemData->hHeap!=0 ); assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE ); -#ifdef SQLITE_WIN32_MALLOC_VALIDATE +#ifdef !SQLITE_OS_WINRT && SQLITE_WIN32_MALLOC_VALIDATE assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) ); #endif return SQLITE_OK; @@ -1087,7 +1112,7 @@ static void winMemShutdown(void *pAppData){ if( !pWinMemData ) return; if( pWinMemData->hHeap ){ assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE ); -#ifdef SQLITE_WIN32_MALLOC_VALIDATE +#ifdef !SQLITE_OS_WINRT && SQLITE_WIN32_MALLOC_VALIDATE assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) ); #endif if( pWinMemData->bOwned ){ @@ -4112,7 +4137,7 @@ int sqlite3_os_init(void){ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ - assert( ArraySize(aSyscall)==71 ); + assert( ArraySize(aSyscall)==72 ); #ifndef SQLITE_OMIT_WAL /* get memory map allocation granularity */ From e8c9a184be32c0370b925d90723b836284ba40ba Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 14 Mar 2012 20:20:37 +0000 Subject: [PATCH 25/59] Fix typos, use #if instead of #ifdef when checking for the Win32 native heap validation define. FossilOrigin-Name: 845aa46f69784420ada4116078f8dc0a68cf3707 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 373fdaf5a7..4314ec4ed7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sredefining\smacros.\s\sEnable\suse\sof\sthe\sWin32\snative\sheap\son\sWinRT.\s\sUse\sthe\ssyscall\stable\sto\scall\sOutputDebugStringW\sand\sfix\stype\scasting\swarnings. -D 2012-03-14T20:17:34.431 +C Fix\stypos,\suse\s#if\sinstead\sof\s#ifdef\swhen\schecking\sfor\sthe\sWin32\snative\sheap\svalidation\sdefine. +D 2012-03-14T20:20:37.765 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c 7f5f9d8e2160512e42d446a69c7290fc2c3ba04b +F src/os_win.c 817bce5df90080879263f0a7b0d6be194f5a152e F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P df4caf1326f5aa3ba11345e5e9604d7af4385fe8 -R 6d203715243f929ef5f7dee64f72709c +P 46c412a8f6470c9e8c4bdeafaf4db435fbb694ab +R 39e5d64245595f7182fd72bc71b1f514 U mistachkin -Z b2f77c539a50e8f1af539640575ebb2c +Z f46c995916aec3a9f0322bdbc2b14015 diff --git a/manifest.uuid b/manifest.uuid index a332570030..29889e626b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -46c412a8f6470c9e8c4bdeafaf4db435fbb694ab \ No newline at end of file +845aa46f69784420ada4116078f8dc0a68cf3707 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index a697e3774d..b12ba27809 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -970,7 +970,7 @@ static void *winMemMalloc(int nBytes){ hHeap = winMemGetHeap(); assert( hHeap!=0 ); assert( hHeap!=INVALID_HANDLE_VALUE ); -#ifdef !SQLITE_OS_WINRT && SQLITE_WIN32_MALLOC_VALIDATE +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE) assert ( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) ); #endif assert( nBytes>=0 ); @@ -992,7 +992,7 @@ static void winMemFree(void *pPrior){ hHeap = winMemGetHeap(); assert( hHeap!=0 ); assert( hHeap!=INVALID_HANDLE_VALUE ); -#ifdef !SQLITE_OS_WINRT && SQLITE_WIN32_MALLOC_VALIDATE +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE) assert ( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ); #endif if( !pPrior ) return; /* Passing NULL to HeapFree is undefined. */ @@ -1013,7 +1013,7 @@ static void *winMemRealloc(void *pPrior, int nBytes){ hHeap = winMemGetHeap(); assert( hHeap!=0 ); assert( hHeap!=INVALID_HANDLE_VALUE ); -#ifdef !SQLITE_OS_WINRT && SQLITE_WIN32_MALLOC_VALIDATE +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE) assert ( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ); #endif assert( nBytes>=0 ); @@ -1041,7 +1041,7 @@ static int winMemSize(void *p){ hHeap = winMemGetHeap(); assert( hHeap!=0 ); assert( hHeap!=INVALID_HANDLE_VALUE ); -#ifdef !SQLITE_OS_WINRT && SQLITE_WIN32_MALLOC_VALIDATE +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE) assert ( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) ); #endif if( !p ) return 0; @@ -1097,7 +1097,7 @@ static int winMemInit(void *pAppData){ #endif assert( pWinMemData->hHeap!=0 ); assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE ); -#ifdef !SQLITE_OS_WINRT && SQLITE_WIN32_MALLOC_VALIDATE +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE) assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) ); #endif return SQLITE_OK; @@ -1112,7 +1112,7 @@ static void winMemShutdown(void *pAppData){ if( !pWinMemData ) return; if( pWinMemData->hHeap ){ assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE ); -#ifdef !SQLITE_OS_WINRT && SQLITE_WIN32_MALLOC_VALIDATE +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE) assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) ); #endif if( pWinMemData->bOwned ){ From 16afb9ee966359ab608ea61499794400ba98e16b Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 14 Mar 2012 23:08:59 +0000 Subject: [PATCH 26/59] Fix macro issues for osGetProcessHeap and sqlite3_win32_write_debug. FossilOrigin-Name: d3d071598aba367e3d73001ab38d7a78306875ea --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 4314ec4ed7..73be5ae116 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypos,\suse\s#if\sinstead\sof\s#ifdef\swhen\schecking\sfor\sthe\sWin32\snative\sheap\svalidation\sdefine. -D 2012-03-14T20:20:37.765 +C Fix\smacro\sissues\sfor\sosGetProcessHeap\sand\ssqlite3_win32_write_debug. +D 2012-03-14T23:08:59.126 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c 817bce5df90080879263f0a7b0d6be194f5a152e +F src/os_win.c a2e9d48184b8b29075d7be2b5e990c4af48cf05a F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 46c412a8f6470c9e8c4bdeafaf4db435fbb694ab -R 39e5d64245595f7182fd72bc71b1f514 +P 845aa46f69784420ada4116078f8dc0a68cf3707 +R 19913ba6cd236428e778abd041ed11a4 U mistachkin -Z f46c995916aec3a9f0322bdbc2b14015 +Z 1c2030e83f925395c20a7055c12f2bff diff --git a/manifest.uuid b/manifest.uuid index 29889e626b..1a19b160bf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -845aa46f69784420ada4116078f8dc0a68cf3707 \ No newline at end of file +d3d071598aba367e3d73001ab38d7a78306875ea \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index b12ba27809..5d574fd438 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -98,7 +98,7 @@ struct winFile { * The size of the buffer used by sqlite3_win32_write_debug(). */ #ifndef SQLITE_WIN32_DBG_BUF_SIZE -# define SQLITE_WIN32_DBG_BUF_SIZE (4096-sizeof(DWORD)) +# define SQLITE_WIN32_DBG_BUF_SIZE ((int)(4096-sizeof(DWORD))) #endif /* @@ -788,7 +788,7 @@ static struct win_syscall { { "GetProcessHeap", (SYSCALL)GetProcessHeap, 0 }, -#define osGetProcessHeap() ((HANDLE(WINAPI*)(VOID))aSyscall[71].pCurrent) +#define osGetProcessHeap ((HANDLE(WINAPI*)(VOID))aSyscall[71].pCurrent) }; /* End of the overrideable system calls */ @@ -882,7 +882,7 @@ static const char *winNextSystemCall(sqlite3_vfs *p, const char *zName){ void sqlite3_win32_write_debug(char *zBuf, int nBuf){ char zDbgBuf[SQLITE_WIN32_DBG_BUF_SIZE]; - int nMin = MIN(nBuf,SQLITE_WIN32_DBG_BUF_SIZE-1); /* may be negative. */ + int nMin = MIN(nBuf, (SQLITE_WIN32_DBG_BUF_SIZE - 1)); /* may be negative. */ if( nMin<-1 ) nMin = -1; /* all negative values become -1. */ assert( nMin==-1 || nMin==0 || nMin Date: Thu, 15 Mar 2012 03:40:59 +0000 Subject: [PATCH 27/59] Add SQLITE_WIN32_HEAP_CREATE compiler define to control whether or not the Win32 native allocator will create an isolated heap for all allocated data. FossilOrigin-Name: 8693fb652ecd1ad0b03e9067839970b321c3f904 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 21 ++++++++++++++++++++- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 73be5ae116..ccb0bed86a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\smacro\sissues\sfor\sosGetProcessHeap\sand\ssqlite3_win32_write_debug. -D 2012-03-14T23:08:59.126 +C Add\sSQLITE_WIN32_HEAP_CREATE\scompiler\sdefine\sto\scontrol\swhether\sor\snot\sthe\sWin32\snative\sallocator\swill\screate\san\sisolated\sheap\sfor\sall\sallocated\sdata. +D 2012-03-15T03:40:59.450 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c a2e9d48184b8b29075d7be2b5e990c4af48cf05a +F src/os_win.c 9bbe851c4299fd53dae0652fcd199025b755e8a4 F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 845aa46f69784420ada4116078f8dc0a68cf3707 -R 19913ba6cd236428e778abd041ed11a4 +P d3d071598aba367e3d73001ab38d7a78306875ea +R 0bb904de4ab0ea378e0e14a8a8dc9e9c U mistachkin -Z 1c2030e83f925395c20a7055c12f2bff +Z a4be176b4e96926a736affae28592011 diff --git a/manifest.uuid b/manifest.uuid index 1a19b160bf..f8b2016426 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d3d071598aba367e3d73001ab38d7a78306875ea \ No newline at end of file +8693fb652ecd1ad0b03e9067839970b321c3f904 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 5d574fd438..21deea5599 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -106,6 +106,25 @@ struct winFile { * various Win32 API heap functions instead of our own. */ #ifdef SQLITE_WIN32_MALLOC + +/* + * If this is non-zero, an isolated heap will be created by the native Win32 + * allocator subsystem; otherwise, the default process heap will be used. This + * setting has no effect when compiling for WinRT. By default, this is enabled + * and an isolated heap will be created to store all allocated data. + * + ****************************************************************************** + * WARNING: It is important to note that when this setting is non-zero and the + * winMemShutdown function is called (e.g. by the sqlite3_shutdown + * function), all data that was allocated using the isolated heap will + * be freed immediately and any attempt to access any of that freed + * data will almost certainly result in an immediate access violation. + ****************************************************************************** + */ +#ifndef SQLITE_WIN32_HEAP_CREATE +# define SQLITE_WIN32_HEAP_CREATE (TRUE) +#endif + /* * The initial size of the Win32-specific heap. This value may be zero. */ @@ -1070,7 +1089,7 @@ static int winMemInit(void *pAppData){ if( !pWinMemData ) return SQLITE_ERROR; assert( pWinMemData->magic==WINMEM_MAGIC ); -#if !SQLITE_OS_WINRT +#if !SQLITE_OS_WINRT && SQLITE_WIN32_HEAP_CREATE if( !pWinMemData->hHeap ){ pWinMemData->hHeap = osHeapCreate(SQLITE_WIN32_HEAP_FLAGS, SQLITE_WIN32_HEAP_INIT_SIZE, From e4c46aaccda547a37032b58a30904fb8b0c37f97 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 16 Mar 2012 10:28:40 +0000 Subject: [PATCH 28/59] Reset the sqlite3_data_directory and sqlite3_temp_directory variables when the sqlite3_shutdown function is called since they may refer to memory allocated by the heap subsystem that was just shutdown. FossilOrigin-Name: cd70bc4b788b947d47a7a7158c27028160df06bd --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/main.c | 9 +++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index ccb0bed86a..08d8b253c7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sSQLITE_WIN32_HEAP_CREATE\scompiler\sdefine\sto\scontrol\swhether\sor\snot\sthe\sWin32\snative\sallocator\swill\screate\san\sisolated\sheap\sfor\sall\sallocated\sdata. -D 2012-03-15T03:40:59.450 +C Reset\sthe\ssqlite3_data_directory\sand\ssqlite3_temp_directory\svariables\swhen\sthe\ssqlite3_shutdown\sfunction\sis\scalled\ssince\sthey\smay\srefer\sto\smemory\sallocated\sby\sthe\sheap\ssubsystem\sthat\swas\sjust\sshutdown. +D 2012-03-16T10:28:40.323 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -147,7 +147,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416 F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d -F src/main.c 5808bc6e2d2a80c3d73c42622fa162dc3cc24893 +F src/main.c d5ee3f6b60ed3692ffaa2ecfd1f9ea75439320f9 F src/malloc.c 15afac5e59b6584efe072e9933aefb4230e74f97 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c b3677415e69603d6a0e7c5410a1b3731d55beda1 @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P d3d071598aba367e3d73001ab38d7a78306875ea -R 0bb904de4ab0ea378e0e14a8a8dc9e9c +P 8693fb652ecd1ad0b03e9067839970b321c3f904 +R 82dc6fe8495302f5fea0d7d19dfd1f47 U mistachkin -Z a4be176b4e96926a736affae28592011 +Z d2503b8281f3d675b1a2c9e9f5230508 diff --git a/manifest.uuid b/manifest.uuid index f8b2016426..06f5280483 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8693fb652ecd1ad0b03e9067839970b321c3f904 \ No newline at end of file +cd70bc4b788b947d47a7a7158c27028160df06bd \ No newline at end of file diff --git a/src/main.c b/src/main.c index 601138b8df..31e5fb870d 100644 --- a/src/main.c +++ b/src/main.c @@ -287,6 +287,15 @@ int sqlite3_shutdown(void){ sqlite3GlobalConfig.isMutexInit = 0; } + /* The heap subsystem has now been shutdown and these values are supposed + ** to be NULL or point to memory that was obtained from sqlite3_malloc(), + ** which would rely on that heap subsystem; therefore, make sure these + ** values cannot refer to heap memory that was just invalidated when the + ** heap subsystem was shutdown. + */ + sqlite3_data_directory = 0; + sqlite3_temp_directory = 0; + return SQLITE_OK; } From 86f89871b0705eef6ba5a5319ab04b537bc09b43 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sun, 18 Mar 2012 01:32:44 +0000 Subject: [PATCH 29/59] Add SQLITE_OMIT_SHUTDOWN_DIRECTORIES compile-time option to disable clearing the sqlite3_data_directory and sqlite3_temp_directory variables during sqlite3_shutdown. Also, only clear the variables if the heap was actually shutdown. FossilOrigin-Name: 1ae9f9e4f730eccbc0fc3408de1ac3c4be931e01 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/main.c | 21 ++++++++++++--------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 08d8b253c7..f939c80f9c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Reset\sthe\ssqlite3_data_directory\sand\ssqlite3_temp_directory\svariables\swhen\sthe\ssqlite3_shutdown\sfunction\sis\scalled\ssince\sthey\smay\srefer\sto\smemory\sallocated\sby\sthe\sheap\ssubsystem\sthat\swas\sjust\sshutdown. -D 2012-03-16T10:28:40.323 +C Add\sSQLITE_OMIT_SHUTDOWN_DIRECTORIES\scompile-time\soption\sto\sdisable\sclearing\sthe\ssqlite3_data_directory\sand\ssqlite3_temp_directory\svariables\sduring\ssqlite3_shutdown.\s\sAlso,\sonly\sclear\sthe\svariables\sif\sthe\sheap\swas\sactually\sshutdown. +D 2012-03-18T01:32:44.771 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -147,7 +147,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416 F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d -F src/main.c d5ee3f6b60ed3692ffaa2ecfd1f9ea75439320f9 +F src/main.c fbb345088f5719f1842056e0613ea3f9a889f4fa F src/malloc.c 15afac5e59b6584efe072e9933aefb4230e74f97 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c b3677415e69603d6a0e7c5410a1b3731d55beda1 @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 8693fb652ecd1ad0b03e9067839970b321c3f904 -R 82dc6fe8495302f5fea0d7d19dfd1f47 +P cd70bc4b788b947d47a7a7158c27028160df06bd +R d1f4973510f77bf75cb97abcded45ca7 U mistachkin -Z d2503b8281f3d675b1a2c9e9f5230508 +Z 1223d82df9680759dd17a896969e8fb1 diff --git a/manifest.uuid b/manifest.uuid index 06f5280483..e165bcff85 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cd70bc4b788b947d47a7a7158c27028160df06bd \ No newline at end of file +1ae9f9e4f730eccbc0fc3408de1ac3c4be931e01 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 31e5fb870d..a8f326be2a 100644 --- a/src/main.c +++ b/src/main.c @@ -281,21 +281,24 @@ int sqlite3_shutdown(void){ if( sqlite3GlobalConfig.isMallocInit ){ sqlite3MallocEnd(); sqlite3GlobalConfig.isMallocInit = 0; + +#ifndef SQLITE_OMIT_SHUTDOWN_DIRECTORIES + /* The heap subsystem has now been shutdown and these values are supposed + ** to be NULL or point to memory that was obtained from sqlite3_malloc(), + ** which would rely on that heap subsystem; therefore, make sure these + ** values cannot refer to heap memory that was just invalidated when the + ** heap subsystem was shutdown. This is only done if the current call to + ** this function resulted in the heap subsystem actually being shutdown. + */ + sqlite3_data_directory = 0; + sqlite3_temp_directory = 0; +#endif } if( sqlite3GlobalConfig.isMutexInit ){ sqlite3MutexEnd(); sqlite3GlobalConfig.isMutexInit = 0; } - /* The heap subsystem has now been shutdown and these values are supposed - ** to be NULL or point to memory that was obtained from sqlite3_malloc(), - ** which would rely on that heap subsystem; therefore, make sure these - ** values cannot refer to heap memory that was just invalidated when the - ** heap subsystem was shutdown. - */ - sqlite3_data_directory = 0; - sqlite3_temp_directory = 0; - return SQLITE_OK; } From 5593b2e653f9a15f6685b71715ebbbb6b7cd6a20 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sun, 18 Mar 2012 03:22:44 +0000 Subject: [PATCH 30/59] On Windows, when no temporary path is available, skip prepending the directory separator. FossilOrigin-Name: 32b5c20e54474fcc33ba937293e97566a555e733 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 12 ++++++++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index f939c80f9c..c266353f34 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sSQLITE_OMIT_SHUTDOWN_DIRECTORIES\scompile-time\soption\sto\sdisable\sclearing\sthe\ssqlite3_data_directory\sand\ssqlite3_temp_directory\svariables\sduring\ssqlite3_shutdown.\s\sAlso,\sonly\sclear\sthe\svariables\sif\sthe\sheap\swas\sactually\sshutdown. -D 2012-03-18T01:32:44.771 +C On\sWindows,\swhen\sno\stemporary\spath\sis\savailable,\sskip\sprepending\sthe\sdirectory\sseparator. +D 2012-03-18T03:22:44.499 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c 9bbe851c4299fd53dae0652fcd199025b755e8a4 +F src/os_win.c aeb0aee1264e3eea9afffb7c945c734315043b29 F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P cd70bc4b788b947d47a7a7158c27028160df06bd -R d1f4973510f77bf75cb97abcded45ca7 +P 1ae9f9e4f730eccbc0fc3408de1ac3c4be931e01 +R e11c61d544eb2a069b5456711a5abf81 U mistachkin -Z 1223d82df9680759dd17a896969e8fb1 +Z 9329238ea2411efabbbde93cdad877cd diff --git a/manifest.uuid b/manifest.uuid index e165bcff85..d004dba128 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1ae9f9e4f730eccbc0fc3408de1ac3c4be931e01 \ No newline at end of file +32b5c20e54474fcc33ba937293e97566a555e733 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 21deea5599..57f42b7af3 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -3307,6 +3307,7 @@ static int getTempname(int nBuf, char *zBuf){ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789"; size_t i, j; + int nTempPath; char zTempPath[MAX_PATH+2]; /* It's odd to simulate an io-error here, but really this is just @@ -3352,15 +3353,18 @@ static int getTempname(int nBuf, char *zBuf){ /* Check that the output buffer is large enough for the temporary file ** name. If it is not, return SQLITE_ERROR. */ - if( (sqlite3Strlen30(zTempPath) + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 18) >= nBuf ){ + nTempPath = sqlite3Strlen30(zTempPath); + + if( (nTempPath + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 18) >= nBuf ){ return SQLITE_ERROR; } - for(i=sqlite3Strlen30(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){} + for(i=nTempPath; i>0 && zTempPath[i-1]=='\\'; i--){} zTempPath[i] = 0; - sqlite3_snprintf(nBuf-18, zBuf, - "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath); + sqlite3_snprintf(nBuf-18, zBuf, (nTempPath > 0) ? + "%s\\"SQLITE_TEMP_FILE_PREFIX : SQLITE_TEMP_FILE_PREFIX, + zTempPath); j = sqlite3Strlen30(zBuf); sqlite3_randomness(15, &zBuf[j]); for(i=0; i<15; i++, j++){ From ca04d8a9f180a250220657cc5df2675ca8999f95 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 19 Mar 2012 23:28:35 +0000 Subject: [PATCH 31/59] Fix typo, use the syscall table for osOutputDebugStringA. FossilOrigin-Name: 9598c2a398a6e7d9c3ee8b2ae32c21538ad3e15a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index c266353f34..71eeeacff3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C On\sWindows,\swhen\sno\stemporary\spath\sis\savailable,\sskip\sprepending\sthe\sdirectory\sseparator. -D 2012-03-18T03:22:44.499 +C Fix\stypo,\suse\sthe\ssyscall\stable\sfor\sosOutputDebugStringA. +D 2012-03-19T23:28:35.056 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c aeb0aee1264e3eea9afffb7c945c734315043b29 +F src/os_win.c d96547173049f48b6727972fd34b9fd9613d28e5 F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 1ae9f9e4f730eccbc0fc3408de1ac3c4be931e01 -R e11c61d544eb2a069b5456711a5abf81 +P 32b5c20e54474fcc33ba937293e97566a555e733 +R d32fb1b5cd1fab5ff76f40d56d49b5b8 U mistachkin -Z 9329238ea2411efabbbde93cdad877cd +Z 80d32efbf3550d0f32e83e5f5c098d24 diff --git a/manifest.uuid b/manifest.uuid index d004dba128..6ada58a753 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -32b5c20e54474fcc33ba937293e97566a555e733 \ No newline at end of file +9598c2a398a6e7d9c3ee8b2ae32c21538ad3e15a \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 57f42b7af3..db2ec09c1f 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -908,9 +908,9 @@ void sqlite3_win32_write_debug(char *zBuf, int nBuf){ if( nMin>0 ){ memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE); memcpy(zDbgBuf, zBuf, nMin); - OutputDebugStringA(zDbgBuf); + osOutputDebugStringA(zDbgBuf); }else{ - OutputDebugStringA(zBuf); + osOutputDebugStringA(zBuf); } #elif defined(SQLITE_WIN32_HAS_WIDE) memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE); From 428bef2e07dd5f0355e5da398c429250a208c843 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 20 Mar 2012 02:10:22 +0000 Subject: [PATCH 32/59] Remove version information from the MSVC makefile as it is no longer necessary. FossilOrigin-Name: 6f0c1f9761be0402b82945517fdb3a36aeacbaeb --- Makefile.msc | 6 ------ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 2d8f44c733..e92f2d6610 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -32,12 +32,6 @@ SYMBOLS = 1 # DEBUG = 0 -# Version numbers and release number for the SQLite being compiled. -# -VERSION = 3.7 -VERSION_NUMBER = 3007009 -RELEASE = 3.7.9 - # C Compiler and options for use in building executables that # will run on the platform that is doing the build. # diff --git a/manifest b/manifest index 56cd515879..c10b043552 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Merge\supdates\sfrom\strunk. -D 2012-03-19T23:32:26.041 +C Remove\sversion\sinformation\sfrom\sthe\sMSVC\smakefile\sas\sit\sis\sno\slonger\snecessary. +D 2012-03-20T02:10:22.489 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 7849a871b6cdb20fd51baee6bbe5965a03326be4 +F Makefile.msc cf6c1ccb084eb8c395140bf4cb7685ee780c81ce F Makefile.vxworks 3b7fe7a0571fdadc61363ebc1b23732d2d6363ca F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION bb4c2a86abe53ea3c1d6ea515b69a426040e2414 @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 9598c2a398a6e7d9c3ee8b2ae32c21538ad3e15a 036395c0a8e08883b11df025e3da9e2461e4b1eb -R 4006015c648fef4fba98d6e258af08ad +P 4ab1ffd45d4c25368b9b393a3336068b747d8b22 +R 88d2fc3da22f2b36e021c04d194b99ab U mistachkin -Z 2aee651a229c029a1a978eb8aa068968 +Z d118e4ad7168d3a2bc00838d34ef8c36 diff --git a/manifest.uuid b/manifest.uuid index 3343b4c646..ab724150f9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4ab1ffd45d4c25368b9b393a3336068b747d8b22 \ No newline at end of file +6f0c1f9761be0402b82945517fdb3a36aeacbaeb \ No newline at end of file From f39eaf29d0bbf2ba5c846a86ea33b57dbf08e9d4 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 20 Mar 2012 02:18:42 +0000 Subject: [PATCH 33/59] Add WinRT comments to MSVC makefile. FossilOrigin-Name: ddea657bd8fe3762bd460524ac9223f0a5b09752 --- Makefile.msc | 9 ++++++++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index e92f2d6610..24bc0b2951 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -43,7 +43,14 @@ BCC = cl.exe # TCC = cl.exe -W3 -DSQLITE_OS_WIN=1 -I. -I$(TOP)\src -fp:precise -# The mksqlite3c.tcl and mksqlite3h.tcl scripts will pull in +# When compiling the library for use in the WinRT environment, +# the following compile-time option must be used as well to +# disable use of Win32 APIs that are not available and to enable +# use of Win32 APIs that are specific to Windows 8 and/or WinRT. +# +# TCC = $(TCC) -DSQLITE_OS_WINRT=1 + +# The mksqlite3c.tcl and mksqlite3h.tcl scripts will pull in # any extension header files by default. For non-amalgamation # builds, we need to make sure the compiler can find these. # diff --git a/manifest b/manifest index c10b043552..71ee21efaa 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Remove\sversion\sinformation\sfrom\sthe\sMSVC\smakefile\sas\sit\sis\sno\slonger\snecessary. -D 2012-03-20T02:10:22.489 +C Add\sWinRT\scomments\sto\sMSVC\smakefile. +D 2012-03-20T02:18:42.086 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc cf6c1ccb084eb8c395140bf4cb7685ee780c81ce +F Makefile.msc a42ae17632258af9ca0c94847e1c072644b38887 F Makefile.vxworks 3b7fe7a0571fdadc61363ebc1b23732d2d6363ca F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION bb4c2a86abe53ea3c1d6ea515b69a426040e2414 @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 4ab1ffd45d4c25368b9b393a3336068b747d8b22 -R 88d2fc3da22f2b36e021c04d194b99ab +P 6f0c1f9761be0402b82945517fdb3a36aeacbaeb +R 0313ae77c5dbe64845daebd70988142f U mistachkin -Z d118e4ad7168d3a2bc00838d34ef8c36 +Z cd021cef313ab330e262afa3df1b88ed diff --git a/manifest.uuid b/manifest.uuid index ab724150f9..e780766964 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6f0c1f9761be0402b82945517fdb3a36aeacbaeb \ No newline at end of file +ddea657bd8fe3762bd460524ac9223f0a5b09752 \ No newline at end of file From 46b721a29469d75bdacf07610b93261bf19940c7 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 23 Mar 2012 12:28:21 +0000 Subject: [PATCH 34/59] Update MSVC makefile to support compiling for WinRT using one setting. FossilOrigin-Name: c10794bfac0989c611ec3ea98d069cb9631a7b15 --- Makefile.msc | 14 ++++++++++++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 24bc0b2951..97a79d4261 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -15,6 +15,12 @@ USE_AMALGAMATION = 1 # USE_ICU = 0 +# Set this non-0 to compile binaries suitable for the WinRT environment. +# This setting does not apply to any binaries that require Tcl to operate +# properly (i.e. the text fixture, etc). +# +FOR_WINRT = 0 + # Set this to non-0 to create and use PDBs. # SYMBOLS = 1 @@ -44,11 +50,15 @@ BCC = cl.exe TCC = cl.exe -W3 -DSQLITE_OS_WIN=1 -I. -I$(TOP)\src -fp:precise # When compiling the library for use in the WinRT environment, -# the following compile-time option must be used as well to +# the following compile-time options must be used as well to # disable use of Win32 APIs that are not available and to enable # use of Win32 APIs that are specific to Windows 8 and/or WinRT. +# Also, we need to dynamically link to the MSVC runtime when +# compiling for WinRT. # -# TCC = $(TCC) -DSQLITE_OS_WINRT=1 +!IF $(FOR_WINRT)!=0 +TCC = $(TCC) -DSQLITE_OS_WINRT=1 -MD +!ENDIF # The mksqlite3c.tcl and mksqlite3h.tcl scripts will pull in # any extension header files by default. For non-amalgamation diff --git a/manifest b/manifest index 71ee21efaa..9e1571b430 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Add\sWinRT\scomments\sto\sMSVC\smakefile. -D 2012-03-20T02:18:42.086 +C Update\sMSVC\smakefile\sto\ssupport\scompiling\sfor\sWinRT\susing\sone\ssetting. +D 2012-03-23T12:28:21.645 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc a42ae17632258af9ca0c94847e1c072644b38887 +F Makefile.msc 47c5fd7e41e773835f78e2d8d32f67b0c8734113 F Makefile.vxworks 3b7fe7a0571fdadc61363ebc1b23732d2d6363ca F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION bb4c2a86abe53ea3c1d6ea515b69a426040e2414 @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 6f0c1f9761be0402b82945517fdb3a36aeacbaeb -R 0313ae77c5dbe64845daebd70988142f +P ddea657bd8fe3762bd460524ac9223f0a5b09752 +R 73aeb52e562bd72810737fc034c57c72 U mistachkin -Z cd021cef313ab330e262afa3df1b88ed +Z de85e312d806eace4ad69be21292db54 diff --git a/manifest.uuid b/manifest.uuid index e780766964..1b10195f13 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ddea657bd8fe3762bd460524ac9223f0a5b09752 \ No newline at end of file +c10794bfac0989c611ec3ea98d069cb9631a7b15 \ No newline at end of file From 05340e325757ceb06972b8c9e47fc307101902ea Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 30 Mar 2012 12:27:55 +0000 Subject: [PATCH 35/59] Simplify the winRead and winWrite VFS functions to reduce the number of system calls. FossilOrigin-Name: 10ce846759f6f22e70bb9b67bea7a0c2b8a156fe --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 33 ++++++++++++++++++++++++--------- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 9e1571b430..5d5fe7e761 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sMSVC\smakefile\sto\ssupport\scompiling\sfor\sWinRT\susing\sone\ssetting. -D 2012-03-23T12:28:21.645 +C Simplify\sthe\swinRead\sand\swinWrite\sVFS\sfunctions\sto\sreduce\sthe\snumber\sof\ssystem\scalls. +D 2012-03-30T12:27:55.620 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c d96547173049f48b6727972fd34b9fd9613d28e5 +F src/os_win.c 6f8080e783082d3d94ea56537f2248df4e273843 F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P ddea657bd8fe3762bd460524ac9223f0a5b09752 -R 73aeb52e562bd72810737fc034c57c72 +P c10794bfac0989c611ec3ea98d069cb9631a7b15 +R 23bdb0c42f14336dabd08b128245de8d U mistachkin -Z de85e312d806eace4ad69be21292db54 +Z 736498e20bf38fd876d04def8440845b diff --git a/manifest.uuid b/manifest.uuid index 1b10195f13..2a88abb768 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c10794bfac0989c611ec3ea98d069cb9631a7b15 \ No newline at end of file +10ce846759f6f22e70bb9b67bea7a0c2b8a156fe \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index db2ec09c1f..45fae46daa 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -1958,6 +1958,9 @@ static int winClose(sqlite3_file *id){ } #endif OSTRACE(("CLOSE %d %s\n", pFile->h, rc ? "ok" : "failed")); + if( rc ){ + pFile->h = NULL; + } OpenCounter(-1); return rc ? SQLITE_OK : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(), @@ -1975,6 +1978,7 @@ static int winRead( int amt, /* Number of bytes to read */ sqlite3_int64 offset /* Begin reading at this offset */ ){ + OVERLAPPED overlapped; /* The offset for ReadFile. */ winFile *pFile = (winFile*)id; /* file handle */ DWORD nRead; /* Number of bytes actually read from file */ int nRetry = 0; /* Number of retrys */ @@ -1983,10 +1987,11 @@ static int winRead( SimulateIOError(return SQLITE_IOERR_READ); OSTRACE(("READ %d lock=%d\n", pFile->h, pFile->locktype)); - if( seekWinFile(pFile, offset) ){ - return SQLITE_FULL; - } - while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){ + memset(&overlapped, 0, sizeof(OVERLAPPED)); + overlapped.Offset = (LONG)(offset & 0xffffffff); + overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff); + while( !osReadFile(pFile->h, pBuf, amt, &nRead, &overlapped) && + osGetLastError()!=ERROR_HANDLE_EOF ){ DWORD lastErrno; if( retryIoerr(&nRetry, &lastErrno) ) continue; pFile->lastErrno = lastErrno; @@ -2013,7 +2018,7 @@ static int winWrite( int amt, /* Number of bytes to write */ sqlite3_int64 offset /* Offset into the file to begin writing at */ ){ - int rc; /* True if error has occured, else false */ + int rc = 0; /* True if error has occured, else false */ winFile *pFile = (winFile*)id; /* File handle */ int nRetry = 0; /* Number of retries */ @@ -2024,19 +2029,29 @@ static int winWrite( OSTRACE(("WRITE %d lock=%d\n", pFile->h, pFile->locktype)); - rc = seekWinFile(pFile, offset); - if( rc==0 ){ + { + OVERLAPPED overlapped; /* The offset for WriteFile. */ u8 *aRem = (u8 *)pBuf; /* Data yet to be written */ int nRem = amt; /* Number of bytes yet to be written */ DWORD nWrite; /* Bytes written by each WriteFile() call */ DWORD lastErrno = NO_ERROR; /* Value returned by GetLastError() */ + memset(&overlapped, 0, sizeof(OVERLAPPED)); + overlapped.Offset = (LONG)(offset & 0xffffffff); + overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff); + while( nRem>0 ){ - if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, 0) ){ + if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, &overlapped) ){ if( retryIoerr(&nRetry, &lastErrno) ) continue; break; } - if( nWrite<=0 ) break; + if( nWrite<=0 ){ + lastErrno = osGetLastError(); + break; + } + offset += nWrite; + overlapped.Offset = (LONG)(offset & 0xffffffff); + overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff); aRem += nWrite; nRem -= nWrite; } From a6ff857437e621761348a2148418ca1b41308ecd Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 17 Apr 2012 21:00:12 +0000 Subject: [PATCH 36/59] When compiling for WinRT, always use the 'appcontainer' linker option. FossilOrigin-Name: 300bcfe31102d4428567d56810b57d1d54c1d43b --- Makefile.msc | 8 ++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 97a79d4261..a09bd955f5 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -234,6 +234,14 @@ LTLINKOPTS = /MACHINE:$(PLATFORM) LTLIBOPTS = /MACHINE:$(PLATFORM) !ENDIF +# When compiling for use in the WinRT environment, the following +# linker option must be used to mark the executable as runnable +# only in the context of an application container. +# +!IF $(FOR_WINRT)!=0 +LTLINKOPTS = $(LTLINKOPTS) /APPCONTAINER +!ENDIF + # If debugging is enabled, enable PDBs. !IF $(DEBUG)>0 || $(SYMBOLS)!=0 LTLINKOPTS = $(LTLINKOPTS) /DEBUG diff --git a/manifest b/manifest index aedf596003..9e04060a33 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Merge\sthe\slatest\strunk\schanges\sinto\sthe\swinrt\sbranch. -D 2012-03-30T14:01:40.977 +C When\scompiling\sfor\sWinRT,\salways\suse\sthe\s'appcontainer'\slinker\soption. +D 2012-04-17T21:00:12.605 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 47c5fd7e41e773835f78e2d8d32f67b0c8734113 +F Makefile.msc 71b1e756a0afe19fd6ef2b1e60bf2135118ed4d5 F Makefile.vxworks 3b7fe7a0571fdadc61363ebc1b23732d2d6363ca F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION f9313d88cb77df8617059a88eb382291321ef6bc @@ -999,7 +999,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 10ce846759f6f22e70bb9b67bea7a0c2b8a156fe 36aa6665e709b5942b3558afbd555058b42f2c78 -R cfe4287a455a52ef8be1acca1474bbf5 -U drh -Z 8c9488054f5fc194d8a0020e67475da7 +P a1a85b846aac07979e732a9f36d178bd567e103a +R 4b6ce0aef842e29a9d007bcf92b1249b +U mistachkin +Z ed5b0893d8bcb11e5301ff71a81a98a7 diff --git a/manifest.uuid b/manifest.uuid index 7666274340..13c7678f8f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a1a85b846aac07979e732a9f36d178bd567e103a \ No newline at end of file +300bcfe31102d4428567d56810b57d1d54c1d43b \ No newline at end of file From bba02a95d92582227b37a2a96162e5d76be24adc Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 15 May 2012 17:15:34 +0000 Subject: [PATCH 37/59] When a connection disconnects from a shared-cache database, only delete the in-memory schema if there are no other connections. FossilOrigin-Name: 46f4eb5430d7bc9a339cdf7124ff4bd518eaa39b --- manifest | 24 ++++++---- manifest.uuid | 2 +- src/main.c | 37 +++++++++++++-- src/sqliteInt.h | 1 + src/vtab.c | 25 ++++++++++ test/capi3.test | 9 +++- test/shared8.test | 113 ++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 193 insertions(+), 18 deletions(-) create mode 100644 test/shared8.test diff --git a/manifest b/manifest index 68138a320d..ea85d284ac 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sassert()s\sto\sverify\sthat\sTable\sobjects\sin\sthe\sschema\snever\suse\nlookaside\smemory. -D 2012-05-15T12:49:32.294 +C When\sa\sconnection\sdisconnects\sfrom\sa\sshared-cache\sdatabase,\sonly\sdelete\sthe\sin-memory\sschema\sif\sthere\sare\sno\sother\sconnections. +D 2012-05-15T17:15:34.812 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -140,7 +140,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416 F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d -F src/main.c 91458c713e9b7f8dbc98d79e78f1150f0ca9c2a1 +F src/main.c 62146c65069408bc66ad72954655c9cc14bd8f01 F src/malloc.c 15afac5e59b6584efe072e9933aefb4230e74f97 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c b3677415e69603d6a0e7c5410a1b3731d55beda1 @@ -177,7 +177,7 @@ F src/select.c d7b9018b7dd2e821183d69477ab55c39b8272335 F src/shell.c 04399b2f9942bd02ed5ffee3b84bcdb39c52a1e6 F src/sqlite.h.in 4f4d4792f6fb00387c877af013cb09d955643f12 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h c5e917c4f1453f3972b1fd0c81105dfe4f09cc32 +F src/sqliteInt.h cef468b8f16c847c235cb9a3d06253389abe3bc9 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 35939e7e03abf1b7577ce311f48f682c40de3208 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -243,7 +243,7 @@ F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 F src/vdbesort.c b25814d385895544ebc8118245c8311ded7f81c9 F src/vdbetrace.c d6e50e04e1ec498150e519058f617d91b8f5c843 -F src/vtab.c ae657b1c22cff43863458e768a44f915c07bc0e4 +F src/vtab.c 1fbe133809ae542a9cf3a3d8187774b68436fa85 F src/wal.c 7bb3ad807afc7973406c805d5157ec7a2f65e146 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f @@ -309,7 +309,7 @@ F test/boundary4.test 89e02fa66397b8a325d5eb102b5806f961f8ec4b F test/busy.test 76b4887f8b9160ba903c1ac22e8ff406ad6ae2f0 F test/cache.test f64136b0893c293d0b910ed057b3b711249099a7 F test/capi2.test 835d4cee9f542ea50fa8d01f3fe6de80b0627360 -F test/capi3.test 8dedb0050610e9ff95cd9d487beb0ce5f33a31ee +F test/capi3.test 8a33b82c4a2469977aed91b6eb99ae3ca1546444 F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4 F test/capi3c.test 01f197d73f4d4d66316483662f475cab7ab5bd60 F test/capi3d.test 17b57ca28be3e37e14c2ba8f787d292d84b724a1 @@ -688,6 +688,7 @@ F test/shared3.test ebf77f023f4bdaa8f74f65822b559e86ce5c6257 F test/shared4.test 72d90821e8d2fc918a08f16d32880868d8ee8e9d F test/shared6.test 866bb4982c45ce216c61ded5e8fde4e7e2f3ffa9 F test/shared7.test 960760bc8d03e1419e70dea69cf41db62853616e +F test/shared8.test b27befbefbe7f4517f1d6b7ff8f64a41ec74165d F test/shared_err.test 91e26ec4f3fbe07951967955585137e2f18993de F test/sharedlock.test ffa0a3c4ac192145b310f1254f8afca4d553eabf F test/shell1.test cd9f846702d1d471225a988fee590a153be8192c @@ -997,7 +998,10 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 0bb1cfc63f982db7b29c8e6be6698a6dad100f70 -R 040b7c6409bc9c8d46165baae8f02a6f -U drh -Z 46fb04131884f3e5ee0e8870b1bd5af5 +P 736d6ea677f58e4aa2914fa79a3156b775c5a3f5 +R cdb1dff646b0010ea62b89ecb700e74c +T *branch * shared-schema +T *sym-shared-schema * +T -sym-trunk * +U dan +Z 9910d0bfd0815b5cd0d4b52750333b7f diff --git a/manifest.uuid b/manifest.uuid index d1f1a9b991..917ae6d0b9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -736d6ea677f58e4aa2914fa79a3156b775c5a3f5 \ No newline at end of file +46f4eb5430d7bc9a339cdf7124ff4bd518eaa39b \ No newline at end of file diff --git a/src/main.c b/src/main.c index d148b4b42c..869fbb376b 100644 --- a/src/main.c +++ b/src/main.c @@ -720,6 +720,30 @@ static void functionDestroy(sqlite3 *db, FuncDef *p){ } } +/* +** Disconnect all sqlite3_vtab objects that belong to database connection +** db. This is called when db is being closed. +*/ +static void disconnectAllVtab(sqlite3 *db){ +#ifndef SQLITE_OMIT_VIRTUALTABLE + int i; + sqlite3BtreeEnterAll(db); + for(i=0; inDb; i++){ + Schema *pSchema = db->aDb[i].pSchema; + if( db->aDb[i].pSchema ){ + HashElem *p; + for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){ + Table *pTab = (Table *)sqliteHashData(p); + if( IsVirtual(pTab) ) sqlite3VtabDisconnect(db, pTab); + } + } + } + sqlite3BtreeLeaveAll(db); +#else + UNUSED_PARAMETER(db); +#endif +} + /* ** Close an existing SQLite database */ @@ -735,10 +759,10 @@ int sqlite3_close(sqlite3 *db){ } sqlite3_mutex_enter(db->mutex); - /* Force xDestroy calls on all virtual tables */ - sqlite3ResetInternalSchema(db, -1); + /* Force xDisconnect calls on all virtual tables */ + disconnectAllVtab(db); - /* If a transaction is open, the ResetInternalSchema() call above + /* If a transaction is open, the disconnectAllVtab() call above ** will not have called the xDisconnect() method on any virtual ** tables in the db->aVTrans[] array. The following sqlite3VtabRollback() ** call will do so. We need to do this before the check for active @@ -779,15 +803,18 @@ int sqlite3_close(sqlite3 *db){ } } } + + /* This call frees the schema associated with the temp database only (if + ** any). It also frees the db->aDb array, if required. */ sqlite3ResetInternalSchema(db, -1); + assert( db->nDb<=2 ); + assert( db->aDb==db->aDbStatic ); /* Tell the code in notify.c that the connection no longer holds any ** locks and does not require any further unlock-notify callbacks. */ sqlite3ConnectionClosed(db); - assert( db->nDb<=2 ); - assert( db->aDb==db->aDbStatic ); for(j=0; jaFunc.a); j++){ FuncDef *pNext, *pHash, *p; for(p=db->aFunc.a[j]; p; p=pHash){ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index cb178ff97c..cefff07ec5 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3101,6 +3101,7 @@ void sqlite3AutoLoadExtensions(sqlite3*); # define sqlite3GetVTable(X,Y) ((VTable*)0) #else void sqlite3VtabClear(sqlite3 *db, Table*); + void sqlite3VtabDisconnect(sqlite3 *db, Table *p); int sqlite3VtabSync(sqlite3 *db, char **); int sqlite3VtabRollback(sqlite3 *db); int sqlite3VtabCommit(sqlite3 *db); diff --git a/src/vtab.c b/src/vtab.c index c561f7198f..f660b54439 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -180,6 +180,31 @@ static VTable *vtabDisconnectAll(sqlite3 *db, Table *p){ return pRet; } +/* +** Table *p is a virtual table. This function removes the VTable object +** for table *p associated with database connection db from the linked +** list in p->pVTab. It also decrements the VTable ref count. This is +** used when closing database connection db to free all of its VTable +** objects without disturbing the rest of the Schema object (which may +** be being used by other shared-cache connections). +*/ +void sqlite3VtabDisconnect(sqlite3 *db, Table *p){ + VTable **ppVTab; + + assert( IsVirtual(p) ); + assert( sqlite3BtreeHoldsAllMutexes(db) ); + assert( sqlite3_mutex_held(db->mutex) ); + + for(ppVTab=&p->pVTable; *ppVTab; ppVTab=&(*ppVTab)->pNext){ + if( (*ppVTab)->db==db ){ + VTable *pVTab = *ppVTab; + *ppVTab = pVTab->pNext; + sqlite3VtabUnlock(pVTab); + break; + } + } +} + /* ** Disconnect all the virtual table objects in the sqlite3.pDisconnect list. diff --git a/test/capi3.test b/test/capi3.test index d9106267c5..b84ddbbf1a 100644 --- a/test/capi3.test +++ b/test/capi3.test @@ -649,13 +649,18 @@ do_test capi3-6.1 { db cache flush sqlite3_close $DB } {SQLITE_BUSY} + +# 6.2 and 6.3 used to return SQLITE_ERROR and SQLITE_SCHEMA, respectively. +# But since attempting to close a connection no longer resets the internal +# schema and expires all statements, this is no longer the case. do_test capi3-6.2 { sqlite3_step $STMT -} {SQLITE_ERROR} +} {SQLITE_ROW} #check_data $STMT capi3-6.3 {INTEGER} {1} {1.0} {1} do_test capi3-6.3 { sqlite3_finalize $STMT -} {SQLITE_SCHEMA} +} {SQLITE_OK} + do_test capi3-6.4-misuse { db cache flush sqlite3_close $DB diff --git a/test/shared8.test b/test/shared8.test new file mode 100644 index 0000000000..600e02bf7e --- /dev/null +++ b/test/shared8.test @@ -0,0 +1,113 @@ +# 2012 May 15 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# The tests in this file are intended to show that closing one database +# connection to a shared-cache while there exist other connections (a) +# does not cause the schema to be reloaded and (b) does not cause any +# other problems. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +ifcapable !shared_cache { finish_test ; return } +set testprefix shared8 + +db close +set ::enable_shared_cache [sqlite3_enable_shared_cache 1] +do_test 0.0 { sqlite3_enable_shared_cache } {1} + +proc roman {n} { + array set R {1 i 2 ii 3 iii 4 iv 5 v 6 vi 7 vii 8 viii 9 ix 10 x} + set R($n) +} + +#------------------------------------------------------------------------- +# The following tests work as follows: +# +# 1.0: Open connection [db1] and populate the database. +# +# 1.1: Using "PRAGMA writable_schema", destroy the database schema on +# disk. The schema is still in memory, so it is possible to keep +# using it, but any attempt to reload it from disk will fail. +# +# 1.3-4: Open connection db2. Check that it can see the db schema. Then +# close db1 and check that db2 still works. This shows that closing +# db1 did not reset the in-memory schema. +# +# 1.5-7: Similar to 1.3-4. +# +# 1.8: Close all database connections (deleting the in-memory schema). +# Then open a new connection and check that it cannot read the db. +# +do_test 1.0 { + sqlite3 db1 test.db + db1 func roman roman + execsql { + CREATE TABLE t1(a, b); + INSERT INTO t1 VALUES(1, 1); + INSERT INTO t1 VALUES(2, 2); + INSERT INTO t1 VALUES(3, 3); + INSERT INTO t1 VALUES(4, 4); + CREATE VIEW v1 AS SELECT a, roman(b) FROM t1; + SELECT * FROM v1; + } db1 +} {1 i 2 ii 3 iii 4 iv} + +do_test 1.1 { + execsql { + PRAGMA writable_schema = 1; + DELETE FROM sqlite_master WHERE 1; + PRAGMA writable_schema = 0; + SELECT * FROM sqlite_master; + } db1 +} {} + +do_test 1.2 { + execsql { SELECT * FROM v1 } db1 +} {1 i 2 ii 3 iii 4 iv} + +do_test 1.3 { + sqlite3 db2 test.db + db2 func roman roman + execsql { SELECT * FROM v1 } db2 +} {1 i 2 ii 3 iii 4 iv} + +do_test 1.4 { + db1 close + execsql { SELECT * FROM v1 } db2 +} {1 i 2 ii 3 iii 4 iv} + +do_test 1.5 { + sqlite3 db3 test.db + db3 func roman roman + execsql { SELECT * FROM v1 } db3 +} {1 i 2 ii 3 iii 4 iv} + +do_test 1.6 { + execsql { SELECT * FROM v1 } db2 +} {1 i 2 ii 3 iii 4 iv} + +do_test 1.7 { + db2 close + execsql { SELECT * FROM v1 } db3 +} {1 i 2 ii 3 iii 4 iv} + +do_test 1.8 { + db3 close + sqlite3 db4 test.db + catchsql { SELECT * FROM v1 } db4 +} {1 {no such table: v1}} + + +foreach db {db1 db2 db3 db4} { catch { $db close } } +sqlite3_enable_shared_cache $::enable_shared_cache +finish_test + From 81028a455de1b4e8782c3f233369515e83822bde Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 15 May 2012 18:28:27 +0000 Subject: [PATCH 38/59] The former sqlite3ResetInternalSchema() routine was really two different routines, selected by parameter, each with a confused mission. So split this routine up into three separate smaller routines, calling each separately as needed. Hopefully this will make further refactoring and schema reset collateral damage containment easier. FossilOrigin-Name: aa0c3493d3647d7efe527067e9fcccefda8e3008 --- manifest | 35 ++++++++--------- manifest.uuid | 2 +- src/attach.c | 4 +- src/backup.c | 2 +- src/build.c | 99 +++++++++++++++++++++++++------------------------ src/main.c | 4 +- src/pragma.c | 2 +- src/prepare.c | 8 ++-- src/sqliteInt.h | 4 +- src/vacuum.c | 2 +- src/vdbe.c | 8 ++-- src/vtab.c | 6 +-- 12 files changed, 88 insertions(+), 88 deletions(-) diff --git a/manifest b/manifest index ea85d284ac..2d4da7eb65 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sa\sconnection\sdisconnects\sfrom\sa\sshared-cache\sdatabase,\sonly\sdelete\sthe\sin-memory\sschema\sif\sthere\sare\sno\sother\sconnections. -D 2012-05-15T17:15:34.812 +C The\sformer\ssqlite3ResetInternalSchema()\sroutine\swas\sreally\stwo\sdifferent\s\nroutines,\sselected\sby\sparameter,\seach\swith\sa\sconfused\smission.\s\sSo\ssplit\nthis\sroutine\sup\sinto\sthree\sseparate\ssmaller\sroutines,\scalling\seach\nseparately\sas\sneeded.\s\sHopefully\sthis\swill\smake\sfurther\srefactoring\sand\nschema\sreset\scollateral\sdamage\scontainment\seasier. +D 2012-05-15T18:28:27.325 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -113,15 +113,15 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c 149cc80d9257971b0bff34e58fb2263e01998289 F src/analyze.c 70c46504c0d2543ea5cdca01140b2cd3e1d886e7 -F src/attach.c 12c6957996908edc31c96d7c68d4942c2474405f +F src/attach.c 577bf5675b0c50495fc28549f2fcbdb1bac71143 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 -F src/backup.c 6be23a344d3301ae38e92fddb3a33b91c309fce4 +F src/backup.c d7fb4c6d2ad3fe51a4ce1a897fde7b00f4de5fef F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c df800f10896bc2ddaa1125c532d6e7a7b9efc532 F src/btree.h 48a013f8964f12d944d90e4700df47b72dd6d923 F src/btreeInt.h 38a639c0542c29fe8331a221c4aed0cb8686249e -F src/build.c 95fd8aa1bf81acf15e9ef46b07d1f70111ea88d0 +F src/build.c 6da3a261958d79805df198808b35209e93acf52d F src/callback.c 0cb4228cdcd827dcc5def98fb099edcc9142dbcd F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c a9c26822515f81ec21588cbb482ca6724be02e33 @@ -140,7 +140,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416 F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d -F src/main.c 62146c65069408bc66ad72954655c9cc14bd8f01 +F src/main.c 28804c01149c1e707418434a42dc36438acdc5c8 F src/malloc.c 15afac5e59b6584efe072e9933aefb4230e74f97 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c b3677415e69603d6a0e7c5410a1b3731d55beda1 @@ -167,8 +167,8 @@ F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c F src/pcache1.c b30b1c35908346ecc43d8d9d17f2ddf6817f8f60 -F src/pragma.c e708b3bb5704605816f617e0b1d63a5488060715 -F src/prepare.c 9a00a9612ebf80203fbb41f8a29ab8cb27a05f40 +F src/pragma.c 28d7955a9e9a27d41cb462690228d39e3cec231c +F src/prepare.c ef197444dac110ee57a5f49745368b447a8c6bd1 F src/printf.c 7ffb4ebb8b341f67e049695ba031da717b3d2699 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 748e75299faff345f34f0e5bd02a2bac8aa69fcd @@ -177,7 +177,7 @@ F src/select.c d7b9018b7dd2e821183d69477ab55c39b8272335 F src/shell.c 04399b2f9942bd02ed5ffee3b84bcdb39c52a1e6 F src/sqlite.h.in 4f4d4792f6fb00387c877af013cb09d955643f12 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h cef468b8f16c847c235cb9a3d06253389abe3bc9 +F src/sqliteInt.h 05b22e581622128168d786a7c852d1763dd45559 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 35939e7e03abf1b7577ce311f48f682c40de3208 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -233,8 +233,8 @@ F src/trigger.c ee7e178fb9188f44b532cebd449a7c1df90fb684 F src/update.c d3076782c887c10e882996550345da9c4c9f9dea F src/utf.c 890c67dcfcc7a74623c95baac7535aadfe265e84 F src/util.c 4f6cfad661b2e3454b0cdd5b1b9d39a54942d0e3 -F src/vacuum.c bfd53f9bd20a8fdb70b0fa8e77182b866875c0d8 -F src/vdbe.c e1d26b98288889c22f00cf4851ec351ee67ad8b9 +F src/vacuum.c 587a52bb8833d7ac15af8916f25437e2575028bd +F src/vdbe.c 6ed3e89957a0dd55e9c4ab7842949051ba8eaaa9 F src/vdbe.h 18f581cac1f4339ec3299f3e0cc6e11aec654cdb F src/vdbeInt.h 6ff4180a05683566a8835d12f7ec504b22932c82 F src/vdbeapi.c 3662b6a468a2a4605a15dfab313baa6dff81ad91 @@ -243,7 +243,7 @@ F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 F src/vdbesort.c b25814d385895544ebc8118245c8311ded7f81c9 F src/vdbetrace.c d6e50e04e1ec498150e519058f617d91b8f5c843 -F src/vtab.c 1fbe133809ae542a9cf3a3d8187774b68436fa85 +F src/vtab.c 4c1d7e7206aa330da12cfbed29bbe08a5fd2c08e F src/wal.c 7bb3ad807afc7973406c805d5157ec7a2f65e146 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f @@ -998,10 +998,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 736d6ea677f58e4aa2914fa79a3156b775c5a3f5 -R cdb1dff646b0010ea62b89ecb700e74c -T *branch * shared-schema -T *sym-shared-schema * -T -sym-trunk * -U dan -Z 9910d0bfd0815b5cd0d4b52750333b7f +P 46f4eb5430d7bc9a339cdf7124ff4bd518eaa39b +R 3470c7e3b0ec734f279c648e5bd9b93d +U drh +Z 93dd6b08b78f998064cdd25b32f8367e diff --git a/manifest.uuid b/manifest.uuid index 917ae6d0b9..680e37e511 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -46f4eb5430d7bc9a339cdf7124ff4bd518eaa39b \ No newline at end of file +aa0c3493d3647d7efe527067e9fcccefda8e3008 \ No newline at end of file diff --git a/src/attach.c b/src/attach.c index 18f8823b31..e295c30111 100644 --- a/src/attach.c +++ b/src/attach.c @@ -216,7 +216,7 @@ static void attachFunc( db->aDb[iDb].pBt = 0; db->aDb[iDb].pSchema = 0; } - sqlite3ResetInternalSchema(db, -1); + sqlite3ResetAllSchemasOfConnection(db); db->nDb = iDb; if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){ db->mallocFailed = 1; @@ -288,7 +288,7 @@ static void detachFunc( sqlite3BtreeClose(pDb->pBt); pDb->pBt = 0; pDb->pSchema = 0; - sqlite3ResetInternalSchema(db, -1); + sqlite3ResetAllSchemasOfConnection(db); return; detach_error: diff --git a/src/backup.c b/src/backup.c index 7a4047f34c..0ada33c3be 100644 --- a/src/backup.c +++ b/src/backup.c @@ -414,7 +414,7 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){ rc = sqlite3BtreeUpdateMeta(p->pDest,1,p->iDestSchema+1); if( rc==SQLITE_OK ){ if( p->pDestDb ){ - sqlite3ResetInternalSchema(p->pDestDb, -1); + sqlite3ResetAllSchemasOfConnection(p->pDestDb); } if( destMode==PAGER_JOURNALMODE_WAL ){ rc = sqlite3BtreeSetVersion(p->pDest, 2); diff --git a/src/build.c b/src/build.c index e02f0402fc..3eefac9391 100644 --- a/src/build.c +++ b/src/build.c @@ -394,58 +394,15 @@ void sqlite3UnlinkAndDeleteIndex(sqlite3 *db, int iDb, const char *zIdxName){ } /* -** Erase all schema information from the in-memory hash tables of -** a single database. This routine is called to reclaim memory -** before the database closes. It is also called during a rollback -** if there were schema changes during the transaction or if a -** schema-cookie mismatch occurs. +** Look through the list of open database files in db->aDb[] and if +** any have been closed, remove them from the list. Reallocate the +** db->aDb[] structure to a smaller size, if possible. ** -** If iDb<0 then reset the internal schema tables for all database -** files. If iDb>=0 then reset the internal schema for only the -** single file indicated. +** Entry 0 (the "main" database) and entry 1 (the "temp" database) +** are never candidates for being collapsed. */ -void sqlite3ResetInternalSchema(sqlite3 *db, int iDb){ +void sqlite3CollapseDatabaseArray(sqlite3 *db){ int i, j; - assert( iDbnDb ); - - if( iDb>=0 ){ - /* Case 1: Reset the single schema identified by iDb */ - Db *pDb = &db->aDb[iDb]; - assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); - assert( pDb->pSchema!=0 ); - sqlite3SchemaClear(pDb->pSchema); - - /* If any database other than TEMP is reset, then also reset TEMP - ** since TEMP might be holding triggers that reference tables in the - ** other database. - */ - if( iDb!=1 ){ - pDb = &db->aDb[1]; - assert( pDb->pSchema!=0 ); - sqlite3SchemaClear(pDb->pSchema); - } - return; - } - /* Case 2 (from here to the end): Reset all schemas for all attached - ** databases. */ - assert( iDb<0 ); - sqlite3BtreeEnterAll(db); - for(i=0; inDb; i++){ - Db *pDb = &db->aDb[i]; - if( pDb->pSchema ){ - sqlite3SchemaClear(pDb->pSchema); - } - } - db->flags &= ~SQLITE_InternChanges; - sqlite3VtabUnlockList(db); - sqlite3BtreeLeaveAll(db); - - /* If one or more of the auxiliary database files has been closed, - ** then remove them from the auxiliary database list. We take the - ** opportunity to do this here since we have just deleted all of the - ** schema hash tables and therefore do not have to make any changes - ** to any of those tables. - */ for(i=j=2; inDb; i++){ struct Db *pDb = &db->aDb[i]; if( pDb->pBt==0 ){ @@ -467,6 +424,50 @@ void sqlite3ResetInternalSchema(sqlite3 *db, int iDb){ } } +/* +** Reset the schema for the database at index iDb. Also reset the +** TEMP schema. +*/ +void sqlite3ResetOneSchema(sqlite3 *db, int iDb){ + assert( iDbnDb ); + + /* Case 1: Reset the single schema identified by iDb */ + Db *pDb = &db->aDb[iDb]; + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); + assert( pDb->pSchema!=0 ); + sqlite3SchemaClear(pDb->pSchema); + + /* If any database other than TEMP is reset, then also reset TEMP + ** since TEMP might be holding triggers that reference tables in the + ** other database. + */ + if( iDb!=1 ){ + pDb = &db->aDb[1]; + assert( pDb->pSchema!=0 ); + sqlite3SchemaClear(pDb->pSchema); + } + return; +} + +/* +** Erase all schema information from all attached databases (including +** "main" and "temp") for a single database connection. +*/ +void sqlite3ResetAllSchemasOfConnection(sqlite3 *db){ + int i; + sqlite3BtreeEnterAll(db); + for(i=0; inDb; i++){ + Db *pDb = &db->aDb[i]; + if( pDb->pSchema ){ + sqlite3SchemaClear(pDb->pSchema); + } + } + db->flags &= ~SQLITE_InternChanges; + sqlite3VtabUnlockList(db); + sqlite3BtreeLeaveAll(db); + sqlite3CollapseDatabaseArray(db); +} + /* ** This routine is called when a commit occurs. */ diff --git a/src/main.c b/src/main.c index 869fbb376b..c0c7aa5f66 100644 --- a/src/main.c +++ b/src/main.c @@ -806,7 +806,7 @@ int sqlite3_close(sqlite3 *db){ /* This call frees the schema associated with the temp database only (if ** any). It also frees the db->aDb array, if required. */ - sqlite3ResetInternalSchema(db, -1); + sqlite3ResetAllSchemasOfConnection(db); assert( db->nDb<=2 ); assert( db->aDb==db->aDbStatic ); @@ -901,7 +901,7 @@ void sqlite3RollbackAll(sqlite3 *db, int tripCode){ if( db->flags&SQLITE_InternChanges ){ sqlite3ExpirePreparedStatements(db); - sqlite3ResetInternalSchema(db, -1); + sqlite3ResetAllSchemasOfConnection(db); } /* Any deferred constraint violations have now been resolved. */ diff --git a/src/pragma.c b/src/pragma.c index 2db0b61508..3401c73c1b 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -118,7 +118,7 @@ static int invalidateTempStorage(Parse *pParse){ } sqlite3BtreeClose(db->aDb[1].pBt); db->aDb[1].pBt = 0; - sqlite3ResetInternalSchema(db, -1); + sqlite3ResetAllSchemasOfConnection(db); } return SQLITE_OK; } diff --git a/src/prepare.c b/src/prepare.c index c46e55ed2c..f1dbb6b3b0 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -342,7 +342,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ } if( db->mallocFailed ){ rc = SQLITE_NOMEM; - sqlite3ResetInternalSchema(db, -1); + sqlite3ResetAllSchemasOfConnection(db); } if( rc==SQLITE_OK || (db->flags&SQLITE_RecoveryMode)){ /* Black magic: If the SQLITE_RecoveryMode flag is set, then consider @@ -395,7 +395,7 @@ int sqlite3Init(sqlite3 *db, char **pzErrMsg){ if( DbHasProperty(db, i, DB_SchemaLoaded) || i==1 ) continue; rc = sqlite3InitOne(db, i, pzErrMsg); if( rc ){ - sqlite3ResetInternalSchema(db, i); + sqlite3ResetOneSchema(db, i); } } @@ -408,7 +408,7 @@ int sqlite3Init(sqlite3 *db, char **pzErrMsg){ && !DbHasProperty(db, 1, DB_SchemaLoaded) ){ rc = sqlite3InitOne(db, 1, pzErrMsg); if( rc ){ - sqlite3ResetInternalSchema(db, 1); + sqlite3ResetOneSchema(db, 1); } } #endif @@ -476,7 +476,7 @@ static void schemaIsValid(Parse *pParse){ sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&cookie); assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); if( cookie!=db->aDb[iDb].pSchema->schema_cookie ){ - sqlite3ResetInternalSchema(db, iDb); + sqlite3ResetOneSchema(db, iDb); pParse->rc = SQLITE_SCHEMA; } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index cefff07ec5..8cd022d7a5 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2696,7 +2696,9 @@ void sqlite3ExprListDelete(sqlite3*, ExprList*); int sqlite3Init(sqlite3*, char**); int sqlite3InitCallback(void*, int, char**, char**); void sqlite3Pragma(Parse*,Token*,Token*,Token*,int); -void sqlite3ResetInternalSchema(sqlite3*, int); +void sqlite3ResetAllSchemasOfConnection(sqlite3*); +void sqlite3ResetOneSchema(sqlite3*,int); +void sqlite3CollapseDatabaseArray(sqlite3*); void sqlite3BeginParse(Parse*,int); void sqlite3CommitInternalChanges(sqlite3*); Table *sqlite3ResultSetOfSelect(Parse*,Select*); diff --git a/src/vacuum.c b/src/vacuum.c index c03b4500b3..401d41dfb7 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -339,7 +339,7 @@ end_of_vacuum: /* This both clears the schemas and reduces the size of the db->aDb[] ** array. */ - sqlite3ResetInternalSchema(db, -1); + sqlite3ResetAllSchemasOfConnection(db); return rc; } diff --git a/src/vdbe.c b/src/vdbe.c index fa5180c9a4..aa42a0f735 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2747,7 +2747,7 @@ case OP_Savepoint: { } if( p1==SAVEPOINT_ROLLBACK && (db->flags&SQLITE_InternChanges)!=0 ){ sqlite3ExpirePreparedStatements(db); - sqlite3ResetInternalSchema(db, -1); + sqlite3ResetAllSchemasOfConnection(db); db->flags = (db->flags | SQLITE_InternChanges); } } @@ -3051,7 +3051,7 @@ case OP_VerifyCookie: { ** a v-table method. */ if( db->aDb[pOp->p1].pSchema->schema_cookie!=iMeta ){ - sqlite3ResetInternalSchema(db, pOp->p1); + sqlite3ResetOneSchema(db, pOp->p1); } p->expired = 1; @@ -4864,7 +4864,7 @@ case OP_ParseSchema: { db->init.busy = 0; } } - if( rc ) sqlite3ResetInternalSchema(db, -1); + if( rc ) sqlite3ResetAllSchemasOfConnection(db); if( rc==SQLITE_NOMEM ){ goto no_mem; } @@ -6159,7 +6159,7 @@ vdbe_error_halt: if( rc==SQLITE_IOERR_NOMEM ) db->mallocFailed = 1; rc = SQLITE_ERROR; if( resetSchemaOnFault>0 ){ - sqlite3ResetInternalSchema(db, resetSchemaOnFault-1); + sqlite3ResetOneSchema(db, resetSchemaOnFault-1); } /* This is the only way out of this procedure. We have to diff --git a/src/vtab.c b/src/vtab.c index f660b54439..24eee1a81a 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -22,8 +22,8 @@ ** are invoked only from within xCreate and xConnect methods. */ struct VtabCtx { - Table *pTab; - VTable *pVTable; + VTable *pVTable; /* The virtual table being constructed */ + Table *pTab; /* The Table object to which the virtual table belongs */ }; /* @@ -54,7 +54,7 @@ static int createModule( pMod->xDestroy = xDestroy; pDel = (Module *)sqlite3HashInsert(&db->aModule, zCopy, nName, (void*)pMod); if( pDel && pDel->xDestroy ){ - sqlite3ResetInternalSchema(db, -1); + sqlite3ResetAllSchemasOfConnection(db); pDel->xDestroy(pDel->pAux); } sqlite3DbFree(db, pDel); From 5efb3145256ed3a87a4c25ad5899e136ff132eca Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 16 May 2012 01:24:34 +0000 Subject: [PATCH 39/59] Avoid using sqlite3ResetAllSchemasOfConnection() purely for its side-effects. FossilOrigin-Name: 5587c73badc07d3e01a7c5c5964e178b5112dd24 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/main.c | 11 ++++++++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 2d4da7eb65..7f50ea50c8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sformer\ssqlite3ResetInternalSchema()\sroutine\swas\sreally\stwo\sdifferent\s\nroutines,\sselected\sby\sparameter,\seach\swith\sa\sconfused\smission.\s\sSo\ssplit\nthis\sroutine\sup\sinto\sthree\sseparate\ssmaller\sroutines,\scalling\seach\nseparately\sas\sneeded.\s\sHopefully\sthis\swill\smake\sfurther\srefactoring\sand\nschema\sreset\scollateral\sdamage\scontainment\seasier. -D 2012-05-15T18:28:27.325 +C Avoid\susing\ssqlite3ResetAllSchemasOfConnection()\spurely\sfor\sits\sside-effects. +D 2012-05-16T01:24:34.201 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -140,7 +140,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416 F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d -F src/main.c 28804c01149c1e707418434a42dc36438acdc5c8 +F src/main.c 48f47554ccedb2e800aa8f5fb316835a584f709f F src/malloc.c 15afac5e59b6584efe072e9933aefb4230e74f97 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c b3677415e69603d6a0e7c5410a1b3731d55beda1 @@ -998,7 +998,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 46f4eb5430d7bc9a339cdf7124ff4bd518eaa39b -R 3470c7e3b0ec734f279c648e5bd9b93d +P aa0c3493d3647d7efe527067e9fcccefda8e3008 +R f77d3725cc1e7473c355856cafd6e6e6 U drh -Z 93dd6b08b78f998064cdd25b32f8367e +Z 8c590823c466df3da4ff72040b91d983 diff --git a/manifest.uuid b/manifest.uuid index 680e37e511..657abd7526 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -aa0c3493d3647d7efe527067e9fcccefda8e3008 \ No newline at end of file +5587c73badc07d3e01a7c5c5964e178b5112dd24 \ No newline at end of file diff --git a/src/main.c b/src/main.c index c0c7aa5f66..41adb0e932 100644 --- a/src/main.c +++ b/src/main.c @@ -793,6 +793,7 @@ int sqlite3_close(sqlite3 *db){ /* Free any outstanding Savepoint structures. */ sqlite3CloseSavepoints(db); + /* Close all database connections */ for(j=0; jnDb; j++){ struct Db *pDb = &db->aDb[j]; if( pDb->pBt ){ @@ -803,10 +804,14 @@ int sqlite3_close(sqlite3 *db){ } } } + /* Clear the TEMP schema separately and last */ + if( db->aDb[1].pSchema ){ + sqlite3SchemaClear(db->aDb[1].pSchema); + } + sqlite3VtabUnlockList(db); - /* This call frees the schema associated with the temp database only (if - ** any). It also frees the db->aDb array, if required. */ - sqlite3ResetAllSchemasOfConnection(db); + /* Free up the array of auxiliary databases */ + sqlite3CollapseDatabaseArray(db); assert( db->nDb<=2 ); assert( db->aDb==db->aDbStatic ); From ca8b9bac3b7d5fa457883936062fef2ee10a8ecb Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 16 May 2012 14:29:11 +0000 Subject: [PATCH 40/59] Return SQLITE_MISUSE if an application attempts to register a virtual table module with the same name as an existing module. FossilOrigin-Name: ea2cd55e098b21cd8997fd6c1978131d3ef2fab4 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/test8.c | 20 ++++++++++++++------ src/vtab.c | 46 ++++++++++++++++++++++++---------------------- test/vtab1.test | 14 ++++++++++++++ 5 files changed, 62 insertions(+), 38 deletions(-) diff --git a/manifest b/manifest index 7f50ea50c8..5ee9da6342 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\susing\ssqlite3ResetAllSchemasOfConnection()\spurely\sfor\sits\sside-effects. -D 2012-05-16T01:24:34.201 +C Return\sSQLITE_MISUSE\sif\san\sapplication\sattempts\sto\sregister\sa\svirtual\stable\smodule\swith\sthe\ssame\sname\sas\san\sexisting\smodule. +D 2012-05-16T14:29:11.421 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -189,7 +189,7 @@ F src/test4.c d1e5a5e904d4b444cf572391fdcb017638e36ff7 F src/test5.c a6d1ac55ac054d0b2b8f37b5e655b6c92645a013 F src/test6.c 417e1e214734393c24a8ee80b41485a9c4169123 F src/test7.c 2e0781754905c8adc3268d8f0967e7633af58843 -F src/test8.c 5ecbffe6712da81d5d10454e9d77d6c5bac95fe8 +F src/test8.c 235f1d19716fa768c46fc461ccbf529b2c9e4399 F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e @@ -243,7 +243,7 @@ F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 F src/vdbesort.c b25814d385895544ebc8118245c8311ded7f81c9 F src/vdbetrace.c d6e50e04e1ec498150e519058f617d91b8f5c843 -F src/vtab.c 4c1d7e7206aa330da12cfbed29bbe08a5fd2c08e +F src/vtab.c bb8ea3a26608bb1357538a5d2fc72beba6638998 F src/wal.c 7bb3ad807afc7973406c805d5157ec7a2f65e146 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f @@ -900,7 +900,7 @@ F test/vacuum4.test d3f8ecff345f166911568f397d2432c16d2867d9 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/veryquick.test 7701bb609fe8bf6535514e8b849a309e8f00573b F test/view.test b182a67ec43f490b156b5a710827a341be83dd17 -F test/vtab1.test e429a6835faa3870016c55d1178dcfead85f936a +F test/vtab1.test 331ca61ba0b5df4d2f2e55ee2b9596fde4228dbe F test/vtab2.test 7bcffc050da5c68f4f312e49e443063e2d391c0d F test/vtab3.test baad99fd27217f5d6db10660522e0b7192446de1 F test/vtab4.test 942f8b8280b3ea8a41dae20e7822d065ca1cb275 @@ -998,7 +998,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P aa0c3493d3647d7efe527067e9fcccefda8e3008 -R f77d3725cc1e7473c355856cafd6e6e6 -U drh -Z 8c590823c466df3da4ff72040b91d983 +P 5587c73badc07d3e01a7c5c5964e178b5112dd24 +R c4833805a7760d62c8726aeccbf50a1f +U dan +Z 29dbe9b5d386a5757fe1ec7bc83d13ea diff --git a/manifest.uuid b/manifest.uuid index 657abd7526..aad61d8e81 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5587c73badc07d3e01a7c5c5964e178b5112dd24 \ No newline at end of file +ea2cd55e098b21cd8997fd6c1978131d3ef2fab4 \ No newline at end of file diff --git a/src/test8.c b/src/test8.c index ba7e37372c..372eef664a 100644 --- a/src/test8.c +++ b/src/test8.c @@ -1300,6 +1300,7 @@ static sqlite3_module echoModuleV2 = { ** Decode a pointer to an sqlite3 object. */ extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb); +extern const char *sqlite3TestErrorName(int rc); static void moduleDestroy(void *p){ sqlite3_free(p); @@ -1314,6 +1315,7 @@ static int register_echo_module( int objc, /* Number of arguments */ Tcl_Obj *CONST objv[] /* Command arguments */ ){ + int rc; sqlite3 *db; EchoModule *pMod; if( objc!=2 ){ @@ -1325,14 +1327,20 @@ static int register_echo_module( /* Virtual table module "echo" */ pMod = sqlite3_malloc(sizeof(EchoModule)); pMod->interp = interp; - sqlite3_create_module_v2(db, "echo", &echoModule, (void*)pMod, moduleDestroy); + rc = sqlite3_create_module_v2( + db, "echo", &echoModule, (void*)pMod, moduleDestroy + ); /* Virtual table module "echo_v2" */ - pMod = sqlite3_malloc(sizeof(EchoModule)); - pMod->interp = interp; - sqlite3_create_module_v2(db, "echo_v2", - &echoModuleV2, (void*)pMod, moduleDestroy - ); + if( rc==SQLITE_OK ){ + pMod = sqlite3_malloc(sizeof(EchoModule)); + pMod->interp = interp; + rc = sqlite3_create_module_v2(db, "echo_v2", + &echoModuleV2, (void*)pMod, moduleDestroy + ); + } + + Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC); return TCL_OK; } diff --git a/src/vtab.c b/src/vtab.c index 24eee1a81a..0e082a05d9 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -38,33 +38,35 @@ static int createModule( void *pAux, /* Context pointer for xCreate/xConnect */ void (*xDestroy)(void *) /* Module destructor function */ ){ - int rc, nName; - Module *pMod; + int rc = SQLITE_OK; + int nName; sqlite3_mutex_enter(db->mutex); nName = sqlite3Strlen30(zName); - pMod = (Module *)sqlite3DbMallocRaw(db, sizeof(Module) + nName + 1); - if( pMod ){ - Module *pDel; - char *zCopy = (char *)(&pMod[1]); - memcpy(zCopy, zName, nName+1); - pMod->zName = zCopy; - pMod->pModule = pModule; - pMod->pAux = pAux; - pMod->xDestroy = xDestroy; - pDel = (Module *)sqlite3HashInsert(&db->aModule, zCopy, nName, (void*)pMod); - if( pDel && pDel->xDestroy ){ - sqlite3ResetAllSchemasOfConnection(db); - pDel->xDestroy(pDel->pAux); + if( sqlite3HashFind(&db->aModule, zName, nName) ){ + rc = SQLITE_MISUSE_BKPT; + }else{ + Module *pMod; + pMod = (Module *)sqlite3DbMallocRaw(db, sizeof(Module) + nName + 1); + if( pMod ){ + Module *pDel; + char *zCopy = (char *)(&pMod[1]); + memcpy(zCopy, zName, nName+1); + pMod->zName = zCopy; + pMod->pModule = pModule; + pMod->pAux = pAux; + pMod->xDestroy = xDestroy; + pDel = (Module *)sqlite3HashInsert(&db->aModule,zCopy,nName,(void*)pMod); + assert( pDel==0 || pDel==pMod ); + if( pDel ){ + db->mallocFailed = 1; + sqlite3DbFree(db, pDel); + } } - sqlite3DbFree(db, pDel); - if( pDel==pMod ){ - db->mallocFailed = 1; - } - }else if( xDestroy ){ - xDestroy(pAux); } - rc = sqlite3ApiExit(db, SQLITE_OK); + rc = sqlite3ApiExit(db, rc); + if( rc!=SQLITE_OK && xDestroy ) xDestroy(pAux); + sqlite3_mutex_leave(db->mutex); return rc; } diff --git a/test/vtab1.test b/test/vtab1.test index 38aec09eae..9fb843f754 100644 --- a/test/vtab1.test +++ b/test/vtab1.test @@ -1275,4 +1275,18 @@ foreach {tn sql res filter} { } do_execsql_test 18.2.x { PRAGMA case_sensitive_like = OFF } +#------------------------------------------------------------------------- +# Test that an existing module may not be overridden. +# +do_test 19.1 { + sqlite3 db2 test.db + register_echo_module [sqlite3_connection_pointer db2] +} SQLITE_OK +do_test 19.2 { + register_echo_module [sqlite3_connection_pointer db2] +} SQLITE_MISUSE +do_test 19.3 { + db2 close +} {} + finish_test From 86ab48fcfceeb6ee1db5c9d37180ab3bde402fa7 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 22 May 2012 19:25:51 +0000 Subject: [PATCH 41/59] Use the new test suite helper procedure 'get_pwd' to query the current directory from tests. FossilOrigin-Name: 1dd01e408161f5c1ab6b4fd449bee147d7e00744 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/shell1.test | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 84520301da..fb96fe17d4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sthe\s3.7.12.1\strunk\schanges\sinto\sthe\sWinRT\sbranch. -D 2012-05-22T17:39:00.851 +C Use\sthe\snew\stest\ssuite\shelper\sprocedure\s'get_pwd'\sto\squery\sthe\scurrent\sdirectory\sfrom\stests. +D 2012-05-22T19:25:51.250 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -691,7 +691,7 @@ F test/shared6.test 866bb4982c45ce216c61ded5e8fde4e7e2f3ffa9 F test/shared7.test 960760bc8d03e1419e70dea69cf41db62853616e F test/shared_err.test 91e26ec4f3fbe07951967955585137e2f18993de F test/sharedlock.test ffa0a3c4ac192145b310f1254f8afca4d553eabf -F test/shell1.test 6e3013bc50e2b73f00d17e491f776decc82a71c8 +F test/shell1.test 9895ee3013742a02e5afd8d77793729967ffd195 F test/shell2.test 037d6ad16e873354195d30bb2dc4b5321788154a F test/shell3.test 9196c42772d575685e722c92b4b39053c6ebba59 F test/shell4.test aa4eef8118b412d1a01477a53426ece169ea86a9 @@ -998,7 +998,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 224c65e4a5c6ede076c364c93933cedd17f1e70b 6d326d44fd1d626aae0e8456e5fa2049f1ce0789 -R 4f25f9545051a609810b52e6c59078d1 -U drh -Z b60ecf5beb2c5144541d29fa3c1ce0f9 +P b9ed0b26debd225a4530eb17d25b857e8e883a85 +R 862fc76bca700646e8a6c3acf8f2d307 +U mistachkin +Z fe4e5d83d2f708a7c0601e6c2f510bd5 diff --git a/manifest.uuid b/manifest.uuid index 5b151b6f2f..c164e060b8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b9ed0b26debd225a4530eb17d25b857e8e883a85 \ No newline at end of file +1dd01e408161f5c1ab6b4fd449bee147d7e00744 \ No newline at end of file diff --git a/test/shell1.test b/test/shell1.test index 0cafc35ae5..47f9e41d02 100644 --- a/test/shell1.test +++ b/test/shell1.test @@ -283,7 +283,7 @@ do_test shell1-3.2.4 { # .databases List names and files of attached databases do_test shell1-3.3.1 { catchcmd "-csv test.db" ".databases" -} "/0 +.*main +[string map {/ .} [string range [pwd] 0 10]].*/" +} "/0 +.*main +[string map {/ .} [string range [get_pwd] 0 10]].*/" do_test shell1-3.3.2 { # too many arguments catchcmd "test.db" ".databases BAD" From d3d8c04fd1c5e03f9e075d83a44a69d380884b2a Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 29 May 2012 17:02:40 +0000 Subject: [PATCH 42/59] Changes some NDEBUG macros to SQLITE_DEBUG in os_unix.c. The is a notational change only and really should not effect the code. FossilOrigin-Name: 8e3025709e4954803919c84f3a810c7c63c60601 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 97ff035bc2..29dc9ce942 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sRTree\smodule,\smake\ssure\sall\sdouble-to-float\sconversions\sround\sin\sa\ndirection\sto\sincrease\sthe\ssize\sof\selement\sbounding\sboxes. -D 2012-05-29T00:39:50.223 +C Changes\ssome\sNDEBUG\smacros\sto\sSQLITE_DEBUG\sin\sos_unix.c.\s\sThe\sis\sa\snotational\nchange\sonly\sand\sreally\sshould\snot\seffect\sthe\scode. +D 2012-05-29T17:02:40.005 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -164,7 +164,7 @@ F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c F src/os.h 59beba555b65a450bd1d804220532971d4299f60 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 -F src/os_unix.c 424d46e0edab969293c2223f09923b2178171f47 +F src/os_unix.c 8a90a7cdfc19ed0f233d76b63825d8effcae302a F src/os_win.c 412d6434133c7c81dc48b7702f3ea5e61c309e5c F src/pager.c 9d4d6406512002d9a243ec27b9c01e93fda43e36 F src/pager.h 8b8c9bc065a3c66769df8724dfdf492ee1aab3c5 @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 480158143be1256cbe4dba52ef1a5b96e172b38c f607ad27c1ede27af24dbee10ca867c8f7761ee3 -R 38bedd0c37f624ccf215394e11ad9336 +P 0abdc2903d8b3f86cad426e1bac2a959d1b1f7dd +R 99e554d1747c9743d7f383f83e1b186d U drh -Z 4bf39e44bbbf20a271c4dc152544fd6f +Z 66446fe8bdcb030202f3dea3dae3cedf diff --git a/manifest.uuid b/manifest.uuid index 942005486b..0b0410c98f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0abdc2903d8b3f86cad426e1bac2a959d1b1f7dd \ No newline at end of file +8e3025709e4954803919c84f3a810c7c63c60601 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index c85e9b53af..f1d3a08a06 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -227,7 +227,7 @@ struct unixFile { #if OS_VXWORKS struct vxworksFileId *pId; /* Unique file ID */ #endif -#ifndef NDEBUG +#ifdef SQLITE_DEBUG /* The next group of variables are used to track whether or not the ** transaction counter in bytes 24-27 of database files are updated ** whenever any part of the database changes. An assertion fault will @@ -1563,7 +1563,7 @@ static int unixLock(sqlite3_file *id, int eFileLock){ } -#ifndef NDEBUG +#ifdef SQLITE_DEBUG /* Set up the transaction-counter change checking flags when ** transitioning from a SHARED to a RESERVED lock. The change ** from SHARED to RESERVED marks the beginning of a normal @@ -1642,7 +1642,7 @@ static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){ if( pFile->eFileLock>SHARED_LOCK ){ assert( pInode->eFileLock==pFile->eFileLock ); -#ifndef NDEBUG +#ifdef SQLITE_DEBUG /* When reducing a lock such that other processes can start ** reading the database file again, make sure that the ** transaction counter was updated if any part of the database @@ -2841,7 +2841,7 @@ static int afpUnlock(sqlite3_file *id, int eFileLock) { SimulateIOError( h=(-1) ) SimulateIOErrorBenign(0); -#ifndef NDEBUG +#ifdef SQLITE_DEBUG /* When reducing a lock such that other processes can start ** reading the database file again, make sure that the ** transaction counter was updated if any part of the database @@ -3145,7 +3145,7 @@ static int unixWrite( ); #endif -#ifndef NDEBUG +#ifdef SQLITE_DEBUG /* If we are doing a normal write to a database file (as opposed to ** doing a hot-journal rollback or a write to some file other than a ** normal database file) then record the fact that the database @@ -3436,7 +3436,7 @@ static int unixTruncate(sqlite3_file *id, i64 nByte){ pFile->lastErrno = errno; return unixLogError(SQLITE_IOERR_TRUNCATE, "ftruncate", pFile->zPath); }else{ -#ifndef NDEBUG +#ifdef SQLITE_DEBUG /* If we are doing a normal write to a database file (as opposed to ** doing a hot-journal rollback or a write to some file other than a ** normal database file) and we truncate the file to zero length, @@ -3593,7 +3593,7 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ *(char**)pArg = sqlite3_mprintf("%s", pFile->pVfs->zName); return SQLITE_OK; } -#ifndef NDEBUG +#ifdef SQLITE_DEBUG /* The pager calls this method to signal that it has done ** a rollback and that the database is therefore unchanged and ** it hence it is OK for the transaction change counter to be From 666a1d8d1eb2dbb4d15be139f16a886b5e199bf1 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 29 May 2012 17:59:11 +0000 Subject: [PATCH 43/59] Fix a typo (a repeated "or") in the documentation. No changes to code. FossilOrigin-Name: 6fec6cf1fbac881a33a35ea99aac2f5f1cf27c2a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 29dc9ce942..338ce89b77 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Changes\ssome\sNDEBUG\smacros\sto\sSQLITE_DEBUG\sin\sos_unix.c.\s\sThe\sis\sa\snotational\nchange\sonly\sand\sreally\sshould\snot\seffect\sthe\scode. -D 2012-05-29T17:02:40.005 +C Fix\sa\stypo\s(a\srepeated\s"or")\sin\sthe\sdocumentation.\s\sNo\schanges\sto\scode. +D 2012-05-29T17:59:11.464 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -180,7 +180,7 @@ F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1 F src/select.c f6c4833c4d8e94714761d99013d74f381e084f1d F src/shell.c c16f72e34f611f060546709564c121a67cb2b31b -F src/sqlite.h.in 031d506fc8db023b64f15a4d7369ea0c5f51ee1e +F src/sqlite.h.in 922d2907cc2b0177b2c4a3b462f04937750d6edd F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqliteInt.h 97ccae71ae0a4e924dcb9fab14eb4fc4839790da F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 0abdc2903d8b3f86cad426e1bac2a959d1b1f7dd -R 99e554d1747c9743d7f383f83e1b186d +P 8e3025709e4954803919c84f3a810c7c63c60601 +R e031c8ae243dc6a28631e4783394147f U drh -Z 66446fe8bdcb030202f3dea3dae3cedf +Z 995b9ed856717b20346127daae7e1bdf diff --git a/manifest.uuid b/manifest.uuid index 0b0410c98f..5a18f613a6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8e3025709e4954803919c84f3a810c7c63c60601 \ No newline at end of file +6fec6cf1fbac881a33a35ea99aac2f5f1cf27c2a \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 85534870ae..e96c196802 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2581,7 +2581,7 @@ void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); ** access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had ** been set. ^Value "rwc" is equivalent to setting both ** SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE. ^If the mode option is -** set to "memory" then a pure [in-memory database] that never reads or +** set to "memory" then a pure [in-memory database] that never reads ** or writes from disk is used. ^It is an error to specify a value for ** the mode parameter that is less restrictive than that specified by ** the flags passed in the third parameter to sqlite3_open_v2(). From 1b28b89319c8c0831ed84296cf0c6937f881eee8 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 29 May 2012 19:25:20 +0000 Subject: [PATCH 44/59] Link the NDEBUG macro to SQLITE_DEBUG so that when SQLITE_DEBUG is defined, NDEBUG is automatically undefined an dwhen SQLITE_DEBUG is undefined NDEBUG is automatically defined. FossilOrigin-Name: 07935d10d341fe6265cfd3b09e2c4ef4005c4826 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqliteInt.h | 15 +++++++++++---- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 338ce89b77..277d58e302 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stypo\s(a\srepeated\s"or")\sin\sthe\sdocumentation.\s\sNo\schanges\sto\scode. -D 2012-05-29T17:59:11.464 +C Link\sthe\sNDEBUG\smacro\sto\sSQLITE_DEBUG\sso\sthat\swhen\sSQLITE_DEBUG\sis\sdefined,\nNDEBUG\sis\sautomatically\sundefined\san\sdwhen\sSQLITE_DEBUG\sis\sundefined\nNDEBUG\sis\sautomatically\sdefined. +D 2012-05-29T19:25:20.175 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -182,7 +182,7 @@ F src/select.c f6c4833c4d8e94714761d99013d74f381e084f1d F src/shell.c c16f72e34f611f060546709564c121a67cb2b31b F src/sqlite.h.in 922d2907cc2b0177b2c4a3b462f04937750d6edd F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h 97ccae71ae0a4e924dcb9fab14eb4fc4839790da +F src/sqliteInt.h 64cffc7ff43725ade0cdfdbab0ef6a56ef3b682f F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 35939e7e03abf1b7577ce311f48f682c40de3208 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 8e3025709e4954803919c84f3a810c7c63c60601 -R e031c8ae243dc6a28631e4783394147f +P 6fec6cf1fbac881a33a35ea99aac2f5f1cf27c2a +R 04c27600577da03816e15c318dd7df31 U drh -Z 995b9ed856717b20346127daae7e1bdf +Z 9df1e8f50925fc882f32cc14d2630547 diff --git a/manifest.uuid b/manifest.uuid index 5a18f613a6..5097ca4c3a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6fec6cf1fbac881a33a35ea99aac2f5f1cf27c2a \ No newline at end of file +07935d10d341fe6265cfd3b09e2c4ef4005c4826 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 953850eee4..85dabb0b39 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -203,15 +203,22 @@ #endif /* -** Many people are failing to set -DNDEBUG=1 when compiling SQLite. -** Setting NDEBUG makes the code smaller and run faster. So the following -** lines are added to automatically set NDEBUG unless the -DSQLITE_DEBUG=1 -** option is set. Thus NDEBUG becomes an opt-in rather than an opt-out +** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that +** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true, +** make it true by defining or undefining NDEBUG. +** +** Setting NDEBUG makes the code smaller and run faster by disabling the +** number assert() statements in the code. So we want the default action +** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG +** is set. Thus NDEBUG becomes an opt-in rather than an opt-out ** feature. */ #if !defined(NDEBUG) && !defined(SQLITE_DEBUG) # define NDEBUG 1 #endif +#if defined(NDEBUG) && defined(SQLITE_DEBUG) +# undef NDEBUG +#endif /* ** The testcase() macro is used to aid in coverage testing. When From ed4668271909964bfa81cc968ccbea5be7f4c15e Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 31 May 2012 13:10:49 +0000 Subject: [PATCH 45/59] Avoid calling fchown() if the process is not running as root. FossilOrigin-Name: 70c419a434be77b042a23174483d6a411899eb5d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 28 ++++++++++++++-------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 277d58e302..b001b92c56 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Link\sthe\sNDEBUG\smacro\sto\sSQLITE_DEBUG\sso\sthat\swhen\sSQLITE_DEBUG\sis\sdefined,\nNDEBUG\sis\sautomatically\sundefined\san\sdwhen\sSQLITE_DEBUG\sis\sundefined\nNDEBUG\sis\sautomatically\sdefined. -D 2012-05-29T19:25:20.175 +C Avoid\scalling\sfchown()\sif\sthe\sprocess\sis\snot\srunning\sas\sroot. +D 2012-05-31T13:10:49.376 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -164,7 +164,7 @@ F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c F src/os.h 59beba555b65a450bd1d804220532971d4299f60 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 -F src/os_unix.c 8a90a7cdfc19ed0f233d76b63825d8effcae302a +F src/os_unix.c d7c96b5d140f550f07345870112fae5d7ef99757 F src/os_win.c 412d6434133c7c81dc48b7702f3ea5e61c309e5c F src/pager.c 9d4d6406512002d9a243ec27b9c01e93fda43e36 F src/pager.h 8b8c9bc065a3c66769df8724dfdf492ee1aab3c5 @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 6fec6cf1fbac881a33a35ea99aac2f5f1cf27c2a -R 04c27600577da03816e15c318dd7df31 +P 07935d10d341fe6265cfd3b09e2c4ef4005c4826 +R db0f48be730e02610af744a3fe432e51 U drh -Z 9df1e8f50925fc882f32cc14d2630547 +Z a3e118b76a7afa02078e1c319e3927b5 diff --git a/manifest.uuid b/manifest.uuid index 5097ca4c3a..b74e97b330 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -07935d10d341fe6265cfd3b09e2c4ef4005c4826 \ No newline at end of file +70c419a434be77b042a23174483d6a411899eb5d \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index f1d3a08a06..0f11613b0a 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -262,7 +262,6 @@ 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_CHOWN 0x100 /* File ownership was changed */ /* ** Include code that is common to all os_*.c files @@ -308,6 +307,15 @@ static int posixOpen(const char *zFile, int flags, int mode){ return open(zFile, flags, mode); } +/* +** On some systems, calls to fchown() will trigger a message in a security +** log if they come from non-root processes. So avoid calling fchown() if +** we are not running as root. +*/ +static int posixFchown(int fd, uid_t uid, gid_t gid){ + return geteuid() ? 0 : fchown(fd,uid,gid); +} + /* Forward reference */ static int openDirectory(const char*, int*); @@ -419,7 +427,7 @@ static struct unix_syscall { { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 }, #define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent) - { "fchown", (sqlite3_syscall_ptr)fchown, 0 }, + { "fchown", (sqlite3_syscall_ptr)posixFchown, 0 }, #define osFchown ((int(*)(int,uid_t,gid_t))aSyscall[20].pCurrent) { "umask", (sqlite3_syscall_ptr)umask, 0 }, @@ -3944,14 +3952,9 @@ static int unixOpenSharedMemory(unixFile *pDbFd){ /* If this process is running as root, make sure that the SHM file ** is owned by the same user that owns the original database. Otherwise, - ** the original owner will not be able to connect. If this process is - ** not root, the following fchown() will fail, but we don't care. The - ** if(){..} and the UNIXFILE_CHOWN flag are purely to silence compiler - ** warnings. + ** the original owner will not be able to connect. */ - if( osFchown(pShmNode->h, sStat.st_uid, sStat.st_gid)==0 ){ - pDbFd->ctrlFlags |= UNIXFILE_CHOWN; - } + osFchown(pShmNode->h, sStat.st_uid, sStat.st_gid); /* Check to see if another process is holding the dead-man switch. ** If not, truncate the file to zero length. @@ -5157,13 +5160,10 @@ static int unixOpen( /* If this process is running as root and if creating a new rollback ** journal or WAL file, set the ownership of the journal or WAL to be - ** the same as the original database. If we are not running as root, - ** then the fchown() call will fail, but that's ok. The "if(){}" and - ** the setting of the UNIXFILE_CHOWN flag are purely to silence compiler - ** warnings from gcc. + ** the same as the original database. */ if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){ - if( osFchown(fd, uid, gid)==0 ){ p->ctrlFlags |= UNIXFILE_CHOWN; } + osFchown(fd, uid, gid); } } assert( fd>=0 ); From 1e6eea950225684434c65675a16ce901d0f37ae8 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 31 May 2012 22:12:26 +0000 Subject: [PATCH 46/59] Update several APIs to enable compilation with newer revisions of WinRT. FossilOrigin-Name: 54de739f056749b53b198f6b074d9e649520cf00 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 37 ++++++++++++++++++++++++++----------- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index fb96fe17d4..ef63fa7d06 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sthe\snew\stest\ssuite\shelper\sprocedure\s'get_pwd'\sto\squery\sthe\scurrent\sdirectory\sfrom\stests. -D 2012-05-22T19:25:51.250 +C Update\sseveral\sAPIs\sto\senable\scompilation\swith\snewer\srevisions\sof\sWinRT. +D 2012-05-31T22:12:26.763 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -160,7 +160,7 @@ F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 424d46e0edab969293c2223f09923b2178171f47 -F src/os_win.c 37e1b92f0fa5edf1955bcd6b04d3e4d8be68ede2 +F src/os_win.c ce6b415a2efd30027d4881bc8266c90ed4bc3ad0 F src/pager.c bb5635dde0b152797836d1c72275284724bb563c F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099 @@ -998,7 +998,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P b9ed0b26debd225a4530eb17d25b857e8e883a85 -R 862fc76bca700646e8a6c3acf8f2d307 +P 1dd01e408161f5c1ab6b4fd449bee147d7e00744 +R e2e31613ef8f782c24f244b69c156ce3 U mistachkin -Z fe4e5d83d2f708a7c0601e6c2f510bd5 +Z 408bf47646a7d2177c7080bd3b9695d2 diff --git a/manifest.uuid b/manifest.uuid index c164e060b8..a21151147e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1dd01e408161f5c1ab6b4fd449bee147d7e00744 \ No newline at end of file +54de739f056749b53b198f6b074d9e649520cf00 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 4652304c4f..376e240c75 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -288,7 +288,7 @@ static struct win_syscall { #define osCreateFileW ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD, \ LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[5].pCurrent) -#if defined(SQLITE_WIN32_HAS_WIDE) +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) { "CreateFileMappingW", (SYSCALL)CreateFileMappingW, 0 }, #else { "CreateFileMappingW", (SYSCALL)0, 0 }, @@ -684,7 +684,7 @@ static struct win_syscall { #define osWriteFile ((BOOL(WINAPI*)(HANDLE,LPCVOID,DWORD,LPDWORD, \ LPOVERLAPPED))aSyscall[58].pCurrent) -#if SQLITE_OS_WINRT +#if !SQLITE_OS_WINCE { "CreateEventExW", (SYSCALL)CreateEventExW, 0 }, #else { "CreateEventExW", (SYSCALL)0, 0 }, @@ -720,7 +720,7 @@ static struct win_syscall { #define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \ PLARGE_INTEGER,DWORD))aSyscall[62].pCurrent) -#if SQLITE_OS_WINRT +#if !SQLITE_OS_WINCE { "GetFileInformationByHandleEx", (SYSCALL)GetFileInformationByHandleEx, 0 }, #else { "GetFileInformationByHandleEx", (SYSCALL)0, 0 }, @@ -729,14 +729,14 @@ static struct win_syscall { #define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \ FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[63].pCurrent) -#if !SQLITE_OS_WINCE - { "MapViewOfFileEx", (SYSCALL)MapViewOfFileEx, 0 }, +#if SQLITE_OS_WINRT + { "MapViewOfFileFromApp", (SYSCALL)MapViewOfFileFromApp, 0 }, #else - { "MapViewOfFileEx", (SYSCALL)0, 0 }, + { "MapViewOfFileFromApp", (SYSCALL)0, 0 }, #endif -#define osMapViewOfFileEx ((LPVOID(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,SIZE_T, \ - LPVOID))aSyscall[64].pCurrent) +#define osMapViewOfFileFromApp ((LPVOID(WINAPI*)(HANDLE,ULONG,ULONG64, \ + SIZE_T))aSyscall[64].pCurrent) #if SQLITE_OS_WINRT { "CreateFile2", (SYSCALL)CreateFile2, 0 }, @@ -793,6 +793,15 @@ static struct win_syscall { #define osGetProcessHeap ((HANDLE(WINAPI*)(VOID))aSyscall[71].pCurrent) +#if SQLITE_OS_WINRT + { "CreateFileMappingFromApp", (SYSCALL)CreateFileMappingFromApp, 0 }, +#else + { "CreateFileMappingFromApp", (SYSCALL)0, 0 }, +#endif + +#define osCreateFileMappingFromApp ((HANDLE(WINAPI*)(HANDLE, \ + LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[72].pCurrent) + }; /* End of the overrideable system calls */ /* @@ -3211,9 +3220,15 @@ static int winShmMap( HANDLE hMap; /* file-mapping handle */ void *pMap = 0; /* Mapped memory region */ +#if SQLITE_OS_WINRT + hMap = osCreateFileMappingFromApp(pShmNode->hFile.h, + NULL, PAGE_READWRITE, nByte, NULL + ); +#else hMap = osCreateFileMappingW(pShmNode->hFile.h, NULL, PAGE_READWRITE, 0, nByte, NULL ); +#endif OSTRACE(("SHM-MAP pid-%d create region=%d nbyte=%d %s\n", (int)osGetCurrentProcessId(), pShmNode->nRegion, nByte, hMap ? "ok" : "failed")); @@ -3221,8 +3236,8 @@ static int winShmMap( int iOffset = pShmNode->nRegion*szRegion; int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity; #if SQLITE_OS_WINRT - pMap = osMapViewOfFileEx(hMap, FILE_MAP_WRITE | FILE_MAP_READ, - 0, iOffset - iOffsetShift, szRegion + iOffsetShift, NULL + pMap = osMapViewOfFileFromApp(hMap, FILE_MAP_WRITE | FILE_MAP_READ, + iOffset - iOffsetShift, szRegion + iOffsetShift ); #else pMap = osMapViewOfFile(hMap, FILE_MAP_WRITE | FILE_MAP_READ, @@ -4264,7 +4279,7 @@ int sqlite3_os_init(void){ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ - assert( ArraySize(aSyscall)==72 ); + assert( ArraySize(aSyscall)==73 ); #ifndef SQLITE_OMIT_WAL /* get memory map allocation granularity */ From 401e9153e9c8a28380146495159eac4da9275c66 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 4 Jun 2012 05:18:32 +0000 Subject: [PATCH 47/59] When not compiling for WinRT, skip using a couple Win32 APIs unavailable when compiling with MinGW. FossilOrigin-Name: eb29e2d93984c29756430b55c08501d7e1783df0 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index ef63fa7d06..9d43e5d76f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sseveral\sAPIs\sto\senable\scompilation\swith\snewer\srevisions\sof\sWinRT. -D 2012-05-31T22:12:26.763 +C When\snot\scompiling\sfor\sWinRT,\sskip\susing\sa\scouple\sWin32\sAPIs\sunavailable\swhen\scompiling\swith\sMinGW. +D 2012-06-04T05:18:32.951 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -160,7 +160,7 @@ F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 424d46e0edab969293c2223f09923b2178171f47 -F src/os_win.c ce6b415a2efd30027d4881bc8266c90ed4bc3ad0 +F src/os_win.c e3d3d3e26b65a35d4293d753137a58510bd3299b F src/pager.c bb5635dde0b152797836d1c72275284724bb563c F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099 @@ -998,7 +998,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 1dd01e408161f5c1ab6b4fd449bee147d7e00744 -R e2e31613ef8f782c24f244b69c156ce3 +P 54de739f056749b53b198f6b074d9e649520cf00 +R 3d3156f22dcbc533103d303a20808da1 U mistachkin -Z 408bf47646a7d2177c7080bd3b9695d2 +Z 5ca4b04744121d2d2667ad0e95a12f12 diff --git a/manifest.uuid b/manifest.uuid index a21151147e..674e2d893b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -54de739f056749b53b198f6b074d9e649520cf00 \ No newline at end of file +eb29e2d93984c29756430b55c08501d7e1783df0 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 376e240c75..8509e9272d 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -684,7 +684,7 @@ static struct win_syscall { #define osWriteFile ((BOOL(WINAPI*)(HANDLE,LPCVOID,DWORD,LPDWORD, \ LPOVERLAPPED))aSyscall[58].pCurrent) -#if !SQLITE_OS_WINCE +#if SQLITE_OS_WINRT { "CreateEventExW", (SYSCALL)CreateEventExW, 0 }, #else { "CreateEventExW", (SYSCALL)0, 0 }, @@ -720,7 +720,7 @@ static struct win_syscall { #define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \ PLARGE_INTEGER,DWORD))aSyscall[62].pCurrent) -#if !SQLITE_OS_WINCE +#if SQLITE_OS_WINRT { "GetFileInformationByHandleEx", (SYSCALL)GetFileInformationByHandleEx, 0 }, #else { "GetFileInformationByHandleEx", (SYSCALL)0, 0 }, From d3babb52208bd2373059b355866e8e1333c10909 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 5 Jun 2012 02:24:54 +0000 Subject: [PATCH 48/59] Correct docs regarding use of malloc and free by the Windows VFS layer. No changes to code. FossilOrigin-Name: 8e8590a4dc8d9b0fa12ce288cdfd0146223fee6c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 9d43e5d76f..2e1af4b1b2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\snot\scompiling\sfor\sWinRT,\sskip\susing\sa\scouple\sWin32\sAPIs\sunavailable\swhen\scompiling\swith\sMinGW. -D 2012-06-04T05:18:32.951 +C Correct\sdocs\sregarding\suse\sof\smalloc\sand\sfree\sby\sthe\sWindows\sVFS\slayer.\s\sNo\schanges\sto\scode. +D 2012-06-05T02:24:54.043 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -175,7 +175,7 @@ F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1 F src/select.c f6c4833c4d8e94714761d99013d74f381e084f1d F src/shell.c c16f72e34f611f060546709564c121a67cb2b31b -F src/sqlite.h.in 51b406bc156dcdfbb2af45ba11555256f23937be +F src/sqlite.h.in 06a5141bdc5cc8959fe04bc0f59b0fe0ff742c90 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqliteInt.h 97ccae71ae0a4e924dcb9fab14eb4fc4839790da F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d @@ -998,7 +998,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 54de739f056749b53b198f6b074d9e649520cf00 -R 3d3156f22dcbc533103d303a20808da1 +P eb29e2d93984c29756430b55c08501d7e1783df0 +R c0cc15c1965faab4224b374fdd762280 U mistachkin -Z 5ca4b04744121d2d2667ad0e95a12f12 +Z 5d7036d126f9e49518f298514203b768 diff --git a/manifest.uuid b/manifest.uuid index 674e2d893b..f1097a6089 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eb29e2d93984c29756430b55c08501d7e1783df0 \ No newline at end of file +8e8590a4dc8d9b0fa12ce288cdfd0146223fee6c \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 30cff3ae3e..f0f7ff93ec 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2164,12 +2164,12 @@ char *sqlite3_vsnprintf(int,char*,const char*, va_list); ** implementation of these routines to be omitted. That capability ** is no longer provided. Only built-in memory allocators can be used. ** -** The Windows OS interface layer calls +** Prior to SQLite version 3.7.10, the Windows OS interface layer called ** the system malloc() and free() directly when converting ** filenames between the UTF-8 encoding used by SQLite ** and whatever filename encoding is used by the particular Windows -** installation. Memory allocation errors are detected, but -** they are reported back as [SQLITE_CANTOPEN] or +** installation. Memory allocation errors were detected, but +** they were reported back as [SQLITE_CANTOPEN] or ** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. ** ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] From 98c78ea63f62f26df6766df1b00e496775959a09 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 5 Jun 2012 13:56:15 +0000 Subject: [PATCH 49/59] Add sqlite3_quota_ferror() and sqlite3_quota_file_available() interfaces to test_quota.c. Change sqlite3_quota_fwrite() to use a const input buffer. FossilOrigin-Name: 61669c95859e187618fb2fb4249306a947ae8d26 --- manifest | 16 +++++----- manifest.uuid | 2 +- src/test_quota.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++-- src/test_quota.h | 19 ++++++++++-- test/quota2.test | 26 +++++++++++++++- 5 files changed, 129 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index b001b92c56..604ec87337 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\scalling\sfchown()\sif\sthe\sprocess\sis\snot\srunning\sas\sroot. -D 2012-05-31T13:10:49.376 +C Add\ssqlite3_quota_ferror()\sand\ssqlite3_quota_file_available()\sinterfaces\sto\ntest_quota.c.\s\sChange\ssqlite3_quota_fwrite()\sto\suse\sa\sconst\sinput\sbuffer. +D 2012-06-05T13:56:15.352 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -218,8 +218,8 @@ F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e F src/test_onefile.c 0396f220561f3b4eedc450cef26d40c593c69a25 F src/test_osinst.c 90a845c8183013d80eccb1f29e8805608516edba F src/test_pcache.c a5cd24730cb43c5b18629043314548c9169abb00 -F src/test_quota.c 47cb7b606160ce8f603a7d47143dd1f74de09058 -F src/test_quota.h ee5da2ae7f84d1c8e0e0e2ab33f01d69f10259b5 +F src/test_quota.c 0af3e1e9a1f22bc5f431dd3efcc32762f4109f58 +F src/test_quota.h 8761e463b25e75ebc078bd67d70e39b9c817a0cb F src/test_rtree.c aba603c949766c4193f1068b91c787f57274e0d9 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f @@ -651,7 +651,7 @@ F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota-glob.test 32901e9eed6705d68ca3faee2a06b73b57cb3c26 F test/quota.test c2f778dab4c7fb07bcfa962cc5c762f36d8061dc -F test/quota2.test bc9fdb2e46aace691c1a01a9cc8d097bd4d7c1ab +F test/quota2.test 52175f1c94fb01711da38095a7d3988d0c7d6575 F test/quote.test 215897dbe8de1a6f701265836d6601cc6ed103e6 F test/randexpr1.tcl 40dec52119ed3a2b8b2a773bce24b63a3a746459 F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 07935d10d341fe6265cfd3b09e2c4ef4005c4826 -R db0f48be730e02610af744a3fe432e51 +P 70c419a434be77b042a23174483d6a411899eb5d +R 6f34bdd03e1922ea3b6cb56fd9309a2c U drh -Z a3e118b76a7afa02078e1c319e3927b5 +Z 1b017ff1370375c5086bff54a1d45078 diff --git a/manifest.uuid b/manifest.uuid index b74e97b330..9d397b734f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -70c419a434be77b042a23174483d6a411899eb5d \ No newline at end of file +61669c95859e187618fb2fb4249306a947ae8d26 \ No newline at end of file diff --git a/src/test_quota.c b/src/test_quota.c index 38dc36fdc2..6fd7329f88 100644 --- a/src/test_quota.c +++ b/src/test_quota.c @@ -1042,7 +1042,7 @@ size_t sqlite3_quota_fread( ** the write if we exceed quota. */ size_t sqlite3_quota_fwrite( - void *pBuf, /* Take content to write from here */ + const void *pBuf, /* Take content to write from here */ size_t size, /* Size of each element */ size_t nmemb, /* Number of elements */ quota_FILE *p /* Write to this quota_FILE objecct */ @@ -1052,7 +1052,7 @@ size_t sqlite3_quota_fwrite( sqlite3_int64 szNew; quotaFile *pFile; size_t rc; - + iOfst = ftell(p->f); iEnd = iOfst + size*nmemb; pFile = p->pFile; @@ -1091,7 +1091,7 @@ size_t sqlite3_quota_fwrite( pFile->iSize = iNewEnd; quotaLeave(); } - return rc; + return rc; } /* @@ -1160,6 +1160,13 @@ long sqlite3_quota_ftell(quota_FILE *p){ return ftell(p->f); } +/* +** Test the error indicator for the given file. +*/ +int sqlite3_quota_ferror(quota_FILE *p){ + return ferror(p->f); +} + /* ** Truncate a file to szNew bytes. */ @@ -1236,6 +1243,25 @@ sqlite3_int64 sqlite3_quota_file_truesize(quota_FILE *p){ sqlite3_int64 sqlite3_quota_file_size(quota_FILE *p){ return p->pFile ? p->pFile->iSize : -1; } + +/* +** Determine the amount of data in bytes available for reading +** in the given file. +*/ +long sqlite3_quota_file_available(quota_FILE *p){ + FILE* f = p->f; + long pos1, pos2; + int rc; + pos1 = ftell(f); + if ( pos1 < 0 ) return -1; + rc = fseek(f, 0, SEEK_END); + if ( rc != 0 ) return -1; + pos2 = ftell(f); + if ( pos2 < 0 ) return -1; + rc = fseek(f, pos1, SEEK_SET); + if ( rc != 0 ) return -1; + return pos2 - pos1; +} /* ** Remove a managed file. Update quotas accordingly. @@ -1895,6 +1921,53 @@ static int test_quota_glob( return TCL_OK; } +/* +** tclcmd: sqlite3_quota_file_available HANDLE +** +** Return the number of bytes from the current file point to the end of +** the file. +*/ +static int test_quota_file_available( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + quota_FILE *p; + sqlite3_int64 x; + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 1, objv, "HANDLE"); + return TCL_ERROR; + } + p = sqlite3TestTextToPtr(Tcl_GetString(objv[1])); + x = sqlite3_quota_file_available(p); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(x)); + return TCL_OK; +} + +/* +** tclcmd: sqlite3_quota_ferror HANDLE +** +** Return true if the file handle is in the error state. +*/ +static int test_quota_ferror( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + quota_FILE *p; + int x; + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 1, objv, "HANDLE"); + return TCL_ERROR; + } + p = sqlite3TestTextToPtr(Tcl_GetString(objv[1])); + x = sqlite3_quota_ferror(p); + Tcl_SetObjResult(interp, Tcl_NewIntObj(x)); + return TCL_OK; +} + /* ** This routine registers the custom TCL commands defined in this ** module. This should be the only procedure visible from outside @@ -1924,6 +1997,8 @@ int Sqlitequota_Init(Tcl_Interp *interp){ { "sqlite3_quota_file_mtime", test_quota_file_mtime }, { "sqlite3_quota_remove", test_quota_remove }, { "sqlite3_quota_glob", test_quota_glob }, + { "sqlite3_quota_file_available",test_quota_file_available }, + { "sqlite3_quota_ferror", test_quota_ferror }, }; int i; diff --git a/src/test_quota.h b/src/test_quota.h index 9bd4312c6c..2d0767a19a 100644 --- a/src/test_quota.h +++ b/src/test_quota.h @@ -162,7 +162,7 @@ quota_FILE *sqlite3_quota_fopen(const char *zFilename, const char *zMode); ** the sum of sizes of all files from going over quota. */ size_t sqlite3_quota_fread(void*, size_t, size_t, quota_FILE*); -size_t sqlite3_quota_fwrite(void*, size_t, size_t, quota_FILE*); +size_t sqlite3_quota_fwrite(const void*, size_t, size_t, quota_FILE*); /* ** Flush all written content held in memory buffers out to disk. @@ -190,6 +190,13 @@ int sqlite3_quota_fseek(quota_FILE*, long, int); void sqlite3_quota_rewind(quota_FILE*); long sqlite3_quota_ftell(quota_FILE*); +/* +** Test the error indicator for the given file. +** +** Return non-zero if the error indicator is set. +*/ +int sqlite3_quota_ferror(quota_FILE*); + /* ** Truncate a file previously opened by sqlite3_quota_fopen(). Return ** zero on success and non-zero on any kind of failure. @@ -198,7 +205,7 @@ long sqlite3_quota_ftell(quota_FILE*); ** Any attempt to "truncate" a file to a larger size results in ** undefined behavior. */ -int sqlite3_quota_ftrunate(quota_FILE*, sqlite3_int64 newSize); +int sqlite3_quota_ftruncate(quota_FILE*, sqlite3_int64 newSize); /* ** Return the last modification time of the opened file, in seconds @@ -232,6 +239,14 @@ sqlite3_int64 sqlite3_quota_file_size(quota_FILE*); */ sqlite3_int64 sqlite3_quota_file_truesize(quota_FILE*); +/* +** Determine the amount of data in bytes available for reading +** in the given file. +** +** Return -1 if the amount cannot be determined for some reason. +*/ +long sqlite3_quota_file_available(quota_FILE*); + /* ** Delete a file from the disk, if that file is under quota management. ** Adjust quotas accordingly. diff --git a/test/quota2.test b/test/quota2.test index 5bb50d7ce0..202cdacf1c 100644 --- a/test/quota2.test +++ b/test/quota2.test @@ -164,11 +164,17 @@ do_test quota2-2.1 { do_test quota2-2.2 { set ::quota } {} -do_test quota2-2.3 { +do_test quota2-2.3.1 { sqlite3_quota_rewind $::h1 + sqlite3_quota_file_available $::h1 +} {7000} +do_test quota2-2.3.2 { set ::x [sqlite3_quota_fread $::h1 1001 7] string length $::x } {6006} +do_test quota2-2.3.3 { + sqlite3_quota_file_available $::h1 +} {0} do_test quota2-2.4 { string match $::x [string range $::bigtext 0 6005] } {1} @@ -180,22 +186,40 @@ do_test quota2-2.6 { sqlite3_quota_fseek $::h1 -100 SEEK_END sqlite3_quota_ftell $::h1 } {6900} +do_test quota2-2.6.1 { + sqlite3_quota_file_available $::h1 +} {100} do_test quota2-2.7 { sqlite3_quota_fseek $::h1 -100 SEEK_CUR sqlite3_quota_ftell $::h1 } {6800} +do_test quota2-2.7.1 { + sqlite3_quota_file_available $::h1 +} {200} do_test quota2-2.8 { sqlite3_quota_fseek $::h1 50 SEEK_CUR sqlite3_quota_ftell $::h1 } {6850} +do_test quota2-2.8.1 { + sqlite3_quota_file_available $::h1 +} {150} do_test quota2-2.9 { sqlite3_quota_fseek $::h1 50 SEEK_SET sqlite3_quota_ftell $::h1 } {50} +do_test quota2-2.9.1 { + sqlite3_quota_file_available $::h1 +} {6950} do_test quota2-2.10 { sqlite3_quota_rewind $::h1 sqlite3_quota_ftell $::h1 } {0} +do_test quota2-2.10.1 { + sqlite3_quota_file_available $::h1 +} {7000} +do_test quota2-2.10.2 { + sqlite3_quota_ferror $::h1 +} {0} do_test quota2-2.11 { standard_path [sqlite3_quota_dump] } {{*/quota2b/* 5000 0} {*/quota2a/* 4000 0}} From a19b89627eec4c0506b98f34d5f50399c26fd8d4 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 6 Jun 2012 10:56:22 +0000 Subject: [PATCH 50/59] Make sure the Index.azColl pointers do not point to connection-specific memory. Also, remove an unnecessary reinitialization to sqlite3.pDfltColl. FossilOrigin-Name: c469850b2eb61a63150cc5fc7d2fe98f0b5abffb --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/build.c | 2 +- src/prepare.c | 1 - 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 8dd687ea56..9c4e896868 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sthe\slatest\strunk\schanges\sinto\sshared-schema\sbranch.\s\sAlso\sfix\sa\sC99-ism\s\nin\sthat\sbranch. -D 2012-06-05T19:20:03.039 +C Make\ssure\sthe\sIndex.azColl\spointers\sdo\snot\spoint\sto\sconnection-specific\smemory.\nAlso,\sremove\san\sunnecessary\sreinitialization\sto\ssqlite3.pDfltColl. +D 2012-06-06T10:56:22.535 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -126,7 +126,7 @@ F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c f0b71054103cb77eb5e782088c16998ec4f06624 F src/btree.h 48a013f8964f12d944d90e4700df47b72dd6d923 F src/btreeInt.h 38a639c0542c29fe8331a221c4aed0cb8686249e -F src/build.c 178b24b35ada3688aa63d04cd6a2f972cb481aea +F src/build.c 47c4506afe4bcb4ed1f4b5357582d1cb3402f8ad F src/callback.c 0cb4228cdcd827dcc5def98fb099edcc9142dbcd F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c a9c26822515f81ec21588cbb482ca6724be02e33 @@ -173,7 +173,7 @@ F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c F src/pcache1.c b30b1c35908346ecc43d8d9d17f2ddf6817f8f60 F src/pragma.c 28d7955a9e9a27d41cb462690228d39e3cec231c -F src/prepare.c ef197444dac110ee57a5f49745368b447a8c6bd1 +F src/prepare.c 33291b83cca285718048d219c67b8298501fa3a5 F src/printf.c 7ffb4ebb8b341f67e049695ba031da717b3d2699 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P ea2cd55e098b21cd8997fd6c1978131d3ef2fab4 61669c95859e187618fb2fb4249306a947ae8d26 -R fc7cb647ad4d37ffcdbbdbe50e659acc +P 42338e9e6979bb497823527f8f39e96f63623c59 +R 4e8ba0ec11cbdf49789a46888b404344 U drh -Z 0c46cbc562d7f9db30fca97ff8d69c33 +Z a16a791ba70d8a38d9ba353fda40937d diff --git a/manifest.uuid b/manifest.uuid index 7d57948980..52f568de93 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -42338e9e6979bb497823527f8f39e96f63623c59 \ No newline at end of file +c469850b2eb61a63150cc5fc7d2fe98f0b5abffb \ No newline at end of file diff --git a/src/build.c b/src/build.c index 7938343e81..9f13b7b11c 100644 --- a/src/build.c +++ b/src/build.c @@ -2765,7 +2765,7 @@ Index *sqlite3CreateIndex( }else{ zColl = pTab->aCol[j].zColl; if( !zColl ){ - zColl = db->pDfltColl->zName; + zColl = "BINARY"; } } if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){ diff --git a/src/prepare.c b/src/prepare.c index f1dbb6b3b0..bd2cf7aafc 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -262,7 +262,6 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ encoding = (u8)meta[BTREE_TEXT_ENCODING-1] & 3; if( encoding==0 ) encoding = SQLITE_UTF8; ENC(db) = encoding; - db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 0); }else{ /* If opening an attached database, the encoding much match ENC(db) */ if( meta[BTREE_TEXT_ENCODING-1]!=ENC(db) ){ From 754d3adf7c54bdc34c6d2b91bccb609244f14895 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 6 Jun 2012 19:30:38 +0000 Subject: [PATCH 51/59] Have the FTS unicode61 strip out diacritics when tokenizing text. This can be disabled by specifying the tokenizer option "remove_diacritics=0". FossilOrigin-Name: 790f76a5898dad1a955d40edddf11f7b0fec0ccd --- ext/fts3/fts3Int.h | 5 +- ext/fts3/fts3_unicode.c | 33 +++- ext/fts3/fts3_unicode2.c | 72 ++++++++- ext/fts3/unicode/mkunicode.tcl | 266 +++++++++++++++++++++++++++++++-- manifest | 22 +-- manifest.uuid | 2 +- test/fts4unicode.test | 15 ++ 7 files changed, 383 insertions(+), 32 deletions(-) diff --git a/ext/fts3/fts3Int.h b/ext/fts3/fts3Int.h index 097d4a3f0a..98e353bea5 100644 --- a/ext/fts3/fts3Int.h +++ b/ext/fts3/fts3Int.h @@ -542,8 +542,11 @@ int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr); int sqlite3Fts3DeferredTokenList(Fts3DeferredToken *, char **, int *); /* fts3_unicode2.c (functions generated by parsing unicode text files) */ -int sqlite3FtsUnicodeTolower(int); +#ifndef SQLITE_DISABLE_FTS3_UNICODE +int sqlite3FtsUnicodeFold(int, int); int sqlite3FtsUnicodeIsalnum(int); +int sqlite3FtsUnicodeIsdiacritic(int); +#endif #endif /* !SQLITE_CORE || SQLITE_ENABLE_FTS3 */ #endif /* _FTSINT_H */ diff --git a/ext/fts3/fts3_unicode.c b/ext/fts3/fts3_unicode.c index 83b1c322b2..c5228273b3 100644 --- a/ext/fts3/fts3_unicode.c +++ b/ext/fts3/fts3_unicode.c @@ -82,6 +82,7 @@ typedef struct unicode_cursor unicode_cursor; struct unicode_tokenizer { sqlite3_tokenizer base; + int bRemoveDiacritic; }; struct unicode_cursor { @@ -103,11 +104,30 @@ static int unicodeCreate( sqlite3_tokenizer **pp /* OUT: New tokenizer handle */ ){ unicode_tokenizer *pNew; /* New tokenizer object */ + int i; pNew = (unicode_tokenizer *) sqlite3_malloc(sizeof(unicode_tokenizer)); if( pNew==NULL ){ return SQLITE_NOMEM; } memset(pNew, 0, sizeof(unicode_tokenizer)); + pNew->bRemoveDiacritic = 1; + + for(i=0; ibRemoveDiacritic = 1; + } + else if( n==19 && memcmp("remove_diacritics=0", z, 19)==0 ){ + pNew->bRemoveDiacritic = 0; + } + else{ + /* Unrecognized argument */ + return SQLITE_ERROR; + } + } + *pp = &pNew->base; return SQLITE_OK; } @@ -197,6 +217,8 @@ static int unicodeNext( zOut = pCsr->zToken; do { + int iOut; + /* Grow the output buffer if required. */ if( (zOut-pCsr->zToken)>=(pCsr->nAlloc-4) ){ char *zNew = sqlite3_realloc(pCsr->zToken, pCsr->nAlloc+64); @@ -208,12 +230,19 @@ static int unicodeNext( /* Write the folded case of the last character read to the output */ zEnd = z; - WRITE_UTF8(zOut, sqlite3FtsUnicodeTolower(iCode)); + iOut = sqlite3FtsUnicodeFold(iCode, + ((unicode_tokenizer *)pCsr->base.pTokenizer)->bRemoveDiacritic + ); + if( iOut ){ + WRITE_UTF8(zOut, iOut); + } /* If the cursor is not at EOF, read the next character */ if( z>=zTerm ) break; READ_UTF8(z, zTerm, iCode); - }while( sqlite3FtsUnicodeIsalnum(iCode) ); + }while( sqlite3FtsUnicodeIsalnum(iCode) + || sqlite3FtsUnicodeIsdiacritic(iCode) + ); /* Set the output variables and return. */ pCsr->iOff = (z - pCsr->aInput); diff --git a/ext/fts3/fts3_unicode2.c b/ext/fts3/fts3_unicode2.c index 6f053c1321..3bb7874b29 100644 --- a/ext/fts3/fts3_unicode2.c +++ b/ext/fts3/fts3_unicode2.c @@ -152,6 +152,74 @@ int sqlite3FtsUnicodeIsalnum(int c){ } +/* +** If the argument is a codepoint corresponding to a lowercase letter +** in the ASCII range with a diacritic added, return the codepoint +** of the ASCII letter only. For example, if passed 235 - "LATIN +** SMALL LETTER E WITH DIAERESIS" - return 65 ("LATIN SMALL LETTER +** E"). The resuls of passing a codepoint that corresponds to an +** uppercase letter are undefined. +*/ +static int remove_diacritic(int c){ + unsigned short aDia[] = { + 0, 1797, 1848, 1859, 1891, 1928, 1940, 1995, + 2024, 2040, 2060, 2110, 2168, 2206, 2264, 2286, + 2344, 2383, 2472, 2488, 2516, 2596, 2668, 2732, + 2782, 2842, 2894, 2954, 2984, 3000, 3028, 3336, + 3456, 3696, 3712, 3728, 3744, 3896, 3912, 3928, + 3968, 4008, 4040, 4106, 4138, 4170, 4202, 4234, + 4266, 4296, 4312, 4344, 4408, 4424, 4472, 4504, + 6148, 6198, 6264, 6280, 6360, 6429, 6505, 6529, + 61448, 61468, 61534, 61592, 61642, 61688, 61704, 61726, + 61784, 61800, 61836, 61880, 61914, 61948, 61998, 62122, + 62154, 62200, 62218, 62302, 62364, 62442, 62478, 62536, + 62554, 62584, 62604, 62640, 62648, 62656, 62664, 62730, + 62924, 63050, 63082, 63274, 63390, + }; + char aChar[] = { + '\0', 'a', 'c', 'e', 'i', 'n', 'o', 'u', 'y', 'y', 'a', 'c', + 'd', 'e', 'e', 'g', 'h', 'i', 'j', 'k', 'l', 'n', 'o', 'r', + 's', 't', 'u', 'u', 'w', 'y', 'z', 'o', 'u', 'a', 'i', 'o', + 'u', 'g', 'k', 'o', 'j', 'g', 'n', 'a', 'e', 'i', 'o', 'r', + 'u', 's', 't', 'h', 'a', 'e', 'o', 'y', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', 'a', 'b', 'd', 'd', 'e', 'f', 'g', 'h', + 'h', 'i', 'k', 'l', 'l', 'm', 'n', 'p', 'r', 'r', 's', 't', + 'u', 'v', 'w', 'w', 'x', 'y', 'z', 'h', 't', 'w', 'y', 'a', + 'e', 'i', 'o', 'u', 'y', + }; + + unsigned int key = (((unsigned int)c)<<3) | 0x00000007; + int iRes = 0; + int iHi = sizeof(aDia)/sizeof(aDia[0]) - 1; + int iLo = 0; + while( iHi>=iLo ){ + int iTest = (iHi + iLo) / 2; + if( key >= aDia[iTest] ){ + iRes = iTest; + iLo = iTest+1; + }else{ + iHi = iTest-1; + } + } + assert( key>=aDia[iRes] ); + return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]); +}; + + +/* +** Return true if the argument interpreted as a unicode codepoint +** is a diacritical modifier character. +*/ +int sqlite3FtsUnicodeIsdiacritic(int c){ + unsigned int mask0 = 0x08029FDF; + unsigned int mask1 = 0x000361F8; + if( c<768 || c>817 ) return 0; + return (c < 768+32) ? + (mask0 & (1 << (c-768))) : + (mask1 & (1 << (c-768-32))); +} + + /* ** Interpret the argument as a unicode codepoint. If the codepoint ** is an upper case character that has a lower case equivalent, @@ -161,7 +229,7 @@ int sqlite3FtsUnicodeIsalnum(int c){ ** The results are undefined if the value passed to this function ** is less than zero. */ -int sqlite3FtsUnicodeTolower(int c){ +int sqlite3FtsUnicodeFold(int c, int bRemoveDiacritic){ /* Each entry in the following array defines a rule for folding a range ** of codepoints to lower case. The rule applies to a range of nRange ** codepoints starting at codepoint iCode. @@ -284,6 +352,8 @@ int sqlite3FtsUnicodeTolower(int c){ assert( ret>0 ); } } + + if( bRemoveDiacritic ) ret = remove_diacritic(ret); } else if( c>=66560 && c<66600 ){ diff --git a/ext/fts3/unicode/mkunicode.tcl b/ext/fts3/unicode/mkunicode.tcl index 83f079dfb4..0d58e8aa5c 100644 --- a/ext/fts3/unicode/mkunicode.tcl +++ b/ext/fts3/unicode/mkunicode.tcl @@ -1,4 +1,208 @@ +# +# Parameter $zName must be a path to the file UnicodeData.txt. This command +# reads the file and returns a list of mappings required to remove all +# diacritical marks from a unicode string. Each mapping is itself a list +# consisting of two elements - the unicode codepoint and the single ASCII +# character that it should be replaced with, or an empty string if the +# codepoint should simply be removed from the input. Examples: +# +# { 224 a } (replace codepoint 224 to "a") +# { 769 "" } (remove codepoint 769 from input) +# +# Mappings are only returned for non-upper case codepoints. It is assumed +# that the input has already been folded to lower case. +# +proc rd_load_unicodedata_text {zName} { + global tl_lookup_table + + set fd [open $zName] + set lField { + code + character_name + general_category + canonical_combining_classes + bidirectional_category + character_decomposition_mapping + decimal_digit_value + digit_value + numeric_value + mirrored + unicode_1_name + iso10646_comment_field + uppercase_mapping + lowercase_mapping + titlecase_mapping + } + set lRet [list] + + while { ![eof $fd] } { + set line [gets $fd] + if {$line == ""} continue + + set fields [split $line ";"] + if {[llength $fields] != [llength $lField]} { error "parse error: $line" } + foreach $lField $fields {} + if { [llength $character_decomposition_mapping]!=2 + || [string is xdigit [lindex $character_decomposition_mapping 0]]==0 + } { + continue + } + + set iCode [expr "0x$code"] + set iAscii [expr "0x[lindex $character_decomposition_mapping 0]"] + set iDia [expr "0x[lindex $character_decomposition_mapping 1]"] + + if {[info exists tl_lookup_table($iCode)]} continue + + if { ($iAscii >= 97 && $iAscii <= 122) + || ($iAscii >= 65 && $iAscii <= 90) + } { + lappend lRet [list $iCode [string tolower [format %c $iAscii]]] + set dia($iDia) 1 + } + } + + foreach d [array names dia] { + lappend lRet [list $d ""] + } + set lRet [lsort -integer -index 0 $lRet] + + close $fd + set lRet +} + + +proc print_rd {map} { + global tl_lookup_table + set aChar [list] + set lRange [list] + + set nRange 1 + set iFirst [lindex $map 0 0] + set cPrev [lindex $map 0 1] + + foreach m [lrange $map 1 end] { + foreach {i c} $m {} + + if {$cPrev == $c} { + for {set j [expr $iFirst+$nRange]} {$j<$i} {incr j} { + if {[info exists tl_lookup_table($j)]==0} break + } + + if {$j==$i} { + set nNew [expr {(1 + $i - $iFirst)}] + if {$nNew<=8} { + set nRange $nNew + continue + } + } + } + + lappend lRange [list $iFirst $nRange] + lappend aChar $cPrev + + set iFirst $i + set cPrev $c + set nRange 1 + } + lappend lRange [list $iFirst $nRange] + lappend aChar $cPrev + + puts "/*" + puts "** If the argument is a codepoint corresponding to a lowercase letter" + puts "** in the ASCII range with a diacritic added, return the codepoint" + puts "** of the ASCII letter only. For example, if passed 235 - \"LATIN" + puts "** SMALL LETTER E WITH DIAERESIS\" - return 65 (\"LATIN SMALL LETTER" + puts "** E\"). The resuls of passing a codepoint that corresponds to an" + puts "** uppercase letter are undefined." + puts "*/" + puts "static int remove_diacritic(int c)\{" + puts " unsigned short aDia\[\] = \{" + puts -nonewline " 0, " + set i 1 + foreach r $lRange { + foreach {iCode nRange} $r {} + if {($i % 8)==0} {puts "" ; puts -nonewline " " } + incr i + + puts -nonewline [format "%5d" [expr ($iCode<<3) + $nRange-1]] + puts -nonewline ", " + } + puts "" + puts " \};" + puts " char aChar\[\] = \{" + puts -nonewline " '\\0', " + set i 1 + foreach c $aChar { + set str "'$c', " + if {$c == ""} { set str "'\\0', " } + + if {($i % 12)==0} {puts "" ; puts -nonewline " " } + incr i + puts -nonewline "$str" + } + puts "" + puts " \};" + puts { + unsigned int key = (((unsigned int)c)<<3) | 0x00000007; + int iRes = 0; + int iHi = sizeof(aDia)/sizeof(aDia[0]) - 1; + int iLo = 0; + while( iHi>=iLo ){ + int iTest = (iHi + iLo) / 2; + if( key >= aDia[iTest] ){ + iRes = iTest; + iLo = iTest+1; + }else{ + iHi = iTest-1; + } + } + assert( key>=aDia[iRes] ); + return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]);} + puts "\};" +} + +proc print_isdiacritic {zFunc map} { + + set lCode [list] + foreach m $map { + foreach {code char} $m {} + if {$code && $char == ""} { lappend lCode $code } + } + set lCode [lsort -integer $lCode] + set iFirst [lindex $lCode 0] + set iLast [lindex $lCode end] + + set i1 0 + set i2 0 + + foreach c $lCode { + set i [expr $c - $iFirst] + if {$i < 32} { + set i1 [expr {$i1 | (1<<$i)}] + } else { + set i2 [expr {$i2 | (1<<($i-32))}] + } + } + + puts "/*" + puts "** Return true if the argument interpreted as a unicode codepoint" + puts "** is a diacritical modifier character." + puts "*/" + puts "int ${zFunc}\(int c)\{" + puts " unsigned int mask0 = [format "0x%08X" $i1];" + puts " unsigned int mask1 = [format "0x%08X" $i2];" + + puts " if( c<$iFirst || c>$iLast ) return 0;" + puts " return (c < $iFirst+32) ?" + puts " (mask0 & (1 << (c-$iFirst))) :" + puts " (mask1 & (1 << (c-$iFirst-32)));" + puts "\}" +} + + +#------------------------------------------------------------------------- # Parameter $zName must be a path to the file UnicodeData.txt. This command # reads the file and returns a list of codepoints (integers). The list @@ -393,7 +597,7 @@ proc tl_print_ioff_table {liOff} { } -proc print_tolower {zFunc} { +proc print_fold {zFunc} { set lRecord [tl_create_records] @@ -407,7 +611,7 @@ proc print_tolower {zFunc} { puts "** The results are undefined if the value passed to this function" puts "** is less than zero." puts "*/" - puts "int ${zFunc}\(int c)\{" + puts "int ${zFunc}\(int c, int bRemoveDiacritic)\{" set liOff [tl_generate_ioff_table $lRecord] tl_print_table_header @@ -451,6 +655,8 @@ proc print_tolower {zFunc} { assert( ret>0 ); } } + + if( bRemoveDiacritic ) ret = remove_diacritic(ret); } } @@ -463,22 +669,38 @@ proc print_tolower {zFunc} { puts "\}" } -proc print_tolower_test {zFunc} { +proc print_fold_test {zFunc mappings} { global tl_lookup_table - puts "static int tolower_test(int *piCode)\{" + foreach m $mappings { + set c [lindex $m 1] + if {$c == ""} { + set extra([lindex $m 0]) 0 + } else { + scan $c %c i + set extra([lindex $m 0]) $i + } + } + + puts "static int fold_test(int *piCode)\{" puts -nonewline " static int aLookup\[\] = \{" for {set i 0} {$i < 70000} {incr i} { + set expected $i catch { set expected $tl_lookup_table($i) } - if {($i % 8)==0} { puts "" ; puts -nonewline " " } - puts -nonewline "$expected, " + set expected2 $expected + catch { set expected2 $extra($expected2) } + + if {($i % 4)==0} { puts "" ; puts -nonewline " " } + puts -nonewline "$expected, $expected2, " } puts " \};" puts " int i;" puts " for(i=0; i Date: Wed, 6 Jun 2012 19:51:27 +0000 Subject: [PATCH 52/59] Disable FTS unicode61 by default. It is enabled by specifying compile time option SQLITE_ENABLE_FTS4_UNICODE61. FossilOrigin-Name: eccd6b6580637084495b80e9232262188ba0cf8d --- ext/fts3/fts3.c | 8 ++++---- ext/fts3/fts3Int.h | 2 +- ext/fts3/fts3_unicode.c | 4 ++-- ext/fts3/fts3_unicode2.c | 4 ++-- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/test_config.c | 6 +++--- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 3531cb4df7..54ff893943 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -3554,7 +3554,7 @@ static void hashDestroy(void *p){ */ void sqlite3Fts3SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule); void sqlite3Fts3PorterTokenizerModule(sqlite3_tokenizer_module const**ppModule); -#ifndef SQLITE_DISABLE_FTS3_UNICODE +#ifdef SQLITE_ENABLE_FTS4_UNICODE61 void sqlite3Fts3UnicodeTokenizer(sqlite3_tokenizer_module const**ppModule); #endif #ifdef SQLITE_ENABLE_ICU @@ -3572,7 +3572,7 @@ int sqlite3Fts3Init(sqlite3 *db){ Fts3Hash *pHash = 0; const sqlite3_tokenizer_module *pSimple = 0; const sqlite3_tokenizer_module *pPorter = 0; -#ifndef SQLITE_DISABLE_FTS3_UNICODE +#ifdef SQLITE_ENABLE_FTS4_UNICODE61 const sqlite3_tokenizer_module *pUnicode = 0; #endif @@ -3581,7 +3581,7 @@ int sqlite3Fts3Init(sqlite3 *db){ sqlite3Fts3IcuTokenizerModule(&pIcu); #endif -#ifndef SQLITE_DISABLE_FTS3_UNICODE +#ifdef SQLITE_ENABLE_FTS4_UNICODE61 sqlite3Fts3UnicodeTokenizer(&pUnicode); #endif @@ -3609,7 +3609,7 @@ int sqlite3Fts3Init(sqlite3 *db){ if( sqlite3Fts3HashInsert(pHash, "simple", 7, (void *)pSimple) || sqlite3Fts3HashInsert(pHash, "porter", 7, (void *)pPorter) -#ifndef SQLITE_DISABLE_FTS3_UNICODE +#ifdef SQLITE_ENABLE_FTS4_UNICODE61 || sqlite3Fts3HashInsert(pHash, "unicode61", 10, (void *)pUnicode) #endif #ifdef SQLITE_ENABLE_ICU diff --git a/ext/fts3/fts3Int.h b/ext/fts3/fts3Int.h index 98e353bea5..5dc14990ce 100644 --- a/ext/fts3/fts3Int.h +++ b/ext/fts3/fts3Int.h @@ -542,7 +542,7 @@ int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr); int sqlite3Fts3DeferredTokenList(Fts3DeferredToken *, char **, int *); /* fts3_unicode2.c (functions generated by parsing unicode text files) */ -#ifndef SQLITE_DISABLE_FTS3_UNICODE +#ifdef SQLITE_ENABLE_FTS4_UNICODE61 int sqlite3FtsUnicodeFold(int, int); int sqlite3FtsUnicodeIsalnum(int); int sqlite3FtsUnicodeIsdiacritic(int); diff --git a/ext/fts3/fts3_unicode.c b/ext/fts3/fts3_unicode.c index c5228273b3..5dcfb30acc 100644 --- a/ext/fts3/fts3_unicode.c +++ b/ext/fts3/fts3_unicode.c @@ -13,7 +13,7 @@ ** Implementation of the "unicode" full-text-search tokenizer. */ -#ifndef SQLITE_DISABLE_FTS3_UNICODE +#ifdef SQLITE_ENABLE_FTS4_UNICODE61 #include "fts3Int.h" #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) @@ -272,4 +272,4 @@ void sqlite3Fts3UnicodeTokenizer(sqlite3_tokenizer_module const **ppModule){ } #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ -#endif /* ifndef SQLITE_DISABLE_FTS3_UNICODE */ +#endif /* ifndef SQLITE_ENABLE_FTS4_UNICODE61 */ diff --git a/ext/fts3/fts3_unicode2.c b/ext/fts3/fts3_unicode2.c index 3bb7874b29..226d5ee419 100644 --- a/ext/fts3/fts3_unicode2.c +++ b/ext/fts3/fts3_unicode2.c @@ -15,7 +15,7 @@ ** DO NOT EDIT THIS MACHINE GENERATED FILE. */ -#if !defined(SQLITE_DISABLE_FTS3_UNICODE) +#if defined(SQLITE_ENABLE_FTS4_UNICODE61) #if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4) #include @@ -363,4 +363,4 @@ int sqlite3FtsUnicodeFold(int c, int bRemoveDiacritic){ return ret; } #endif /* defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4) */ -#endif /* !defined(SQLITE_DISABLE_FTS3_UNICODE) */ +#endif /* !defined(SQLITE_ENABLE_FTS4_UNICODE61) */ diff --git a/manifest b/manifest index 5f98dfd100..5ff19581aa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sthe\sFTS\sunicode61\sstrip\sout\sdiacritics\swhen\stokenizing\stext.\sThis\scan\sbe\sdisabled\sby\sspecifying\sthe\stokenizer\soption\s"remove_diacritics=0". -D 2012-06-06T19:30:38.602 +C Disable\sFTS\sunicode61\sby\sdefault.\sIt\sis\senabled\sby\sspecifying\scompile\stime\soption\sSQLITE_ENABLE_FTS4_UNICODE61. +D 2012-06-06T19:51:27.734 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -55,9 +55,9 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 41824d0db7d244ca335ce98162df1244863a05c4 +F ext/fts3/fts3.c bb3107c0e420ea2e26e57050e84cdf0aeaafcd4f F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe -F ext/fts3/fts3Int.h 11c711068474ffe66548d21a2a8498b3dea25348 +F ext/fts3/fts3Int.h 81115435f79248ac09017bc665aae27b410d651f F ext/fts3/fts3_aux.c 5205182bd8f372782597888156404766edf5781e F ext/fts3/fts3_expr.c dbc7ba4c3a6061adde0f38ed8e9b349568299551 F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914 @@ -70,8 +70,8 @@ F ext/fts3/fts3_test.c 348f7d08cae05285794e23dc4fe8b8fdf66e264a F ext/fts3/fts3_tokenizer.c 3da7254a9881f7e270ab28e2004e0d22b3212bce F ext/fts3/fts3_tokenizer.h 66dec98e365854b6cd2d54f1a96bb6d428fc5a68 F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004 -F ext/fts3/fts3_unicode.c a3c1b0780f764c75844bd13afd9fba139049a121 -F ext/fts3/fts3_unicode2.c 6381bcfd621b2800df134a560737eaa1ed07cb17 +F ext/fts3/fts3_unicode.c b9660ab4d7231d92d1853f34dc1a035efb59aa6d +F ext/fts3/fts3_unicode2.c 2965d217c37079f1dbbdbd2c58f843be285d73f2 F ext/fts3/fts3_write.c 6a6391d6b01114f885e24e1f66bbc11ffba0e9e2 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 @@ -200,7 +200,7 @@ F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e F src/test_backup.c c129c91127e9b46e335715ae2e75756e25ba27de F src/test_btree.c 5b89601dcb42a33ba8b820a6b763cc9cb48bac16 -F src/test_config.c d2da9f1490c38d9b9cb52f399b6adb81d538273a +F src/test_config.c 86c4b1897fab385c949db398995eef3b75a2f1ad F src/test_demovfs.c 20a4975127993f4959890016ae9ce5535a880094 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc F src/test_func.c 090f2c3339e85c2c964435f99aed6f3da9d59525 @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 635e3a762ddeb1f952f66a08c1d4d53e3f42c9eb -R 24f67134e172119b7ccb50ae93a76cbd +P 790f76a5898dad1a955d40edddf11f7b0fec0ccd +R b3b020dfaa40a6b886085c7104befb05 U dan -Z 32c2f5c3d9b162b4ae41c62d929207f9 +Z abcc18c27a4be2466863f9b79938e60e diff --git a/manifest.uuid b/manifest.uuid index 27fe4a1173..19e951b739 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -790f76a5898dad1a955d40edddf11f7b0fec0ccd \ No newline at end of file +eccd6b6580637084495b80e9232262188ba0cf8d \ No newline at end of file diff --git a/src/test_config.c b/src/test_config.c index 6b56460602..e784bbef03 100644 --- a/src/test_config.c +++ b/src/test_config.c @@ -307,10 +307,10 @@ static void set_options(Tcl_Interp *interp){ Tcl_SetVar2(interp, "sqlite_options", "fts3", "0", TCL_GLOBAL_ONLY); #endif -#if !defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_DISABLE_FTS3_UNICODE) - Tcl_SetVar2(interp, "sqlite_options", "fts3_unicode", "0", TCL_GLOBAL_ONLY); -#else +#if defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_ENABLE_FTS4_UNICODE61) Tcl_SetVar2(interp, "sqlite_options", "fts3_unicode", "1", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "fts3_unicode", "0", TCL_GLOBAL_ONLY); #endif #ifdef SQLITE_OMIT_GET_TABLE From 617235b1a015aaa32f2ca2eb329f5d9c6e13d09a Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 6 Jun 2012 23:25:33 +0000 Subject: [PATCH 53/59] Fix an #if that is applicable to WinRT, even thought it is currently disabled by another #if. FossilOrigin-Name: baa8b7830779d5797e210a2e057181413412e152 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/mutex_w32.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 1c81e6070a..a87fabb0e4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sthe\schanges\sneed\sto\scompile\son\sWinRT\sinto\strunk. -D 2012-06-06T23:23:23.374 +C Fix\san\s#if\sthat\sis\sapplicable\sto\sWinRT,\seven\sthought\sit\sis\scurrently\sdisabled\sby\sanother\s#if. +D 2012-06-06T23:25:33.382 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -158,7 +158,7 @@ F src/mutex.h 2a79e0c10c26412546b501ee0f3d92b42decf63e F src/mutex_noop.c 7682796b7d8d39bf1c138248858efcd10c9e1553 F src/mutex_os2.c 882d735098c07c8c6a5472b8dd66e19675fe117f F src/mutex_unix.c c3a4e00f96ba068a8dbef34084465979aaf369cc -F src/mutex_w32.c 1170f64d08dc35cd43f6d0bfa833cac5da979279 +F src/mutex_w32.c db8970270841e2385a43602477e84c4b19aff1db F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P eccd6b6580637084495b80e9232262188ba0cf8d 8e8590a4dc8d9b0fa12ce288cdfd0146223fee6c -R e54f5d64d1e08d0a0f77f7e82ee4ca4c -U drh -Z b901cb0ca598db2780e99899aea938ab +P 61360ca6ca3448477d5c662d3642beef6dd2079e +R a8e059bd0c09878cce709aac9edcf4a3 +U mistachkin +Z 60750c2a7d3cb45d526c9f1bc86a508c diff --git a/manifest.uuid b/manifest.uuid index ba2b7d5362..2e6a58b36d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -61360ca6ca3448477d5c662d3642beef6dd2079e \ No newline at end of file +baa8b7830779d5797e210a2e057181413412e152 \ No newline at end of file diff --git a/src/mutex_w32.c b/src/mutex_w32.c index 3717900608..accf9ef8a2 100644 --- a/src/mutex_w32.c +++ b/src/mutex_w32.c @@ -56,7 +56,7 @@ struct sqlite3_mutex { ** this out as well. */ #if 0 -#if SQLITE_OS_WINCE +#if SQLITE_OS_WINCE || SQLITE_OS_WINRT # define mutexIsNT() (1) #else static int mutexIsNT(void){ From 5e0c4938601a8ffc7773a84479bcb99928021dd5 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 6 Jun 2012 23:59:36 +0000 Subject: [PATCH 54/59] Fix harmless Clang warnings. FossilOrigin-Name: 31fe1985ad6be5eb04bbe85da378c2385c503ceb --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/pager.c | 2 +- tool/warnings-clang.sh | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index a87fabb0e4..fbf5a657fb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\s#if\sthat\sis\sapplicable\sto\sWinRT,\seven\sthought\sit\sis\scurrently\sdisabled\sby\sanother\s#if. -D 2012-06-06T23:25:33.382 +C Fix\sharmless\sClang\swarnings. +D 2012-06-06T23:59:36.067 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -166,7 +166,7 @@ F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c d7c96b5d140f550f07345870112fae5d7ef99757 F src/os_win.c e3d3d3e26b65a35d4293d753137a58510bd3299b -F src/pager.c 9d4d6406512002d9a243ec27b9c01e93fda43e36 +F src/pager.c a1147e04bb1f64ee31bba8da2351f5e727f62179 F src/pager.h 8b8c9bc065a3c66769df8724dfdf492ee1aab3c5 F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 @@ -1003,9 +1003,9 @@ F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 +F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 61360ca6ca3448477d5c662d3642beef6dd2079e -R a8e059bd0c09878cce709aac9edcf4a3 -U mistachkin -Z 60750c2a7d3cb45d526c9f1bc86a508c +P baa8b7830779d5797e210a2e057181413412e152 +R f3c80d376d96bec331a1d34f3039877a +U drh +Z 3a2862b939ba347e67b7710215b7f1c2 diff --git a/manifest.uuid b/manifest.uuid index 2e6a58b36d..9f563c3ef9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -baa8b7830779d5797e210a2e057181413412e152 \ No newline at end of file +31fe1985ad6be5eb04bbe85da378c2385c503ceb \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 425fb78ce4..bd788fb1f3 100644 --- a/src/pager.c +++ b/src/pager.c @@ -4446,7 +4446,7 @@ int sqlite3PagerOpen( assert( nPathname>0 ); pPager->zJournal = (char*)(pPtr += nPathname + 1 + nUri); memcpy(pPager->zFilename, zPathname, nPathname); - memcpy(&pPager->zFilename[nPathname+1], zUri, nUri); + if( nUri ) memcpy(&pPager->zFilename[nPathname+1], zUri, nUri); memcpy(pPager->zJournal, zPathname, nPathname); memcpy(&pPager->zJournal[nPathname], "-journal\000", 8+1); sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal); diff --git a/tool/warnings-clang.sh b/tool/warnings-clang.sh index b0d2fb6d10..7a0aa4bce7 100644 --- a/tool/warnings-clang.sh +++ b/tool/warnings-clang.sh @@ -7,7 +7,7 @@ rm -f sqlite3.c make sqlite3.c echo '************* FTS4 and RTREE ****************' scan-build gcc -c -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE \ - -DSQLITE_DEBUG sqlite3.c 2>&1 | grep -v 'ANALYZE:' + -DSQLITE_DEBUG -DSQLITE_ENABLE_STAT3 sqlite3.c 2>&1 | grep -v 'ANALYZE:' echo '********** ENABLE_STAT3. THREADSAFE=0 *******' scan-build gcc -c -I. -DSQLITE_ENABLE_STAT3 -DSQLITE_THREADSAFE=0 \ -DSQLITE_DEBUG \ From 4bd6952a77790cb0a3d84e6e76d07a7d381b99b4 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 7 Jun 2012 02:35:29 +0000 Subject: [PATCH 55/59] Provide an (undocumented) compile-time option to disable the page cache overflow counter, in order to avoid a mutex. FossilOrigin-Name: 208825cd830748a2ca456affc57be75bbe618e47 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pcache1.c | 4 ++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index fbf5a657fb..2a453a9705 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\sClang\swarnings. -D 2012-06-06T23:59:36.067 +C Provide\san\s(undocumented)\scompile-time\soption\sto\sdisable\sthe\spage\scache\noverflow\scounter,\sin\sorder\sto\savoid\sa\smutex. +D 2012-06-07T02:35:29.974 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -171,7 +171,7 @@ F src/pager.h 8b8c9bc065a3c66769df8724dfdf492ee1aab3c5 F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c -F src/pcache1.c b30b1c35908346ecc43d8d9d17f2ddf6817f8f60 +F src/pcache1.c 2234d84f9c003d800a57f00f8535c91667fa4f6c F src/pragma.c eee3e3161f82a1e06f632a8d2a82b29ba3c45889 F src/prepare.c 33291b83cca285718048d219c67b8298501fa3a5 F src/printf.c 7ffb4ebb8b341f67e049695ba031da717b3d2699 @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P baa8b7830779d5797e210a2e057181413412e152 -R f3c80d376d96bec331a1d34f3039877a +P 31fe1985ad6be5eb04bbe85da378c2385c503ceb +R c9b7e3ab6dcecb0e1f4bc1dec449f209 U drh -Z 3a2862b939ba347e67b7710215b7f1c2 +Z 08d748f35a747f23b9b024d61c3db611 diff --git a/manifest.uuid b/manifest.uuid index 9f563c3ef9..90fe997bca 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -31fe1985ad6be5eb04bbe85da378c2385c503ceb \ No newline at end of file +208825cd830748a2ca456affc57be75bbe618e47 \ No newline at end of file diff --git a/src/pcache1.c b/src/pcache1.c index 42fc8ceba9..c41b49e6c8 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -212,12 +212,14 @@ static void *pcache1Alloc(int nByte){ ** it from sqlite3Malloc instead. */ p = sqlite3Malloc(nByte); +#ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS if( p ){ int sz = sqlite3MallocSize(p); sqlite3_mutex_enter(pcache1.mutex); sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz); sqlite3_mutex_leave(pcache1.mutex); } +#endif sqlite3MemdebugSetType(p, MEMTYPE_PCACHE); } return p; @@ -244,9 +246,11 @@ static int pcache1Free(void *p){ assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) ); sqlite3MemdebugSetType(p, MEMTYPE_HEAP); nFreed = sqlite3MallocSize(p); +#ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS sqlite3_mutex_enter(pcache1.mutex); sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, -nFreed); sqlite3_mutex_leave(pcache1.mutex); +#endif sqlite3_free(p); } return nFreed; From a879342b0ef772b56d74356e64376359b932c5fe Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 7 Jun 2012 07:24:04 +0000 Subject: [PATCH 56/59] Fix a malloc/free mismatch in pager.c (sqlite3_free() called on a buffer allocated by sqlite3DbMalloc()). FossilOrigin-Name: 506008f000ba4af0b35da023b8c52f7a3f5033bd --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/pager.c | 8 ++++---- test/capi3.test | 2 ++ test/capi3c.test | 2 ++ test/permutations.test | 15 +++++++++++++++ 6 files changed, 34 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 2a453a9705..69af0ff4c4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Provide\san\s(undocumented)\scompile-time\soption\sto\sdisable\sthe\spage\scache\noverflow\scounter,\sin\sorder\sto\savoid\sa\smutex. -D 2012-06-07T02:35:29.974 +C Fix\sa\smalloc/free\smismatch\sin\spager.c\s(sqlite3_free()\scalled\son\sa\sbuffer\sallocated\sby\ssqlite3DbMalloc()). +D 2012-06-07T07:24:04.829 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -166,7 +166,7 @@ F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c d7c96b5d140f550f07345870112fae5d7ef99757 F src/os_win.c e3d3d3e26b65a35d4293d753137a58510bd3299b -F src/pager.c a1147e04bb1f64ee31bba8da2351f5e727f62179 +F src/pager.c e381c118b77dc22021a1a59d3fec24815e91df78 F src/pager.h 8b8c9bc065a3c66769df8724dfdf492ee1aab3c5 F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 @@ -314,9 +314,9 @@ F test/boundary4.test 89e02fa66397b8a325d5eb102b5806f961f8ec4b F test/busy.test 76b4887f8b9160ba903c1ac22e8ff406ad6ae2f0 F test/cache.test f64136b0893c293d0b910ed057b3b711249099a7 F test/capi2.test 835d4cee9f542ea50fa8d01f3fe6de80b0627360 -F test/capi3.test 8a33b82c4a2469977aed91b6eb99ae3ca1546444 +F test/capi3.test 56ab450125ead38846cbae7e5b6a216686c3cffa F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4 -F test/capi3c.test 01f197d73f4d4d66316483662f475cab7ab5bd60 +F test/capi3c.test 93d24621c9ff84da9da060f30431e0453db1cdb0 F test/capi3d.test 17b57ca28be3e37e14c2ba8f787d292d84b724a1 F test/capi3e.test f7408dda65c92b9056199fdc180f893015f83dde F test/cast.test 4c275cbdc8202d6f9c54a3596701719868ac7dc3 @@ -642,7 +642,7 @@ F test/pageropt.test 9191867ed19a2b3db6c42d1b36b6fbc657cd1ab0 F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0 F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16 F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 -F test/permutations.test ea7b6948eaa22993fcfa662eb704ce29ddb24b2a +F test/permutations.test 2af90e00cea9e7e7c0a6b16d34727cb5bbae14dd F test/pragma.test cb736bcc75b8b629af21ac0ad83ba1d054a2107b F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947 F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552 @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 31fe1985ad6be5eb04bbe85da378c2385c503ceb -R c9b7e3ab6dcecb0e1f4bc1dec449f209 -U drh -Z 08d748f35a747f23b9b024d61c3db611 +P 208825cd830748a2ca456affc57be75bbe618e47 +R 615bebd2a4edb95abd2eb071a3babed8 +U dan +Z def87c7e203d2567dcd1543b1ddecb6d diff --git a/manifest.uuid b/manifest.uuid index 90fe997bca..716f35ce92 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -208825cd830748a2ca456affc57be75bbe618e47 \ No newline at end of file +506008f000ba4af0b35da023b8c52f7a3f5033bd \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index bd788fb1f3..a3f5d6ec2e 100644 --- a/src/pager.c +++ b/src/pager.c @@ -4376,7 +4376,7 @@ int sqlite3PagerOpen( if( zFilename && zFilename[0] ){ const char *z; nPathname = pVfs->mxPathname+1; - zPathname = sqlite3Malloc(nPathname*2); + zPathname = sqlite3DbMallocRaw(0, nPathname*2); if( zPathname==0 ){ return SQLITE_NOMEM; } @@ -4400,7 +4400,7 @@ int sqlite3PagerOpen( rc = SQLITE_CANTOPEN_BKPT; } if( rc!=SQLITE_OK ){ - sqlite3_free(zPathname); + sqlite3DbFree(0, zPathname); return rc; } } @@ -4430,7 +4430,7 @@ int sqlite3PagerOpen( ); assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) ); if( !pPtr ){ - sqlite3_free(zPathname); + sqlite3DbFree(0, zPathname); return SQLITE_NOMEM; } pPager = (Pager*)(pPtr); @@ -4456,7 +4456,7 @@ int sqlite3PagerOpen( memcpy(&pPager->zWal[nPathname], "-wal\000", 4+1); sqlite3FileSuffix3(pPager->zFilename, pPager->zWal); #endif - sqlite3_free(zPathname); + sqlite3DbFree(0, zPathname); } pPager->pVfs = pVfs; pPager->vfsFlags = vfsFlags; diff --git a/test/capi3.test b/test/capi3.test index b84ddbbf1a..9d7434d25d 100644 --- a/test/capi3.test +++ b/test/capi3.test @@ -783,6 +783,7 @@ foreach {code english} $code2english { } # Test the error message when a "real" out of memory occurs. +if { [permutation] != "nofaultsim" } { ifcapable memdebug { do_test capi3-10-1 { sqlite3 db test.db @@ -821,6 +822,7 @@ ifcapable memdebug { db close sqlite3_memdebug_fail -1 } +} # The following tests - capi3-11.* - test that a COMMIT or ROLLBACK # statement issued while there are still outstanding VMs that are part of diff --git a/test/capi3c.test b/test/capi3c.test index 4092091894..14545c0a68 100644 --- a/test/capi3c.test +++ b/test/capi3c.test @@ -751,6 +751,7 @@ foreach {code english} $code2english { } # Test the error message when a "real" out of memory occurs. +if { [permutation] != "nofaultsim" } { ifcapable memdebug { do_test capi3c-10-1 { sqlite3 db test.db @@ -771,6 +772,7 @@ ifcapable memdebug { db close sqlite3_memdebug_fail -1 } +} # The following tests - capi3c-11.* - test that a COMMIT or ROLLBACK # statement issued while there are still outstanding VMs that are part of diff --git a/test/permutations.test b/test/permutations.test index 3c83c30031..4370d8691d 100644 --- a/test/permutations.test +++ b/test/permutations.test @@ -188,6 +188,21 @@ test_suite "fts3" -prefix "" -description { fts4check.test fts4unicode.test } +test_suite "nofaultsim" -prefix "" -description { + "Very" quick test suite. Runs in less than 5 minutes on a workstation. + This test suite is the same as the "quick" tests, except that some files + that test malloc and IO errors are omitted. +} -files [ + test_set $allquicktests -exclude *malloc* *ioerr* *fault* +] -initialize { + catch {db close} + sqlite3_shutdown + install_malloc_faultsim 0 + sqlite3_initialize + autoinstall_test_functions +} -shutdown { + unset -nocomplain ::G(valgrind) +} lappend ::testsuitelist xxx #------------------------------------------------------------------------- From 25cdf46ae4aea2bf4b7a93052d896cc765bc39db Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 7 Jun 2012 15:53:48 +0000 Subject: [PATCH 57/59] Add the "tokenchars=" and "separators=" options, for customizing the set of characters considered to be token separators, to the unicode61 tokenizer. FossilOrigin-Name: e56fb462aa1f11bb23303ae0dc62815c21e26a52 --- ext/fts3/fts3_tokenizer.c | 28 +++---- ext/fts3/fts3_unicode.c | 162 ++++++++++++++++++++++++++++++++------ manifest | 16 ++-- manifest.uuid | 2 +- test/fts4unicode.test | 88 +++++++++++++++++++++ 5 files changed, 251 insertions(+), 45 deletions(-) diff --git a/ext/fts3/fts3_tokenizer.c b/ext/fts3/fts3_tokenizer.c index f6b044ff6a..4a7a17567a 100644 --- a/ext/fts3/fts3_tokenizer.c +++ b/ext/fts3/fts3_tokenizer.c @@ -209,10 +209,9 @@ int sqlite3Fts3InitTokenizer( /* ** Implementation of a special SQL scalar function for testing tokenizers ** designed to be used in concert with the Tcl testing framework. This -** function must be called with two arguments: +** function must be called with two or more arguments: ** -** SELECT (, ); -** SELECT (, ); +** SELECT (, ..., ); ** ** where is the name passed as the second argument ** to the sqlite3Fts3InitHashTable() function (e.g. 'fts3_tokenizer') @@ -249,27 +248,27 @@ static void testFunc( const char *zInput; int nInput; - const char *zArg = 0; + const char *azArg[64]; const char *zToken; int nToken; int iStart; int iEnd; int iPos; + int i; Tcl_Obj *pRet; - assert( argc==2 || argc==3 ); + if( argc<2 ){ + sqlite3_result_error(context, "insufficient arguments", -1); + return; + } nName = sqlite3_value_bytes(argv[0]); zName = (const char *)sqlite3_value_text(argv[0]); nInput = sqlite3_value_bytes(argv[argc-1]); zInput = (const char *)sqlite3_value_text(argv[argc-1]); - if( argc==3 ){ - zArg = (const char *)sqlite3_value_text(argv[1]); - } - pHash = (Fts3Hash *)sqlite3_user_data(context); p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1); @@ -283,7 +282,11 @@ static void testFunc( pRet = Tcl_NewObj(); Tcl_IncrRefCount(pRet); - if( SQLITE_OK!=p->xCreate(zArg ? 1 : 0, &zArg, &pTokenizer) ){ + for(i=1; ixCreate(argc-2, azArg, &pTokenizer) ){ zErr = "error in xCreate()"; goto finish; } @@ -467,10 +470,7 @@ int sqlite3Fts3InitHashTable( } #ifdef SQLITE_TEST if( SQLITE_OK==rc ){ - rc = sqlite3_create_function(db, zTest, 2, any, p, testFunc, 0, 0); - } - if( SQLITE_OK==rc ){ - rc = sqlite3_create_function(db, zTest, 3, any, p, testFunc, 0, 0); + rc = sqlite3_create_function(db, zTest, -1, any, p, testFunc, 0, 0); } if( SQLITE_OK==rc ){ rc = sqlite3_create_function(db, zTest2, 0, any, pdb, intTestFunc, 0, 0); diff --git a/ext/fts3/fts3_unicode.c b/ext/fts3/fts3_unicode.c index 5dcfb30acc..79941edbb8 100644 --- a/ext/fts3/fts3_unicode.c +++ b/ext/fts3/fts3_unicode.c @@ -83,6 +83,8 @@ typedef struct unicode_cursor unicode_cursor; struct unicode_tokenizer { sqlite3_tokenizer base; int bRemoveDiacritic; + int nException; + int *aiException; }; struct unicode_cursor { @@ -95,6 +97,121 @@ struct unicode_cursor { int nAlloc; /* space allocated at zToken */ }; + +/* +** Destroy a tokenizer allocated by unicodeCreate(). +*/ +static int unicodeDestroy(sqlite3_tokenizer *pTokenizer){ + if( pTokenizer ){ + unicode_tokenizer *p = (unicode_tokenizer *)pTokenizer; + sqlite3_free(p->aiException); + sqlite3_free(p); + } + return SQLITE_OK; +} + +/* +** As part of a tokenchars= or separators= option, the CREATE VIRTUAL TABLE +** statement has specified that the tokenizer for this table shall consider +** all characters in string zIn/nIn to be separators (if bAlnum==0) or +** token characters (if bAlnum==1). +** +** For each codepoint in the zIn/nIn string, this function checks if the +** sqlite3FtsUnicodeIsalnum() function already returns the desired result. +** If so, no action is taken. Otherwise, the codepoint is added to the +** unicode_tokenizer.aiException[] array. For the purposes of tokenization, +** the return value of sqlite3FtsUnicodeIsalnum() is inverted for all +** codepoints in the aiException[] array. +** +** If a standalone diacritic mark (one that sqlite3FtsUnicodeIsdiacritic() +** identifies as a diacritic) occurs in the zIn/nIn string it is ignored. +** It is not possible to change the behaviour of the tokenizer with respect +** to these codepoints. +*/ +static int unicodeAddExceptions( + unicode_tokenizer *p, /* Tokenizer to add exceptions to */ + int bAlnum, /* Replace Isalnum() return value with this */ + const char *zIn, /* Array of characters to make exceptions */ + int nIn /* Length of z in bytes */ +){ + const unsigned char *z = (const unsigned char *)zIn; + const unsigned char *zTerm = &z[nIn]; + int iCode; + int nEntry = 0; + + assert( bAlnum==0 || bAlnum==1 ); + + while( zaiException, (p->nException+nEntry)*sizeof(int)); + if( aNew==0 ) return SQLITE_NOMEM; + nNew = p->nException; + + z = (const unsigned char *)zIn; + while( zi; j--) aNew[j] = aNew[j-1]; + aNew[i] = iCode; + nNew++; + } + } + p->aiException = aNew; + p->nException = nNew; + } + + return SQLITE_OK; +} + +/* +** Return true if the p->aiException[] array contains the value iCode. +*/ +static int unicodeIsException(unicode_tokenizer *p, int iCode){ + if( p->nException>0 ){ + int *a = p->aiException; + int iLo = 0; + int iHi = p->nException-1; + + while( iHi>=iLo ){ + int iTest = (iHi + iLo) / 2; + if( iCode==a[iTest] ){ + return 1; + }else if( iCode>a[iTest] ){ + iLo = iTest+1; + }else{ + iHi = iTest-1; + } + } + } + + return 0; +} + +/* +** Return true if, for the purposes of tokenization, codepoint iCode is +** considered a token character (not a separator). +*/ +static int unicodeIsAlnum(unicode_tokenizer *p, int iCode){ + assert( (sqlite3FtsUnicodeIsalnum(iCode) & 0xFFFFFFFE)==0 ); + return sqlite3FtsUnicodeIsalnum(iCode) ^ unicodeIsException(p, iCode); +} + /* ** Create a new tokenizer instance. */ @@ -105,14 +222,14 @@ static int unicodeCreate( ){ unicode_tokenizer *pNew; /* New tokenizer object */ int i; + int rc = SQLITE_OK; + pNew = (unicode_tokenizer *) sqlite3_malloc(sizeof(unicode_tokenizer)); - if( pNew==NULL ){ - return SQLITE_NOMEM; - } + if( pNew==NULL ) return SQLITE_NOMEM; memset(pNew, 0, sizeof(unicode_tokenizer)); pNew->bRemoveDiacritic = 1; - for(i=0; ibRemoveDiacritic = 0; } + else if( n>=11 && memcmp("tokenchars=", z, 11)==0 ){ + rc = unicodeAddExceptions(pNew, 1, &z[11], n-11); + } + else if( n>=11 && memcmp("separators=", z, 11)==0 ){ + rc = unicodeAddExceptions(pNew, 0, &z[11], n-11); + } else{ /* Unrecognized argument */ - return SQLITE_ERROR; + rc = SQLITE_ERROR; } } - *pp = &pNew->base; - return SQLITE_OK; -} - -/* -** Destroy a tokenizer allocated by unicodeCreate(). -*/ -static int unicodeDestroy(sqlite3_tokenizer *pTokenizer){ - sqlite3_free(pTokenizer); - return SQLITE_OK; + if( rc!=SQLITE_OK ){ + unicodeDestroy((sqlite3_tokenizer *)pNew); + pNew = 0; + } + *pp = (sqlite3_tokenizer *)pNew; + return rc; } /* @@ -190,14 +309,15 @@ static int unicodeClose(sqlite3_tokenizer_cursor *pCursor){ ** have been opened by a prior call to simpleOpen(). */ static int unicodeNext( - sqlite3_tokenizer_cursor *p, /* Cursor returned by simpleOpen */ + sqlite3_tokenizer_cursor *pC, /* Cursor returned by simpleOpen */ const char **paToken, /* OUT: Token text */ int *pnToken, /* OUT: Number of bytes at *paToken */ int *piStart, /* OUT: Starting offset of token */ int *piEnd, /* OUT: Ending offset of token */ int *piPos /* OUT: Position integer of token */ ){ - unicode_cursor *pCsr = (unicode_cursor *)p; + unicode_cursor *pCsr = (unicode_cursor *)pC; + unicode_tokenizer *p = ((unicode_tokenizer *)pCsr->base.pTokenizer); int iCode; char *zOut; const unsigned char *z = &pCsr->aInput[pCsr->iOff]; @@ -210,7 +330,7 @@ static int unicodeNext( ** the input. */ while( z=zTerm ) return SQLITE_DONE; @@ -230,9 +350,7 @@ static int unicodeNext( /* Write the folded case of the last character read to the output */ zEnd = z; - iOut = sqlite3FtsUnicodeFold(iCode, - ((unicode_tokenizer *)pCsr->base.pTokenizer)->bRemoveDiacritic - ); + iOut = sqlite3FtsUnicodeFold(iCode, p->bRemoveDiacritic); if( iOut ){ WRITE_UTF8(zOut, iOut); } @@ -240,7 +358,7 @@ static int unicodeNext( /* If the cursor is not at EOF, read the next character */ if( z>=zTerm ) break; READ_UTF8(z, zTerm, iCode); - }while( sqlite3FtsUnicodeIsalnum(iCode) + }while( unicodeIsAlnum(p, iCode) || sqlite3FtsUnicodeIsdiacritic(iCode) ); diff --git a/manifest b/manifest index 69af0ff4c4..f87782fe92 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\smalloc/free\smismatch\sin\spager.c\s(sqlite3_free()\scalled\son\sa\sbuffer\sallocated\sby\ssqlite3DbMalloc()). -D 2012-06-07T07:24:04.829 +C Add\sthe\s"tokenchars="\sand\s"separators="\soptions,\sfor\scustomizing\sthe\sset\sof\scharacters\sconsidered\sto\sbe\stoken\sseparators,\sto\sthe\sunicode61\stokenizer. +D 2012-06-07T15:53:48.974 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -67,10 +67,10 @@ F ext/fts3/fts3_porter.c a465b49fcb8249a755792f87516eff182efa42b3 F ext/fts3/fts3_snippet.c bf67520ae9d2352a65368ed101729ff701c08808 F ext/fts3/fts3_term.c a521f75132f9a495bdca1bdd45949b3191c52763 F ext/fts3/fts3_test.c 348f7d08cae05285794e23dc4fe8b8fdf66e264a -F ext/fts3/fts3_tokenizer.c 3da7254a9881f7e270ab28e2004e0d22b3212bce +F ext/fts3/fts3_tokenizer.c e94a8b901066031437ccfe4769fc76370257cede F ext/fts3/fts3_tokenizer.h 66dec98e365854b6cd2d54f1a96bb6d428fc5a68 F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004 -F ext/fts3/fts3_unicode.c b9660ab4d7231d92d1853f34dc1a035efb59aa6d +F ext/fts3/fts3_unicode.c 49e36e6ba59f79e6bd6a8bfe434570fe48d20559 F ext/fts3/fts3_unicode2.c 2965d217c37079f1dbbdbd2c58f843be285d73f2 F ext/fts3/fts3_write.c 6a6391d6b01114f885e24e1f66bbc11ffba0e9e2 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 @@ -501,7 +501,7 @@ F test/fts4langid.test 24a6e41063b416bbdf371ff6b4476fa41c194aa7 F test/fts4merge.test c424309743fdd203f8e56a1f1cd7872cd66cc0ee F test/fts4merge2.test 5faa558d1b672f82b847d2a337465fa745e46891 F test/fts4merge3.test aab02a09f50fe6baaddc2e159c3eabc116d45fc7 -F test/fts4unicode.test f394585139ff878f9af0c83791a5f612d45a5984 +F test/fts4unicode.test 247e6c64563b5f930aec0f89a5b01ed6b4b129cd F test/func.test 9809b7622d721904a8cc33c1ffb87f46d506ed01 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 208825cd830748a2ca456affc57be75bbe618e47 -R 615bebd2a4edb95abd2eb071a3babed8 +P 506008f000ba4af0b35da023b8c52f7a3f5033bd +R 90fdd2c25413aca73a47ceb66fb14b8e U dan -Z def87c7e203d2567dcd1543b1ddecb6d +Z 483c809c7f7cc8104f2baffc94efe46a diff --git a/manifest.uuid b/manifest.uuid index 716f35ce92..28edd46d99 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -506008f000ba4af0b35da023b8c52f7a3f5033bd \ No newline at end of file +e56fb462aa1f11bb23303ae0dc62815c21e26a52 \ No newline at end of file diff --git a/test/fts4unicode.test b/test/fts4unicode.test index 5393d0d020..3abceb68b2 100644 --- a/test/fts4unicode.test +++ b/test/fts4unicode.test @@ -31,6 +31,18 @@ proc do_unicode_token_test2 {tn input res} { " [list [list {*}$res]]] } +proc do_unicode_token_test3 {tn args} { + set res [lindex $args end] + set sql "SELECT fts3_tokenizer_test('unicode61'" + foreach a [lrange $args 0 end-1] { + append sql ", '" + append sql [string map {' ''} $a] + append sql "'" + } + append sql ")" + uplevel [list do_execsql_test $tn $sql [list [list {*}$res]]] +} + do_unicode_token_test 1.0 {a B c D} {0 a a 1 b B 2 c c 3 d D} do_unicode_token_test 1.1 {Ä Ö Ü} {0 ä Ä 1 ö Ö 2 ü Ü} do_unicode_token_test 1.2 {xÄx xÖx xÜx} {0 xäx xÄx 1 xöx xÖx 2 xüx xÜx} @@ -236,6 +248,82 @@ do_test 4.3 { } } {} +#------------------------------------------------------------------------- + +do_unicode_token_test3 5.1 {tokenchars=} { + sqlite3_reset sqlite3_column_int +} { + 0 sqlite3 sqlite3 + 1 reset reset + 2 sqlite3 sqlite3 + 3 column column + 4 int int +} + +do_unicode_token_test3 5.2 {tokenchars=_} { + sqlite3_reset sqlite3_column_int +} { + 0 sqlite3_reset sqlite3_reset + 1 sqlite3_column_int sqlite3_column_int +} + +do_unicode_token_test3 5.3 {separators=xyz} { + Laotianxhorseyrunszfast +} { + 0 laotian Laotian + 1 horse horse + 2 runs runs + 3 fast fast +} + +do_unicode_token_test3 5.4 {tokenchars=xyz} { + Laotianxhorseyrunszfast +} { + 0 laotianxhorseyrunszfast Laotianxhorseyrunszfast +} + +do_unicode_token_test3 5.5 {tokenchars=_} {separators=zyx} { + sqlite3_resetxsqlite3_column_intyhonda_phantom +} { + 0 sqlite3_reset sqlite3_reset + 1 sqlite3_column_int sqlite3_column_int + 2 honda_phantom honda_phantom +} + +do_unicode_token_test3 5.6 "separators=\u05D1" "abc\u05D1def" { + 0 abc abc 1 def def +} + +do_unicode_token_test3 5.7 \ + "tokenchars=\u2444\u2445" \ + "separators=\u05D0\u05D1\u05D2" \ + "\u2444fre\u2445sh\u05D0water\u05D2fish.\u2445timer" \ + [list \ + 0 \u2444fre\u2445sh \u2444fre\u2445sh \ + 1 water water \ + 2 fish fish \ + 3 \u2445timer \u2445timer \ + ] + +# Check that it is not possible to add a standalone diacritic codepoint +# to either separators or tokenchars. +do_unicode_token_test3 5.8 "separators=\u0301" \ + "hello\u0301world \u0301helloworld" \ + "0 helloworld hello\u0301world 1 helloworld helloworld" + +do_unicode_token_test3 5.9 "tokenchars=\u0301" \ + "hello\u0301world \u0301helloworld" \ + "0 helloworld hello\u0301world 1 helloworld helloworld" + +do_unicode_token_test3 5.10 "separators=\u0301" \ + "remove_diacritics=0" \ + "hello\u0301world \u0301helloworld" \ + "0 hello\u0301world hello\u0301world 1 helloworld helloworld" + +do_unicode_token_test3 5.11 "tokenchars=\u0301" \ + "remove_diacritics=0" \ + "hello\u0301world \u0301helloworld" \ + "0 hello\u0301world hello\u0301world 1 helloworld helloworld" finish_test From 0b8dcfa2bd6cc199fdf2dd84f8a3048dd4ff3ee7 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 7 Jun 2012 17:16:04 +0000 Subject: [PATCH 58/59] Fix a problem preventing a shared in-memory database from being attached to a read-only connection. FossilOrigin-Name: 7caca1939ce70d5b14ae8ca8ff6afb62f8aff361 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/main.c | 4 +--- test/shared.test | 31 +++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index f87782fe92..7bf666d978 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"tokenchars="\sand\s"separators="\soptions,\sfor\scustomizing\sthe\sset\sof\scharacters\sconsidered\sto\sbe\stoken\sseparators,\sto\sthe\sunicode61\stokenizer. -D 2012-06-07T15:53:48.974 +C Fix\sa\sproblem\spreventing\sa\sshared\sin-memory\sdatabase\sfrom\sbeing\sattached\sto\sa\sread-only\sconnection. +D 2012-06-07T17:16:04.548 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -145,7 +145,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416 F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d -F src/main.c 81e75dd5b37122369927b400b9e1322b73d725a7 +F src/main.c 07e05ba330b5994fa20d3b2e8c1c146133587d68 F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c b3677415e69603d6a0e7c5410a1b3731d55beda1 @@ -689,7 +689,7 @@ F test/selectA.test 06d1032fa9009314c95394f2ca2e60d9f7ae8532 F test/selectB.test 954e4e49cf1f896d61794e440669e03a27ceea25 F test/selectC.test 871fb55d884d3de5943c4057ebd22c2459e71977 F test/server1.test 46803bd3fe8b99b30dbc5ff38ffc756f5c13a118 -F test/shared.test 1acdf03fef43ea13604786424de8c4908170eece +F test/shared.test 1da9dbad400cee0d93f252ccf76e1ae007a63746 F test/shared2.test 03eb4a8d372e290107d34b6ce1809919a698e879 F test/shared3.test ebf77f023f4bdaa8f74f65822b559e86ce5c6257 F test/shared4.test 72d90821e8d2fc918a08f16d32880868d8ee8e9d @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 506008f000ba4af0b35da023b8c52f7a3f5033bd -R 90fdd2c25413aca73a47ceb66fb14b8e +P e56fb462aa1f11bb23303ae0dc62815c21e26a52 +R c4a4e9b18038a632e311884087895d83 U dan -Z 483c809c7f7cc8104f2baffc94efe46a +Z 4c745cb080fa9884975801ad4cff0525 diff --git a/manifest.uuid b/manifest.uuid index 28edd46d99..b58a677494 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e56fb462aa1f11bb23303ae0dc62815c21e26a52 \ No newline at end of file +7caca1939ce70d5b14ae8ca8ff6afb62f8aff361 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 8906592dfc..7ecb4f2617 100644 --- a/src/main.c +++ b/src/main.c @@ -2065,9 +2065,7 @@ int sqlite3ParseUri( { "ro", SQLITE_OPEN_READONLY }, { "rw", SQLITE_OPEN_READWRITE }, { "rwc", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE }, - { "memory", - SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE - | SQLITE_OPEN_MEMORY }, + { "memory", SQLITE_OPEN_MEMORY }, { 0, 0 } }; diff --git a/test/shared.test b/test/shared.test index e297be678e..4eab476582 100644 --- a/test/shared.test +++ b/test/shared.test @@ -1143,6 +1143,37 @@ do_test shared-$av-16.8 { file exists test1.db } {0} ;# Verify that the database is in-memory +# Shared cache on named memory databases attached to readonly connections. +# +do_test shared-$av-16.8.1 { + db1 close + db2 close + + sqlite3 db test1.db + db eval { + CREATE TABLE yy(a, b); + INSERT INTO yy VALUES(77, 88); + } + db close + + sqlite3 db1 test1.db -uri 1 -readonly 1 + sqlite3 db2 test2.db -uri 1 + + db1 eval { + ATTACH 'file:mem?mode=memory&cache=shared' AS shared; + CREATE TABLE shared.xx(a, b); + INSERT INTO xx VALUES(55, 66); + } + db2 eval { + ATTACH 'file:mem?mode=memory&cache=shared' AS shared; + SELECT * FROM xx; + } +} {55 66} + +do_test shared-$av-16.8.2 { db1 eval { SELECT * FROM yy } } {77 88} +do_test shared-$av-16.8.3 { + list [catch {db1 eval { INSERT INTO yy VALUES(1, 2) }} msg] $msg +} {1 {attempt to write a readonly database}} db1 close db2 close From 155812d31809c72a5066212ba93704ad3b204b70 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 7 Jun 2012 17:57:23 +0000 Subject: [PATCH 59/59] Documentation and evidence mark updates. Remove a redundant assert(). FossilOrigin-Name: cfcbf9375fddd0aae0dd17bdc76a710ab77ef667 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/sqlite.h.in | 5 +++-- src/vdbe.c | 1 - test/e_uri.test | 13 ++++++------- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index 7bf666d978..c259a51bfc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\spreventing\sa\sshared\sin-memory\sdatabase\sfrom\sbeing\sattached\sto\sa\sread-only\sconnection. -D 2012-06-07T17:16:04.548 +C Documentation\sand\sevidence\smark\supdates.\s\sRemove\sa\sredundant\sassert(). +D 2012-06-07T17:57:23.952 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -180,7 +180,7 @@ F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1 F src/select.c f6c4833c4d8e94714761d99013d74f381e084f1d F src/shell.c c16f72e34f611f060546709564c121a67cb2b31b -F src/sqlite.h.in f801a04e1ebd1c7f958017661545422ada06b9ce +F src/sqlite.h.in 39f041ce71a0d994e2487014fc9e8721595f5bc0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqliteInt.h 29b5348f0056d9b46d0bb94d4853db21568afde9 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d @@ -239,7 +239,7 @@ F src/update.c d3076782c887c10e882996550345da9c4c9f9dea F src/utf.c 890c67dcfcc7a74623c95baac7535aadfe265e84 F src/util.c 4f6cfad661b2e3454b0cdd5b1b9d39a54942d0e3 F src/vacuum.c 587a52bb8833d7ac15af8916f25437e2575028bd -F src/vdbe.c 76ae5ef2a0227681c3808ce20fe2d8b194bac634 +F src/vdbe.c f5ad3c06dc3fe647097065829c013f3f1b9eadca F src/vdbe.h 18f581cac1f4339ec3299f3e0cc6e11aec654cdb F src/vdbeInt.h 6ff4180a05683566a8835d12f7ec504b22932c82 F src/vdbeapi.c 3662b6a468a2a4605a15dfab313baa6dff81ad91 @@ -389,7 +389,7 @@ F test/e_resolve.test dcce9308fb13b934ce29591105d031d3e14fbba6 F test/e_select.test f5d4b81205701deacfae42051ae200969c41d2c0 F test/e_select2.test 5c3d3da19c7b3e90ae444579db2b70098599ab92 F test/e_update.test 161d5dc6a3ed9dd08f5264d13e20735d7a89f00c -F test/e_uri.test 32b8e0b99a0e215f25996516c64b90c525810d02 +F test/e_uri.test 9e190ca799d9190eec6e43f2aadf1d10c06a57a3 F test/e_vacuum.test 331da289ae186656cf5f2eb27f577a89c0c221af F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea F test/enc2.test 796c59832e2b9a52842f382ffda8f3e989db03ad @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P e56fb462aa1f11bb23303ae0dc62815c21e26a52 -R c4a4e9b18038a632e311884087895d83 -U dan -Z 4c745cb080fa9884975801ad4cff0525 +P 7caca1939ce70d5b14ae8ca8ff6afb62f8aff361 +R 7d7d8055ffab93415bb0679c51b1e783 +U drh +Z 4e021c1abd989c10ef460664cb392a3f diff --git a/manifest.uuid b/manifest.uuid index b58a677494..04a75c4fc1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7caca1939ce70d5b14ae8ca8ff6afb62f8aff361 \ No newline at end of file +cfcbf9375fddd0aae0dd17bdc76a710ab77ef667 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 19ada7d90a..f273937ca5 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -4453,11 +4453,12 @@ SQLITE_EXTERN char *sqlite3_temp_directory; ** ^(If this global variable is made to point to a string which is ** the name of a folder (a.k.a. directory), then all database files ** specified with a relative pathname and created or accessed by -** SQLite when using a built-in [sqlite3_vfs | VFS] will be assumed +** SQLite when using a built-in windows [sqlite3_vfs | VFS] will be assumed ** to be relative to that directory.)^ ^If this variable is a NULL ** pointer, then SQLite assumes that all database files specified ** with a relative pathname are relative to the current directory -** for the process. +** for the process. Only the windows VFS makes use of this global +** variable; it is ignored by the unix VFS. ** ** Changing the value of this variable while a database connection is ** open can result in a corrupt database. diff --git a/src/vdbe.c b/src/vdbe.c index 2432d5b3a7..19c0255b8f 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -4214,7 +4214,6 @@ case OP_RowData: { assert( pC!=0 ); assert( pC->nullRow==0 ); assert( pC->pseudoTableReg==0 ); - assert( !pC->isSorter ); assert( pC->pCursor!=0 ); pCrsr = pC->pCursor; assert( sqlite3BtreeCursorIsValid(pCrsr) ); diff --git a/test/e_uri.test b/test/e_uri.test index 428c266256..8c9949ef33 100644 --- a/test/e_uri.test +++ b/test/e_uri.test @@ -241,9 +241,9 @@ do_test 6.1 { } {no such vfs: nosuchvfs} -# EVIDENCE-OF: R-60479-64270 The mode parameter may be set to either -# "ro", "rw" or "rwc". Attempting to set it to any other value is an -# error +# EVIDENCE-OF: R-44013-13102 The mode parameter may be set to either +# "ro", "rw", "rwc", or "memory". Attempting to set it to any other +# value is an error # sqlite3 db test.db db close @@ -308,10 +308,9 @@ foreach {tn uri read write create} { catch {db close} } -# EVIDENCE-OF: R-56032-32287 If sqlite3_open_v2() is used, it is an -# error to specify a value for the mode parameter that is less -# restrictive than that specified by the flags passed as the third -# parameter. +# EVIDENCE-OF: R-20590-08726 It is an error to specify a value for the +# mode parameter that is less restrictive than that specified by the +# flags passed in the third parameter to sqlite3_open_v2(). # forcedelete test.db sqlite3 db test.db