/ Check-in [59be370e]
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:Fix jrnlmode2.test so that it works on systems where UNDELETABLE_WHEN_OPEN is defined.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | experimental
Files: files | file ages | folders
SHA1: 59be370e52ec814c45efa6cbac45b6df94661b54
User & Date: dan 2010-06-21 05:40:49
Context
2010-06-21
06:00
Merge latest trunk change. check-in: f6d26e07 user: dan tags: experimental
05:40
Fix jrnlmode2.test so that it works on systems where UNDELETABLE_WHEN_OPEN is defined. check-in: 59be370e user: dan tags: experimental
2010-06-19
19:06
Fix an assert() failure that could occur if compiling with OMIT_SHARED_CACHE. check-in: 3e76a9f2 user: dan tags: experimental
Changes
Hide Diffs Unified Diffs Show Whitespace Changes Patch

Changes to test/jrnlmode2.test.

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
..
42
43
44
45
46
47
48


49
50
51
52
53
54
55
..
83
84
85
86
87
88
89

90
91
92
93
94
95
96
97
98
99
#
#    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.
#
#***********************************************************************
#
# $Id: jrnlmode2.test,v 1.6 2009/06/05 17:09:12 drh Exp $

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

ifcapable {!pager_pragmas} {
  finish_test
  return
}

#-------------------------------------------------------------------------
# Test overview:

#
#   jrnlmode2-1.*: Demonstrate bug #3745












#   jrnlmode2-2.*: Demonstrate bug #3751










#

do_test jrnlmode2-1.1 {
  execsql {
    PRAGMA journal_mode = persist;
    CREATE TABLE t1(a, b);
    INSERT INTO t1 VALUES(1, 2);
................................................................................
  sqlite3 db2 test.db
  execsql { SELECT * FROM t1 } db2
} {1 2}

do_test jrnlmode2-1.4 {
  execsql {
    INSERT INTO t1 VALUES(3, 4);


    BEGIN;
    SELECT * FROM t1;
  }
  execsql { PRAGMA lock_status }
} {main shared temp closed}

do_test jrnlmode2-1.5 {
................................................................................

do_test jrnlmode2-2.4 {
  sqlite3 db2 test.db -readonly 1
  catchsql { SELECT * FROM t1 } db2
} {0 {1 2 3 4 5 6}}

do_test jrnlmode2-2.5 {

  file delete test.db-journal
} {}

do_test jrnlmode2-2.6 {
  sqlite3 db2 test.db -readonly 1
  catchsql { SELECT * FROM t1 } db2
} {0 {1 2 3 4 5 6}}

catch { db2 close }
finish_test







<










|
>

|
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>







 







>
>







 







>


<







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
..
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
...
107
108
109
110
111
112
113
114
115
116

117
118
119
120
121
122
123
#
#    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

ifcapable {!pager_pragmas} {
  finish_test
  return
}

#-------------------------------------------------------------------------
# The tests in this file check that the following two bugs (both now fixed)
# do not reappear.
#
# jrnlmode2-1.*: Demonstrate bug #3745:
#
#     In persistent journal mode, if:
#
#       * There is a persistent journal in the file-system, AND
#       * there exists a connection with a shared lock on the db file, 
#
#     then a second connection cannot open a read-transaction on the database.
#     The reason is because while determining that the persistent-journal is
#     not a hot-journal, SQLite currently grabs an exclusive lock on the
#     database file. If this fails because another connection has a shared
#     lock, then SQLITE_BUSY is returned to the user.  
#
# jrnlmode2-2.*: Demonstrate bug #3751:
#
#     If a connection is opened in SQLITE_OPEN_READONLY mode, the underlying
#     unix file descriptor on the database file is opened in O_RDONLY mode.
#
#     When SQLite queries the database file for the schema in order to compile
#     the SELECT statement, it sees the empty journal in the file system, it
#     attempts to obtain an exclusive lock on the database file (this is a
#     bug). The attempt to obtain an exclusive (write) lock on a read-only file
#     fails at the OS level. Under unix, fcntl() reports an EBADF - "Bad file
#     descriptor" - error. 
#

do_test jrnlmode2-1.1 {
  execsql {
    PRAGMA journal_mode = persist;
    CREATE TABLE t1(a, b);
    INSERT INTO t1 VALUES(1, 2);
................................................................................
  sqlite3 db2 test.db
  execsql { SELECT * FROM t1 } db2
} {1 2}

do_test jrnlmode2-1.4 {
  execsql {
    INSERT INTO t1 VALUES(3, 4);
  }
  execsql {
    BEGIN;
    SELECT * FROM t1;
  }
  execsql { PRAGMA lock_status }
} {main shared temp closed}

do_test jrnlmode2-1.5 {
................................................................................

do_test jrnlmode2-2.4 {
  sqlite3 db2 test.db -readonly 1
  catchsql { SELECT * FROM t1 } db2
} {0 {1 2 3 4 5 6}}

do_test jrnlmode2-2.5 {
  db close
  file delete test.db-journal
} {}

do_test jrnlmode2-2.6 {
  sqlite3 db2 test.db -readonly 1
  catchsql { SELECT * FROM t1 } db2
} {0 {1 2 3 4 5 6}}

catch { db2 close }
finish_test