SQLite

Check-in [639cc85a91]
Login

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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 639cc85a911454bffdcccb33f2976c683953ae64
User & Date: drh 2011-08-29 11:56:14.294
Context
2011-08-29
18:24
Fix a broken assert() statement in select.c. (check-in: ad78ef2b3a user: dan tags: trunk)
11:56
Back out [05c9832e5f6eb] since it was causing a performance regression with no obvious benefit. (check-in: 639cc85a91 user: drh tags: trunk)
03:08
Merge performance enhancements into trunk. (check-in: 5a00d24b27 user: drh tags: trunk)
2011-07-23
13:54
Merge the winAccess retry logic from the anti-antivirus branch into the trunk. (check-in: 08d0e8799e user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/os_unix.c.
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
/* 
** This function is called to handle the SQLITE_FCNTL_SIZE_HINT 
** file-control operation.  Enlarge the database to nBytes in size
** (rounded up to the next chunk-size).  If the database is already
** nBytes or larger, this routine is a no-op.
*/
static int fcntlSizeHint(unixFile *pFile, i64 nByte){
  { /* preserve indentation of removed "if" */
    i64 nSize;                    /* Required file size */
    i64 szChunk;                  /* Chunk size */
    struct stat buf;              /* Used to hold return values of fstat() */
   
    if( osFstat(pFile->h, &buf) ) return SQLITE_IOERR_FSTAT;

    szChunk = pFile->szChunk;
    if( szChunk==0 ){
      nSize = nByte;
    }else{
      nSize = ((nByte+szChunk-1) / szChunk) * szChunk;
    }
    if( nSize>(i64)buf.st_size ){

#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
      /* The code below is handling the return value of osFallocate() 
      ** correctly. posix_fallocate() is defined to "returns zero on success, 
      ** or an error number on  failure". See the manpage for details. */
      int err;







|

<




|
<
<
<
<
<







3441
3442
3443
3444
3445
3446
3447
3448
3449

3450
3451
3452
3453
3454





3455
3456
3457
3458
3459
3460
3461
/* 
** This function is called to handle the SQLITE_FCNTL_SIZE_HINT 
** file-control operation.  Enlarge the database to nBytes in size
** (rounded up to the next chunk-size).  If the database is already
** nBytes or larger, this routine is a no-op.
*/
static int fcntlSizeHint(unixFile *pFile, i64 nByte){
  if( pFile->szChunk ){
    i64 nSize;                    /* Required file size */

    struct stat buf;              /* Used to hold return values of fstat() */
   
    if( osFstat(pFile->h, &buf) ) return SQLITE_IOERR_FSTAT;

    nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;





    if( nSize>(i64)buf.st_size ){

#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
      /* The code below is handling the return value of osFallocate() 
      ** correctly. posix_fallocate() is defined to "returns zero on success, 
      ** or an error number on  failure". See the manpage for details. */
      int err;
Changes to test/pager1.test.
2433
2434
2435
2436
2437
2438
2439

2440
2441
2442
2443
2444
2445
2446
  }
  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;







>







2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
  }
  db close
  sqlite3 db test.db
  execsql {
    BEGIN;
    INSERT INTO t1 VALUES(1, randomblob(10000));
  }
  file_control_chunksize_test db main 1024
  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;
Changes to test/wal5.test.
231
232
233
234
235
236
237




238



239
240
241
242
243
244
245
    } {}
    do_test 2.3.$tn.2 { file_page_counts } {1 5 1 5}
    do_test 2.3.$tn.3 { sql2 { BEGIN; SELECT * FROM t1 } } {1 2}
    do_test 2.3.$tn.4 { sql1 { INSERT INTO t1 VALUES(3, 4) } } {}
    do_test 2.3.$tn.5 { sql1 { INSERT INTO t2 VALUES(3, 4) } } {}
    do_test 2.3.$tn.6 { file_page_counts } {1 7 1 7}
    do_test 2.3.$tn.7 { code1 { do_wal_checkpoint db -mode full } } {1 7 5}




    do_test 2.3.$tn.8 { file_page_counts } {2 7 2 7}



  }

  # Check that checkpoints block on the correct locks. And respond correctly
  # if they cannot obtain those locks. There are three locks that a checkpoint
  # may block on (in the following order):
  #
  #   1. The writer lock: FULL and RESTART checkpoints block until any writer







>
>
>
>
|
>
>
>







231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
    } {}
    do_test 2.3.$tn.2 { file_page_counts } {1 5 1 5}
    do_test 2.3.$tn.3 { sql2 { BEGIN; SELECT * FROM t1 } } {1 2}
    do_test 2.3.$tn.4 { sql1 { INSERT INTO t1 VALUES(3, 4) } } {}
    do_test 2.3.$tn.5 { sql1 { INSERT INTO t2 VALUES(3, 4) } } {}
    do_test 2.3.$tn.6 { file_page_counts } {1 7 1 7}
    do_test 2.3.$tn.7 { code1 { do_wal_checkpoint db -mode full } } {1 7 5}
    if {$tcl_platform(platform) == "windows"} {
        # on unix, the size_hint is a no-op if no chunk size is set.
        # the windows implementation does not have a similar check,
        # and because of this, the db file size has an extra page.
        do_test 2.3.$tn.8 { file_page_counts } {2 7 2 7}
    } {
        do_test 2.3.$tn.8 { file_page_counts } {1 7 2 7}
    }
  }

  # Check that checkpoints block on the correct locks. And respond correctly
  # if they cannot obtain those locks. There are three locks that a checkpoint
  # may block on (in the following order):
  #
  #   1. The writer lock: FULL and RESTART checkpoints block until any writer
339
340
341
342
343
344
345


    do_test 3.$tn.6 { code3 { do_wal_checkpoint db3 } } {0 0 0}
  }
}


finish_test








>
346
347
348
349
350
351
352
353

    do_test 3.$tn.6 { code3 { do_wal_checkpoint db3 } } {0 0 0}
  }
}


finish_test