/ Check-in [55d2e55b]
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:This is a version of the SQLite 3.7.5 release with Apple's changes for MacOS.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | apple-osx
Files: files | file ages | folders
SHA1: 55d2e55b7b0f7851a565e3a982f772afdf8d7a12
User & Date: drh 2011-02-10 01:49:18
Context
2011-04-04
13:11
Merge in the latest changes from trunk. check-in: 6d78a25d user: drh tags: apple-osx
2011-02-10
01:49
This is a version of the SQLite 3.7.5 release with Apple's changes for MacOS. check-in: 55d2e55b user: drh tags: apple-osx
2011-02-01
00:04
Version 3.7.5 check-in: ed759d5a user: drh tags: trunk, release, version-3.7.5
2011-01-27
18:48
Pull in all the changes from trunk up through the version 3.7.5 release candidate 1. check-in: 09d6c91d user: drh tags: apple-osx
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/pager.c.

2473
2474
2475
2476
2477
2478
2479

2480
2481
2482
2483
2484
2485
2486
2487





2488
2489
2490
2491
2492
2493
2494
2495
  assert( pPager->eState!=PAGER_ERROR );
  assert( pPager->eState!=PAGER_READER );
  
  if( isOpen(pPager->fd) 
   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN) 
  ){
    i64 currentSize, newSize;

    assert( pPager->eLock==EXCLUSIVE_LOCK );
    /* TODO: Is it safe to use Pager.dbFileSize here? */
    rc = sqlite3OsFileSize(pPager->fd, &currentSize);
    newSize = pPager->pageSize*(i64)nPage;
    if( rc==SQLITE_OK && currentSize!=newSize ){
      if( currentSize>newSize ){
        rc = sqlite3OsTruncate(pPager->fd, newSize);
      }else{





        rc = sqlite3OsWrite(pPager->fd, "", 1, newSize-1);
      }
      if( rc==SQLITE_OK ){
        pPager->dbFileSize = nPage;
      }
    }
  }
  return rc;







>



|




>
>
>
>
>
|







2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
  assert( pPager->eState!=PAGER_ERROR );
  assert( pPager->eState!=PAGER_READER );
  
  if( isOpen(pPager->fd) 
   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN) 
  ){
    i64 currentSize, newSize;
    int szPage = pPager->pageSize;
    assert( pPager->eLock==EXCLUSIVE_LOCK );
    /* TODO: Is it safe to use Pager.dbFileSize here? */
    rc = sqlite3OsFileSize(pPager->fd, &currentSize);
    newSize = szPage*(i64)nPage;
    if( rc==SQLITE_OK && currentSize!=newSize ){
      if( currentSize>newSize ){
        rc = sqlite3OsTruncate(pPager->fd, newSize);
      }else{
        char *pTmp = pPager->pTmpSpace;
        memset(pTmp, 0, szPage);
        testcase( (newSize-szPage) <  currentSize );
        testcase( (newSize-szPage) == currentSize );
        testcase( (newSize-szPage) >  currentSize );
        rc = sqlite3OsWrite(pPager->fd, pTmp, szPage, newSize-szPage);
      }
      if( rc==SQLITE_OK ){
        pPager->dbFileSize = nPage;
      }
    }
  }
  return rc;

Added test/pagerfault3.test.































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# 2011 January 28
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/lock_common.tcl
source $testdir/malloc_common.tcl

if {[permutation] == "inmemory_journal"} {
  finish_test
  return
}

# Create a database with page-size 2048 bytes that uses 2 pages. Populate
# it so that if the page-size is changed to 1024 bytes and the db vacuumed, 
# the new db size is 3 pages.
#
do_test pagerfault3-pre1 {
  execsql {
    PRAGMA page_size = 2048;
    CREATE TABLE t1(x);
    INSERT INTO t1 VALUES(randomblob(1200));
    PRAGMA page_count;
  }
} {2}
do_test pagerfault3-pre2 {
  faultsim_save_and_close
  faultsim_restore_and_reopen
  execsql { 
    PRAGMA page_size = 1024;
    VACUUM;
    PRAGMA page_count;
  }
} {3}

# Now do the page-size change and VACUUM with IO error injection. When
# an IO error is injected into the final xSync() of the commit, the pager
# will have to extend the db file from 3072 to 4096 byts when rolling
# back the hot-journal file. This is a special case in pager_truncate().
#
do_faultsim_test pagerfault3-1 -faults ioerr-transient -prep {
  faultsim_restore_and_reopen
} -body {
  execsql { 
    PRAGMA page_size = 1024;
    VACUUM;
  }
} -test {
  faultsim_test_result {0 {}} 
  faultsim_integrity_check
}

finish_test