Cherrypick the [d4f6437f8d] change so that SQLITE_FCNTL_SIZE_HINT is always

honored and never undone by memory pressure on windows.

FossilOrigin-Name: 67ff8d27f6aa6e0beff1f6b72a997b30a9647879
This commit is contained in:
drh 2011-08-25 01:58:17 +00:00
parent b6020c4eef
commit 31e8097658
4 changed files with 57 additions and 13 deletions

View File

@ -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

View File

@ -1 +1 @@
2b7fe8e5b74c3504edd0e3ff78096e357ee1b47c
67ff8d27f6aa6e0beff1f6b72a997b30a9647879

View 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;

View 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