]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Merge recent fixes from trunk. Cherrypick of [c43b59dac1], [a221aa82bb], [e1eba1fb09...
authormistachkin <mistachkin@noemail.net>
Wed, 15 Jan 2014 00:24:22 +0000 (00:24 +0000)
committermistachkin <mistachkin@noemail.net>
Wed, 15 Jan 2014 00:24:22 +0000 (00:24 +0000)
FossilOrigin-Name: c697d2f83c2d8ea0a100b84b0debb6a322c3a876

manifest
manifest.uuid
src/main.c
src/os_unix.c
src/os_win.c
src/random.c
src/sqlite.h.in
src/sqliteInt.h
test/win32longpath.test

index 3cc0639fb6cfd590a2faa7e8a6af3a322d6a2a24..969f59f8d9a6b629f958ab9f164e6d98dea58a1f 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Make\ssure\sthe\sWhereLoop.aLTerm[]\sarray\sis\slarge\senough\swhen\sprocessing\nthe\sskip-scan\soptimization.\s\sFix\sfor\sticket\s[520070ec7fbaac].
-D 2013-12-23T15:35:54.039
+C Merge\srecent\sfixes\sfrom\strunk.\s\sCherrypick\sof\s[c43b59dac1],\s[a221aa82bb],\s[e1eba1fb09],\sand\s[1e131094b5].
+D 2014-01-15T00:24:22.522
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -188,7 +188,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
 F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12
 F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b
 F src/loadext.c 867c7b330b740c6c917af9956b13b81d0a048303
-F src/main.c 74bdee8f574588868e67c25cd377df7cba80102e
+F src/main.c 6d0dfffd5d79ebe383308fe7c1c7584f18c687d1
 F src/malloc.c 543a8eb5508eaf4cadf55a9b503379eba2088128
 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
 F src/mem1.c c0c990fcaddff810ea277b4fb5d9138603dd5d4b
@@ -205,8 +205,8 @@ F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30
 F src/os.c b4ad71336fd96f97776f75587cd9e8218288f5be
 F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f
 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
-F src/os_unix.c f076587029285554a3a65d30d0e71d50cd61f41f
-F src/os_win.c 4323dd0bac4f7a7037fc4cf87fb4692d17f0b108
+F src/os_unix.c 35b55bffd4b9de284af62da52775dfc6eff66818
+F src/os_win.c 1b21af72c5fa6f9e519a5fcab33e80d182b1aedb
 F src/pager.c 2aa4444ffe86e9282d03bc349a4a5e49bd77c0e8
 F src/pager.h f094af9f6ececfaa8a1e93876905a4f34233fb0c
 F src/parse.y acee1a9958539e21263362b194594c5255ad2fca
@@ -216,15 +216,15 @@ F src/pcache1.c a467393909a4ed7ca9de066d85ba5c5b04a5be63
 F src/pragma.c 5ab7279d132143feb77f773688a24ab05da75fd7
 F src/prepare.c 359d1a1e9c9bd4488e4dd3a1aaaf2d2ebb9bb768
 F src/printf.c da9119eb31a187a4b99f60aa4a225141c0ebb74b
-F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68
+F src/random.c d10c1f85b6709ca97278428fd5db5bbb9c74eece
 F src/resolve.c 7eda9097b29fcf3d2b42fdc17d1de672134e09b6
 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
 F src/select.c d41381d80a22d3a83352aeca274cccf264ac277a
 F src/shell.c 936a72ff784efff3832cce274a96ed0b036e6758
-F src/sqlite.h.in baf55c31c4e15a4b626acfeaa792f2aaa566657f
+F src/sqlite.h.in c83230953bb3b8cca7aaa75d408a92b4e271a5f4
 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e
 F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
-F src/sqliteInt.h f3a5d663fe9c6c0b2ee7fc2e20a6204eaea5bc7c
+F src/sqliteInt.h 2f72428cff71d2e38ca0bf05116d80f1ef5a9d32
 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
 F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
@@ -1087,7 +1087,7 @@ F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31
 F test/wild001.test bca33f499866f04c24510d74baf1e578d4e44b1c
 F test/win32heap.test ea19770974795cff26e11575e12d422dbd16893c
 F test/win32lock.test 7a6bd73a5dcdee39b5bb93e92395e1773a194361
-F test/win32longpath.test e2aafc07e6990fe86c69be22a3d1a0e210cd329b
+F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d
 F test/without_rowid1.test aaa26da19d543cd8d3d2d0e686dfa255556c15c8
 F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99
 F test/without_rowid3.test eac3d5c8a1924725b58503a368f2cbd24fd6c8a0
@@ -1145,11 +1145,11 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
-P 27392118af4c38c5203a04b8013e1afdb1cebd0d
-Q +46d040591f27be01b1860344f8a268797fe344f4
-R f261db23702291147b2b492eeebe71a1
-T *branch * branch-3.8.2
-T *sym-branch-3.8.2 *
-T -sym-trunk *
-U drh
-Z 4d3959d186d58f8ebce7f5fa0f32ef2d
+P ac5852d6403c9c9628ca0aa7be135c702f000698
+Q +1e131094b522103a0829f72193b067b04e42ce82
+Q +a221aa82bb5496885fd0bf76e4601443799511de
+Q +c43b59dac1fbb67ec3a9d921005543046ad416ce
+Q +e1eba1fb09d7db49d77928bd115b27b8002ae640
+R 9a2615403bfd61ea9575eeff6c57728d
+U mistachkin
+Z 9a636fd2c05ad5aa90446f6df2e80da4
index a68bd007996b31cb146e471fb721f4832fc39bc5..a70c5b7ce1f459d393faf23f6fa6fb449b52b745 100644 (file)
@@ -1 +1 @@
-ac5852d6403c9c9628ca0aa7be135c702f000698
\ No newline at end of file
+c697d2f83c2d8ea0a100b84b0debb6a322c3a876
\ No newline at end of file
index 69a399f3858fc5c20d3053d525bd3cf507324f86..453482a9fd9095a44040e46d751ed4074b29d609 100644 (file)
@@ -3096,7 +3096,7 @@ int sqlite3_test_control(int op, ...){
     ** to the xRandomness method of the default VFS.
     */
     case SQLITE_TESTCTRL_PRNG_RESET: {
-      sqlite3PrngResetState();
+      sqlite3_randomness(0,0);
       break;
     }
 
index ab657dc7bdc35fa19fe278f7152fc966b49ed855..4721ccd1672e353c5bd86142b5e6a247e66db8e6 100644 (file)
@@ -260,6 +260,12 @@ struct unixFile {
 #endif
 };
 
+/* This variable holds the process id (pid) from when the xRandomness()
+** method was called.  If xOpen() is called from a different process id,
+** indicating that a fork() has occurred, the PRNG will be reset.
+*/
+static int randomnessPid = 0;
+
 /*
 ** Allowed values for the unixFile.ctrlFlags bitmask:
 */
@@ -5641,6 +5647,16 @@ static int unixOpen(
        || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL
   );
 
+  /* Detect a pid change and reset the PRNG.  There is a race condition
+  ** here such that two or more threads all trying to open databases at
+  ** the same instant might all reset the PRNG.  But multiple resets
+  ** are harmless.
+  */
+  if( randomnessPid!=getpid() ){
+    randomnessPid = getpid();
+    sqlite3_randomness(0,0);
+  }
+
   memset(p, 0, sizeof(unixFile));
 
   if( eType==SQLITE_OPEN_MAIN_DB ){
@@ -6028,18 +6044,18 @@ static int unixRandomness(sqlite3_vfs *NotUsed, int nBuf, char *zBuf){
   ** tests repeatable.
   */
   memset(zBuf, 0, nBuf);
+  randomnessPid = getpid();  
 #if !defined(SQLITE_TEST)
   {
-    int pid, fd, got;
+    int fd, got;
     fd = robust_open("/dev/urandom", O_RDONLY, 0);
     if( fd<0 ){
       time_t t;
       time(&t);
       memcpy(zBuf, &t, sizeof(t));
-      pid = getpid();
-      memcpy(&zBuf[sizeof(t)], &pid, sizeof(pid));
-      assert( sizeof(t)+sizeof(pid)<=(size_t)nBuf );
-      nBuf = sizeof(t) + sizeof(pid);
+      memcpy(&zBuf[sizeof(t)], &randomnessPid, sizeof(randomnessPid));
+      assert( sizeof(t)+sizeof(randomnessPid)<=(size_t)nBuf );
+      nBuf = sizeof(t) + sizeof(randomnessPid);
     }else{
       do{ got = osRead(fd, zBuf, nBuf); }while( got<0 && errno==EINTR );
       robust_close(0, fd, __LINE__);
index 22052a3fe7c19cb35a0774c81ba001a8031e53ec..4fb4f027030dd116d3f31b8d8596ea6eae4d7de6 100644 (file)
@@ -3119,7 +3119,7 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){
       return SQLITE_OK;
     }
     case SQLITE_FCNTL_VFSNAME: {
-      *(char**)pArg = sqlite3_mprintf("win32");
+      *(char**)pArg = sqlite3_mprintf("%s", pFile->pVfs->zName);
       OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
       return SQLITE_OK;
     }
@@ -3224,7 +3224,7 @@ static void winShmEnterMutex(void){
 static void winShmLeaveMutex(void){
   sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
 }
-#ifdef SQLITE_DEBUG
+#ifndef NDEBUG
 static int winShmMutexHeld(void) {
   return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
 }
index 7afff50885a97edfd1f4f457fdf4f47d9457c115..b82566524c40c6bb87154a259d7c24077d54e394 100644 (file)
@@ -52,6 +52,12 @@ void sqlite3_randomness(int N, void *pBuf){
   sqlite3_mutex_enter(mutex);
 #endif
 
+  if( N<=0 ){
+    wsdPrng.isInit = 0;
+    sqlite3_mutex_leave(mutex);
+    return;
+  }
+
   /* Initialize the state of the random number generator once,
   ** the first time this routine is called.  The seed value does
   ** not need to contain a lot of randomness since we are not
@@ -79,7 +85,8 @@ void sqlite3_randomness(int N, void *pBuf){
     wsdPrng.isInit = 1;
   }
 
-  while( N-- ){
+  assert( N>0 );
+  do{
     wsdPrng.i++;
     t = wsdPrng.s[wsdPrng.i];
     wsdPrng.j += t;
@@ -87,7 +94,7 @@ void sqlite3_randomness(int N, void *pBuf){
     wsdPrng.s[wsdPrng.j] = t;
     t += wsdPrng.s[wsdPrng.i];
     *(zBuf++) = wsdPrng.s[t];
-  }
+  }while( --N );
   sqlite3_mutex_leave(mutex);
 }
 
@@ -116,7 +123,4 @@ void sqlite3PrngRestoreState(void){
     sizeof(sqlite3Prng)
   );
 }
-void sqlite3PrngResetState(void){
-  GLOBAL(struct sqlite3PrngType, sqlite3Prng).isInit = 0;
-}
 #endif /* SQLITE_OMIT_BUILTIN_TEST */
index 98c89da3220830e9695b0036a14962e6427251e5..2fa70bb6dd814851a6a2f3c733fa46eadc949b39 100644 (file)
@@ -2370,11 +2370,13 @@ sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
 ** applications to access the same PRNG for other purposes.
 **
 ** ^A call to this routine stores N bytes of randomness into buffer P.
+** ^If N is less than one, then P can be a NULL pointer.
 **
-** ^The first time this routine is invoked (either internally or by
-** the application) the PRNG is seeded using randomness obtained
-** from the xRandomness method of the default [sqlite3_vfs] object.
-** ^On all subsequent invocations, the pseudo-randomness is generated
+** ^If this routine has not been previously called or if the previous
+** call had N less than one, then the PRNG is seeded using randomness
+** obtained from the xRandomness method of the default [sqlite3_vfs] object.
+** ^If the previous call to this routine had an N of 1 or more then
+** the pseudo-randomness is generated
 ** internally and without recourse to the [sqlite3_vfs] xRandomness
 ** method.
 */
index 8bf05a9c8e2e0483425127c56192c3339ee9b285..26456c3f744e157315d2d4ba8b4050f5de448ee7 100644 (file)
@@ -2957,7 +2957,6 @@ int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
 Vdbe *sqlite3GetVdbe(Parse*);
 void sqlite3PrngSaveState(void);
 void sqlite3PrngRestoreState(void);
-void sqlite3PrngResetState(void);
 void sqlite3RollbackAll(sqlite3*,int);
 void sqlite3CodeVerifySchema(Parse*, int);
 void sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb);
index 0a6a8f98e66bd991742198b759aec4c3c817b728..9e9ed359c634cf91650b497bf30bc825f77a7c48 100644 (file)
@@ -19,11 +19,19 @@ set testdir [file dirname $argv0]
 source $testdir/tester.tcl
 set testprefix win32longpath
 
+do_test 1.0 {
+  file_control_vfsname db
+} win32
+
 db close
 set path [file nativename [get_pwd]]
 sqlite3 db [file join $path test.db] -vfs win32-longpath
 
 do_test 1.1 {
+  file_control_vfsname db
+} win32-longpath
+
+do_test 1.2 {
   db eval {
     BEGIN EXCLUSIVE;
     CREATE TABLE t1(x);
@@ -47,13 +55,13 @@ make_win32_dir $longPath(3)
 
 set fileName $longPath(3)\\test.db
 
-do_test 1.2 {
+do_test 1.3 {
   list [catch {sqlite3 db2 [string range $fileName 4 end]} msg] $msg
 } {1 {unable to open database file}}
 
 sqlite3 db3 $fileName -vfs win32-longpath
 
-do_test 1.3 {
+do_test 1.4 {
   db3 eval {
     BEGIN EXCLUSIVE;
     CREATE TABLE t1(x);
@@ -71,13 +79,13 @@ db3 close
 
 sqlite3 db3 $fileName -vfs win32-longpath
 
-do_test 1.4 {
+do_test 1.5 {
   db3 eval {
     PRAGMA journal_mode = WAL;
   }
 } {wal}
 
-do_test 1.5 {
+do_test 1.6 {
   db3 eval {
     BEGIN EXCLUSIVE;
     INSERT INTO t1 VALUES(9);