]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Cherrypick the [d4f6437f8d] change so that SQLITE_FCNTL_SIZE_HINT is always
authordrh <drh@noemail.net>
Thu, 25 Aug 2011 01:58:17 +0000 (01:58 +0000)
committerdrh <drh@noemail.net>
Thu, 25 Aug 2011 01:58:17 +0000 (01:58 +0000)
honored and never undone by memory pressure on windows.

FossilOrigin-Name: 67ff8d27f6aa6e0beff1f6b72a997b30a9647879

manifest
manifest.uuid
src/os_win.c
test/pager1.test

index e61f98872456dc67c94cdb4086fb325bc36d5025..9bd91f27a19087679921bbe9fd971fa963946e1d 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sthe\ssqlite3_quota_file()\sinterface\sto\stest_quota.c.
-D 2011-08-25T01:42:12.133
+C Cherrypick\sthe\s[d4f6437f8d]\schange\sso\sthat\sSQLITE_FCNTL_SIZE_HINT\sis\salways\nhonored\sand\snever\sundone\sby\smemory\spressure\son\swindows.
+D 2011-08-25T01:58:17.932
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 8c930e7b493d59099ea1304bd0f2aed152eb3315
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -166,7 +166,7 @@ F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9
 F src/os_common.h 65a897143b64667d23ed329a7984b9b405accb58
 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
 F src/os_unix.c 81341980c52a44106b10c1e28a0d5c5247476452
-F src/os_win.c 4eb6fa00ee28f6d7bad0526edcbe5a60d297c67a
+F src/os_win.c 19fa09046f1f86590a188abdcf5630b8fe8279cf
 F src/pager.c 120550e7ef01dafaa2cbb4a0528c0d87c8f12b41
 F src/pager.h 3f8c783de1d4706b40b1ac15b64f5f896bcc78d1
 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58
@@ -609,7 +609,7 @@ F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347
 F test/null.test a8b09b8ed87852742343b33441a9240022108993
 F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394
 F test/oserror.test 3fe52e0bd2891a9bf7cdeb639554992453d46301
-F test/pager1.test 7fc949ccd463dedda729e4d0a1a44e63a3273d39
+F test/pager1.test 70c94c895ffaf4dc34ee4b66e6e4cd713af41edc
 F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1
 F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f
 F test/pagerfault.test 452f2cc23e3bfcfa935f4442aec1da4fe1dc0442
@@ -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 a3220f36c164dd2edf085c07ea08d617d8438812
-R 283add70a055d6da3480c6a93e10a2e4
+P 2b7fe8e5b74c3504edd0e3ff78096e357ee1b47c
+R 36794aff5f4e59db0011ed3cfb68a8bd
 U drh
-Z 490fe9cf524e1e32a7a5a2b19a5723e6
+Z d927f02499c2c18cd5f3df33fe1648f7
index 8912a487086ac156a9a09ffcf62da2946acc61c2..a3911487c6692db21ff57e508f039bda7fb325ca 100644 (file)
@@ -1 +1 @@
-2b7fe8e5b74c3504edd0e3ff78096e357ee1b47c
\ No newline at end of file
+67ff8d27f6aa6e0beff1f6b72a997b30a9647879
\ No newline at end of file
index a006627bf9c48b4efc8c048df33a6dd033c48a60..60b87012442519d6b2c1fd64e89e680eebda682c 100644 (file)
@@ -1351,11 +1351,18 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){
       return SQLITE_OK;
     }
     case SQLITE_FCNTL_SIZE_HINT: {
-      sqlite3_int64 sz = *(sqlite3_int64*)pArg;
-      SimulateIOErrorBenign(1);
-      winTruncate(id, sz);
-      SimulateIOErrorBenign(0);
-      return SQLITE_OK;
+      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;
     }
     case SQLITE_FCNTL_PERSIST_WAL: {
       int bPersist = *(int*)pArg;
index 7fccc5f0c00eec9f26014b3f748bd0f01294dc3b..33e84d4b35b25b3c402e5b587281c8ca435b4016 100644 (file)
@@ -2418,5 +2418,42 @@ do_test pager1-31.1 {
 } {ok}
 }
 
+#-------------------------------------------------------------------------
+# Test that a database file can be "pre-hinted" to a certain size and that
+# subsequent spilling of the pager cache does not result in the database
+# file being shrunk.
+#
+catch {db close}
+forcedelete test.db
+
+do_test pager1-32.1 {
+  sqlite3 db test.db
+  execsql {
+    CREATE TABLE t1(x, y);
+  }
+  db close
+  sqlite3 db test.db
+  execsql {
+    BEGIN;
+    INSERT INTO t1 VALUES(1, randomblob(10000));
+  }
+  file_control_sizehint_test db main 20971520; # 20MB
+  execsql {
+    PRAGMA cache_size = 10;
+    INSERT INTO t1 VALUES(1, randomblob(10000));
+    INSERT INTO t1 VALUES(2, randomblob(10000));
+    INSERT INTO t1 SELECT x+2, randomblob(10000) from t1;
+    INSERT INTO t1 SELECT x+4, randomblob(10000) from t1;
+    INSERT INTO t1 SELECT x+8, randomblob(10000) from t1;
+    INSERT INTO t1 SELECT x+16, randomblob(10000) from t1;
+    SELECT count(*) FROM t1;
+    COMMIT;
+  }
+  db close
+  file size test.db
+} {20971520}
+
+# Cleanup 20MB file left by the previous test.
+forcedelete test.db
 
 finish_test