/ Check-in [05c9832e]
Login

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

Overview
Comment:Enable the SQLITE_FCNTL_SIZE_HINT on unix even if SQLITE_FCNTL_CHUNK_SIZE has not been set.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 05c9832e5f6eb705f1dce4e65cf4e2d56512ff6b
User & Date: drh 2011-07-25 23:25:47
References
2011-08-29
11:56
Back out [05c9832e5f6eb] since it was causing a performance regression with no obvious benefit. check-in: 639cc85a user: drh tags: trunk
Context
2011-07-28
00:14
Use osStat() instead of stat() consistently in os_unix.c check-in: 9109128c user: drh tags: trunk
2011-07-26
16:03
Prototype change for a new sqlite3_file_control() that will cause the -wal and -shm files to persist after the last database connection closes. check-in: e34c553b user: drh tags: persistent-wal-patch
2011-07-25
23:25
Enable the SQLITE_FCNTL_SIZE_HINT on unix even if SQLITE_FCNTL_CHUNK_SIZE has not been set. check-in: 05c9832e 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.

  3391   3391   ** file-control operation.
  3392   3392   **
  3393   3393   ** If the user has configured a chunk-size for this file, it could be
  3394   3394   ** that the file needs to be extended at this point. Otherwise, the
  3395   3395   ** SQLITE_FCNTL_SIZE_HINT operation is a no-op for Unix.
  3396   3396   */
  3397   3397   static int fcntlSizeHint(unixFile *pFile, i64 nByte){
  3398         -  if( pFile->szChunk ){
         3398  +  { /* preserve indentation of removed "if" */
  3399   3399       i64 nSize;                    /* Required file size */
         3400  +    i64 szChunk;                  /* Chunk size */
  3400   3401       struct stat buf;              /* Used to hold return values of fstat() */
  3401   3402      
  3402   3403       if( osFstat(pFile->h, &buf) ) return SQLITE_IOERR_FSTAT;
  3403   3404   
  3404         -    nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
         3405  +    szChunk = pFile->szChunk;
         3406  +    if( szChunk==0 ){
         3407  +      nSize = nByte;
         3408  +    }else{
         3409  +      nSize = ((nByte+szChunk-1) / szChunk) * szChunk;
         3410  +    }
  3405   3411       if( nSize>(i64)buf.st_size ){
  3406   3412   
  3407   3413   #if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
  3408   3414         /* The code below is handling the return value of osFallocate() 
  3409   3415         ** correctly. posix_fallocate() is defined to "returns zero on success, 
  3410   3416         ** or an error number on  failure". See the manpage for details. */
  3411   3417         int err;

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         -    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         -    }
          238  +    do_test 2.3.$tn.8 { file_page_counts } {2 7 2 7}
   246    239     }
   247    240   
   248    241     # Check that checkpoints block on the correct locks. And respond correctly
   249    242     # if they cannot obtain those locks. There are three locks that a checkpoint
   250    243     # may block on (in the following order):
   251    244     #
   252    245     #   1. The writer lock: FULL and RESTART checkpoints block until any writer
................................................................................
   346    339   
   347    340       do_test 3.$tn.6 { code3 { do_wal_checkpoint db3 } } {0 0 0}
   348    341     }
   349    342   }
   350    343   
   351    344   
   352    345   finish_test
   353         -