/ Check-in [67ff8d27]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Cherrypick the [d4f6437f8d] change so that SQLITE_FCNTL_SIZE_HINT is always honored and never undone by memory pressure on windows.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 67ff8d27f6aa6e0beff1f6b72a997b30a9647879
User & Date: drh 2011-08-25 01:58:17
Context
2011-08-25
03:38
Fix an file separator character issue with test_quota.c that was causing it to fail on windows. check-in: ddb8d3e8 user: drh tags: trunk
01:58
Cherrypick the [d4f6437f8d] change so that SQLITE_FCNTL_SIZE_HINT is always honored and never undone by memory pressure on windows. check-in: 67ff8d27 user: drh tags: trunk
01:42
Add the sqlite3_quota_file() interface to test_quota.c. check-in: 2b7fe8e5 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

  1347   1347         return SQLITE_OK;
  1348   1348       }
  1349   1349       case SQLITE_FCNTL_CHUNK_SIZE: {
  1350   1350         pFile->szChunk = *(int *)pArg;
  1351   1351         return SQLITE_OK;
  1352   1352       }
  1353   1353       case SQLITE_FCNTL_SIZE_HINT: {
  1354         -      sqlite3_int64 sz = *(sqlite3_int64*)pArg;
  1355         -      SimulateIOErrorBenign(1);
  1356         -      winTruncate(id, sz);
  1357         -      SimulateIOErrorBenign(0);
  1358         -      return SQLITE_OK;
         1354  +      winFile *pFile = (winFile*)id;
         1355  +      sqlite3_int64 oldSz;
         1356  +      int rc = winFileSize(id, &oldSz);
         1357  +      if( rc==SQLITE_OK ){
         1358  +        sqlite3_int64 newSz = *(sqlite3_int64*)pArg;
         1359  +        if( newSz>oldSz ){
         1360  +          SimulateIOErrorBenign(1);
         1361  +          rc = winTruncate(id, newSz);
         1362  +          SimulateIOErrorBenign(0);
         1363  +        }
         1364  +      }
         1365  +      return rc;
  1359   1366       }
  1360   1367       case SQLITE_FCNTL_PERSIST_WAL: {
  1361   1368         int bPersist = *(int*)pArg;
  1362   1369         if( bPersist<0 ){
  1363   1370           *(int*)pArg = pFile->bPersistWal;
  1364   1371         }else{
  1365   1372           pFile->bPersistWal = bPersist!=0;

Changes to test/pager1.test.

  2414   2414     
  2415   2415     hexio_write test.db2-journal 24 00000000
  2416   2416     sqlite3 db2 test.db2
  2417   2417     execsql { PRAGMA integrity_check } db2
  2418   2418   } {ok}
  2419   2419   }
  2420   2420   
         2421  +#-------------------------------------------------------------------------
         2422  +# Test that a database file can be "pre-hinted" to a certain size and that
         2423  +# subsequent spilling of the pager cache does not result in the database
         2424  +# file being shrunk.
         2425  +#
         2426  +catch {db close}
         2427  +forcedelete test.db
         2428  +
         2429  +do_test pager1-32.1 {
         2430  +  sqlite3 db test.db
         2431  +  execsql {
         2432  +    CREATE TABLE t1(x, y);
         2433  +  }
         2434  +  db close
         2435  +  sqlite3 db test.db
         2436  +  execsql {
         2437  +    BEGIN;
         2438  +    INSERT INTO t1 VALUES(1, randomblob(10000));
         2439  +  }
         2440  +  file_control_sizehint_test db main 20971520; # 20MB
         2441  +  execsql {
         2442  +    PRAGMA cache_size = 10;
         2443  +    INSERT INTO t1 VALUES(1, randomblob(10000));
         2444  +    INSERT INTO t1 VALUES(2, randomblob(10000));
         2445  +    INSERT INTO t1 SELECT x+2, randomblob(10000) from t1;
         2446  +    INSERT INTO t1 SELECT x+4, randomblob(10000) from t1;
         2447  +    INSERT INTO t1 SELECT x+8, randomblob(10000) from t1;
         2448  +    INSERT INTO t1 SELECT x+16, randomblob(10000) from t1;
         2449  +    SELECT count(*) FROM t1;
         2450  +    COMMIT;
         2451  +  }
         2452  +  db close
         2453  +  file size test.db
         2454  +} {20971520}
         2455  +
         2456  +# Cleanup 20MB file left by the previous test.
         2457  +forcedelete test.db
  2421   2458   
  2422   2459   finish_test