SQLite

Check-in [cbbaf8e67a]
Login

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

Overview
Comment:Add the test cases for bug [f3e5abed55].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | experimental
Files: files | file ages | folders
SHA1: cbbaf8e67a23dc332ce935bc7234246eacba60bf
User & Date: dan 2010-07-30 10:09:12.000
Context
2010-07-30
14:39
Merge trunk changes into experimental again. (check-in: 87e0f4e184 user: dan tags: experimental)
10:09
Add the test cases for bug [f3e5abed55]. (check-in: cbbaf8e67a user: dan tags: experimental)
10:02
Make sure a connection has an exclusive lock on all database files involved in a multi-file transaction before writing the master-journal pointer into any journal files. Fix for [f3e5abed55]. (check-in: 50c0f2202d user: dan tags: experimental)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbeaux.c.
1798
1799
1800
1801
1802
1803
1804

1805
1806
1807
1808
1809
1810
1811
    for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ 
      Btree *pBt = db->aDb[i].pBt;
      if( pBt ){
        rc = sqlite3BtreeCommitPhaseOne(pBt, zMaster);
      }
    }
    sqlite3OsCloseFree(pMaster);

    if( rc!=SQLITE_OK ){
      sqlite3DbFree(db, zMaster);
      return rc;
    }

    /* Delete the master journal file. This commits the transaction. After
    ** doing this the directory is synced again before any individual







>







1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
    for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ 
      Btree *pBt = db->aDb[i].pBt;
      if( pBt ){
        rc = sqlite3BtreeCommitPhaseOne(pBt, zMaster);
      }
    }
    sqlite3OsCloseFree(pMaster);
    assert( rc!=SQLITE_BUSY );
    if( rc!=SQLITE_OK ){
      sqlite3DbFree(db, zMaster);
      return rc;
    }

    /* Delete the master journal file. This commits the transaction. After
    ** doing this the directory is synced again before any individual
Added test/tkt-f3e5abed55.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# 2010 July 29
#
# 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/malloc_common.tcl

foreach f [glob -nocomplain test.db*mj*] { file delete -force $f }
file delete -force test.db2

do_test tkt-f3e5abed55-1.1 {
  execsql {
    ATTACH 'test.db2' AS aux;
    CREATE TABLE main.t1(a, b);
    CREATE TABLE aux.t2(c, d);
  }
} {}

do_test tkt-f3e5abed55-1.2 {
  glob -nocomplain test.db*mj*
} {}

do_test tkt-f3e5abed55-1.3 {
  sqlite3 db2 test.db
  execsql { BEGIN; SELECT * FROM t1 } db2
} {}

do_test tkt-f3e5abed55-1.4 {
  execsql {
    BEGIN;
      INSERT INTO t1 VALUES(1, 2);
      INSERT INTO t2 VALUES(1, 2);
  }
  catchsql COMMIT
} {1 {database is locked}}

do_test tkt-f3e5abed55-1.5 {
  execsql COMMIT db2
  execsql COMMIT
} {}

do_test tkt-f3e5abed55-1.6 {
  glob -nocomplain test.db*mj*
} {}
foreach f [glob -nocomplain test.db*mj*] { file delete -force $f }
db close
db2 close



# Set up a testvfs so that the next time SQLite tries to delete the
# file "test.db-journal", a snapshot of the current file-system contents
# is taken.
#
testvfs tvfs -default 1
tvfs script xDelete
tvfs filter xDelete
proc xDelete {method file args} {
  if {[file tail $file] == "test.db-journal"} {
    faultsim_save
    tvfs filter {}
  }
  return "SQLITE_OK"
}

sqlite3 db  test.db
sqlite3 db2 test.db
do_test tkt-f3e5abed55-2.1 {
  execsql {
    ATTACH 'test.db2' AS aux;
    BEGIN;
      INSERT INTO t1 VALUES(3, 4);
      INSERT INTO t2 VALUES(3, 4);
  }
} {}
do_test tkt-f3e5abed55-2.2 {
  execsql { BEGIN; SELECT * FROM t1 } db2
} {1 2}
do_test tkt-f3e5abed55-2.3 {
  catchsql COMMIT
} {1 {database is locked}}

do_test tkt-f3e5abed55-2.4 {
  execsql COMMIT db2
  execsql {
    COMMIT;
    SELECT * FROM t1;
    SELECT * FROM t2;
  }
} {1 2 3 4 1 2 3 4}
do_test tkt-f3e5abed55-2.5 {
  db close
  db2 close
  faultsim_restore_and_reopen
  execsql {
    ATTACH 'test.db2' AS aux;
    SELECT * FROM t1;
    SELECT * FROM t2;
  }
} {1 2 3 4 1 2 3 4}


finish_test