]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Make sure SQLITE_FCNTL_SIZE_HINT a no-op if the chunk size is not greater than zero.
authormistachkin <mistachkin@noemail.net>
Tue, 30 Aug 2011 01:23:34 +0000 (01:23 +0000)
committermistachkin <mistachkin@noemail.net>
Tue, 30 Aug 2011 01:23:34 +0000 (01:23 +0000)
FossilOrigin-Name: 88b763e8d73fafa1538b08af28b1c8b723b39c61

manifest
manifest.uuid
src/os_unix.c
src/os_win.c
test/wal5.test

index fc14f9ba216c51668be04a41c520f47d3d6235b7..7e13b09011fe7362d53fdbc7b649094d847d714d 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\stotal\sunimportant\sfile\sdescriptor\sleak\sin\slemon.\s\sThis\sis\sto\ssilence\nwarning\smessages.
-D 2011-08-30T00:58:58.556
+C Make\ssure\sSQLITE_FCNTL_SIZE_HINT\sa\sno-op\sif\sthe\schunk\ssize\sis\snot\sgreater\sthan\szero.
+D 2011-08-30T01:23:34.101
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 8c930e7b493d59099ea1304bd0f2aed152eb3315
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -165,8 +165,8 @@ F src/os.c fcc717427a80b2ed225373f07b642dc1aad7490b
 F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9
 F src/os_common.h 65a897143b64667d23ed329a7984b9b405accb58
 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
-F src/os_unix.c 014cd466edc2b73e417f382c3213b6c72bc35280
-F src/os_win.c 86bcb5bd0386c761c764c3383879469346da3a14
+F src/os_unix.c ae82cf32c497d9a3a0f147de1b7219b636db4f53
+F src/os_win.c 45de13c6c3501cfd6469b2b34149b823060e39f4
 F src/pager.c 817f7f7140c9fa2641f28e6330e924708ddd870d
 F src/pager.h 2bab1b2ea4eac58663b5833e3522e36b5ff63447
 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58
@@ -887,7 +887,7 @@ F test/wal.test e11da8d5ea8a38a247339455098357e9adf63d76
 F test/wal2.test ad6412596815f553cd30f271d291ab003092bc7e
 F test/wal3.test 18da4e65c30c43c646ad40e145e9a074e4062fc9
 F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c
-F test/wal5.test f06a0427e06db00347e32eb9fa99d6a5c0f2d088
+F test/wal5.test 1bbfaa316dc2a1d0d1fac3f4500c38a90055a41b
 F test/wal6.test 2e3bc767d9c2ce35c47106148d43fcbd072a93b3
 F test/wal7.test 2ae8f427d240099cc4b2dfef63cff44e2a68a1bd
 F test/wal_common.tcl a98f17fba96206122eff624db0ab13ec377be4fe
@@ -961,7 +961,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5
 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
 F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2
-P 49cd60e38bd8df9d736ced95e0ace6efea95ca7d
-R 864960f9c27e1685a9edda4031c320e3
-U drh
-Z 0c80443f2de345db03862d58a6ec74c5
+P e95cf2c576dda656c0f31eeec3d98e911b9003a1
+R 23e2e1649d860cacfc7d885e0481975c
+U mistachkin
+Z 106f8d2e0fe01f69aa7179a809ac1874
index 72809be723b7fa803625070c922ab9d511ac043f..4613466421d6e19d4ee884eb6d82017ed1e33faa 100644 (file)
@@ -1 +1 @@
-e95cf2c576dda656c0f31eeec3d98e911b9003a1
\ No newline at end of file
+88b763e8d73fafa1538b08af28b1c8b723b39c61
\ No newline at end of file
index 8abef8de8b6cbe033ed8769b6157dc2f4b5bbe73..f273d04cb68aa3960c26bad165e47ab3ed2d4e23 100644 (file)
@@ -3445,7 +3445,7 @@ static int proxyFileControl(sqlite3_file*,int,void*);
 ** nBytes or larger, this routine is a no-op.
 */
 static int fcntlSizeHint(unixFile *pFile, i64 nByte){
-  if( pFile->szChunk ){
+  if( pFile->szChunk>0 ){
     i64 nSize;                    /* Required file size */
     struct stat buf;              /* Used to hold return values of fstat() */
    
index 02a7a0c6222f43103bbe8f686d2b207bf11cbd3c..2441398945e0dd5b26fc8df76b595b6c7bdcfb93 100644 (file)
@@ -1216,7 +1216,7 @@ static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
   ** actual file size after the operation may be larger than the requested
   ** size).
   */
-  if( pFile->szChunk ){
+  if( pFile->szChunk>0 ){
     nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk;
   }
 
@@ -1603,18 +1603,21 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){
       return SQLITE_OK;
     }
     case SQLITE_FCNTL_SIZE_HINT: {
-      winFile *pFile = (winFile*)id;
-      sqlite3_int64 oldSz;
-      int rc = winFileSize(id, &oldSz);
-      if( rc==SQLITE_OK ){
-        sqlite3_int64 newSz = *(sqlite3_int64*)pArg;
-        if( newSz>oldSz ){
-          SimulateIOErrorBenign(1);
-          rc = winTruncate(id, newSz);
-          SimulateIOErrorBenign(0);
+      if( pFile->szChunk>0 ){
+        winFile *pFile = (winFile*)id;
+        sqlite3_int64 oldSz;
+        int rc = winFileSize(id, &oldSz);
+        if( rc==SQLITE_OK ){
+          sqlite3_int64 newSz = *(sqlite3_int64*)pArg;
+          if( newSz>oldSz ){
+            SimulateIOErrorBenign(1);
+            rc = winTruncate(id, newSz);
+            SimulateIOErrorBenign(0);
+          }
         }
+        return rc;
       }
-      return rc;
+      return SQLITE_OK;
     }
     case SQLITE_FCNTL_PERSIST_WAL: {
       int bPersist = *(int*)pArg;
index 0c700dfc50595e458a584c0a81464e5be8758abc..ad6bcfc7d83844f1341db75e5ff78cb8912087ff 100644 (file)
@@ -235,14 +235,7 @@ foreach {testprefix do_wal_checkpoint} {
     do_test 2.3.$tn.5 { sql1 { INSERT INTO t2 VALUES(3, 4) } } {}
     do_test 2.3.$tn.6 { file_page_counts } {1 7 1 7}
     do_test 2.3.$tn.7 { code1 { do_wal_checkpoint db -mode full } } {1 7 5}
-    if {$tcl_platform(platform) == "windows"} {
-        # on unix, the size_hint is a no-op if no chunk size is set.
-        # the windows implementation does not have a similar check,
-        # and because of this, the db file size has an extra page.
-        do_test 2.3.$tn.8 { file_page_counts } {2 7 2 7}
-    } {
-        do_test 2.3.$tn.8 { file_page_counts } {1 7 2 7}
-    }
+    do_test 2.3.$tn.8 { file_page_counts } {1 7 2 7}
   }
 
   # Check that checkpoints block on the correct locks. And respond correctly