/ Check-in [639cc85a]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Back out [05c9832e5f6eb] since it was causing a performance regression with no obvious benefit.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 639cc85a911454bffdcccb33f2976c683953ae64
User & Date: drh 2011-08-29 11:56:14
Context
2011-08-29
18:24
Fix a broken assert() statement in select.c. check-in: ad78ef2b user: dan tags: trunk
11:56
Back out [05c9832e5f6eb] since it was causing a performance regression with no obvious benefit. check-in: 639cc85a user: drh tags: trunk
03:08
Merge performance enhancements into trunk. check-in: 5a00d24b user: drh tags: trunk
2011-07-23
13:54
Merge the winAccess retry logic from the anti-antivirus branch into the trunk. check-in: 08d0e879 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

  3441   3441   /* 
  3442   3442   ** This function is called to handle the SQLITE_FCNTL_SIZE_HINT 
  3443   3443   ** file-control operation.  Enlarge the database to nBytes in size
  3444   3444   ** (rounded up to the next chunk-size).  If the database is already
  3445   3445   ** nBytes or larger, this routine is a no-op.
  3446   3446   */
  3447   3447   static int fcntlSizeHint(unixFile *pFile, i64 nByte){
  3448         -  { /* preserve indentation of removed "if" */
         3448  +  if( pFile->szChunk ){
  3449   3449       i64 nSize;                    /* Required file size */
  3450         -    i64 szChunk;                  /* Chunk size */
  3451   3450       struct stat buf;              /* Used to hold return values of fstat() */
  3452   3451      
  3453   3452       if( osFstat(pFile->h, &buf) ) return SQLITE_IOERR_FSTAT;
  3454   3453   
  3455         -    szChunk = pFile->szChunk;
  3456         -    if( szChunk==0 ){
  3457         -      nSize = nByte;
  3458         -    }else{
  3459         -      nSize = ((nByte+szChunk-1) / szChunk) * szChunk;
  3460         -    }
         3454  +    nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
  3461   3455       if( nSize>(i64)buf.st_size ){
  3462   3456   
  3463   3457   #if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
  3464   3458         /* The code below is handling the return value of osFallocate() 
  3465   3459         ** correctly. posix_fallocate() is defined to "returns zero on success, 
  3466   3460         ** or an error number on  failure". See the manpage for details. */
  3467   3461         int err;

Changes to test/pager1.test.

  2433   2433     }
  2434   2434     db close
  2435   2435     sqlite3 db test.db
  2436   2436     execsql {
  2437   2437       BEGIN;
  2438   2438       INSERT INTO t1 VALUES(1, randomblob(10000));
  2439   2439     }
         2440  +  file_control_chunksize_test db main 1024
  2440   2441     file_control_sizehint_test db main 20971520; # 20MB
  2441   2442     execsql {
  2442   2443       PRAGMA cache_size = 10;
  2443   2444       INSERT INTO t1 VALUES(1, randomblob(10000));
  2444   2445       INSERT INTO t1 VALUES(2, randomblob(10000));
  2445   2446       INSERT INTO t1 SELECT x+2, randomblob(10000) from t1;
  2446   2447       INSERT INTO t1 SELECT x+4, randomblob(10000) from t1;

Changes to test/wal5.test.

   231    231       } {}
   232    232       do_test 2.3.$tn.2 { file_page_counts } {1 5 1 5}
   233    233       do_test 2.3.$tn.3 { sql2 { BEGIN; SELECT * FROM t1 } } {1 2}
   234    234       do_test 2.3.$tn.4 { sql1 { INSERT INTO t1 VALUES(3, 4) } } {}
   235    235       do_test 2.3.$tn.5 { sql1 { INSERT INTO t2 VALUES(3, 4) } } {}
   236    236       do_test 2.3.$tn.6 { file_page_counts } {1 7 1 7}
   237    237       do_test 2.3.$tn.7 { code1 { do_wal_checkpoint db -mode full } } {1 7 5}
   238         -    do_test 2.3.$tn.8 { file_page_counts } {2 7 2 7}
          238  +    if {$tcl_platform(platform) == "windows"} {
          239  +        # on unix, the size_hint is a no-op if no chunk size is set.
          240  +        # the windows implementation does not have a similar check,
          241  +        # and because of this, the db file size has an extra page.
          242  +        do_test 2.3.$tn.8 { file_page_counts } {2 7 2 7}
          243  +    } {
          244  +        do_test 2.3.$tn.8 { file_page_counts } {1 7 2 7}
          245  +    }
   239    246     }
   240    247   
   241    248     # Check that checkpoints block on the correct locks. And respond correctly
   242    249     # if they cannot obtain those locks. There are three locks that a checkpoint
   243    250     # may block on (in the following order):
   244    251     #
   245    252     #   1. The writer lock: FULL and RESTART checkpoints block until any writer
................................................................................
   339    346   
   340    347       do_test 3.$tn.6 { code3 { do_wal_checkpoint db3 } } {0 0 0}
   341    348     }
   342    349   }
   343    350   
   344    351   
   345    352   finish_test
          353  +