/ Check-in [59be370e]
Login

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 Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/jrnlmode2.test.

     5      5   #
     6      6   #    May you do good and not evil.
     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   #
    12         -# $Id: jrnlmode2.test,v 1.6 2009/06/05 17:09:12 drh Exp $
    13     12   
    14     13   set testdir [file dirname $argv0]
    15     14   source $testdir/tester.tcl
    16     15   
    17     16   ifcapable {!pager_pragmas} {
    18     17     finish_test
    19     18     return
    20     19   }
    21     20   
    22     21   #-------------------------------------------------------------------------
    23         -# Test overview:
           22  +# The tests in this file check that the following two bugs (both now fixed)
           23  +# do not reappear.
           24  +#
           25  +# jrnlmode2-1.*: Demonstrate bug #3745:
           26  +#
           27  +#     In persistent journal mode, if:
           28  +#
           29  +#       * There is a persistent journal in the file-system, AND
           30  +#       * there exists a connection with a shared lock on the db file, 
           31  +#
           32  +#     then a second connection cannot open a read-transaction on the database.
           33  +#     The reason is because while determining that the persistent-journal is
           34  +#     not a hot-journal, SQLite currently grabs an exclusive lock on the
           35  +#     database file. If this fails because another connection has a shared
           36  +#     lock, then SQLITE_BUSY is returned to the user.  
           37  +#
           38  +# jrnlmode2-2.*: Demonstrate bug #3751:
           39  +#
           40  +#     If a connection is opened in SQLITE_OPEN_READONLY mode, the underlying
           41  +#     unix file descriptor on the database file is opened in O_RDONLY mode.
    24     42   #
    25         -#   jrnlmode2-1.*: Demonstrate bug #3745
    26         -#   jrnlmode2-2.*: Demonstrate bug #3751
           43  +#     When SQLite queries the database file for the schema in order to compile
           44  +#     the SELECT statement, it sees the empty journal in the file system, it
           45  +#     attempts to obtain an exclusive lock on the database file (this is a
           46  +#     bug). The attempt to obtain an exclusive (write) lock on a read-only file
           47  +#     fails at the OS level. Under unix, fcntl() reports an EBADF - "Bad file
           48  +#     descriptor" - error. 
    27     49   #
    28     50   
    29     51   do_test jrnlmode2-1.1 {
    30     52     execsql {
    31     53       PRAGMA journal_mode = persist;
    32     54       CREATE TABLE t1(a, b);
    33     55       INSERT INTO t1 VALUES(1, 2);
................................................................................
    42     64     sqlite3 db2 test.db
    43     65     execsql { SELECT * FROM t1 } db2
    44     66   } {1 2}
    45     67   
    46     68   do_test jrnlmode2-1.4 {
    47     69     execsql {
    48     70       INSERT INTO t1 VALUES(3, 4);
           71  +  }
           72  +  execsql {
    49     73       BEGIN;
    50     74       SELECT * FROM t1;
    51     75     }
    52     76     execsql { PRAGMA lock_status }
    53     77   } {main shared temp closed}
    54     78   
    55     79   do_test jrnlmode2-1.5 {
................................................................................
    83    107   
    84    108   do_test jrnlmode2-2.4 {
    85    109     sqlite3 db2 test.db -readonly 1
    86    110     catchsql { SELECT * FROM t1 } db2
    87    111   } {0 {1 2 3 4 5 6}}
    88    112   
    89    113   do_test jrnlmode2-2.5 {
          114  +  db close
    90    115     file delete test.db-journal
    91    116   } {}
    92         -
    93    117   do_test jrnlmode2-2.6 {
    94    118     sqlite3 db2 test.db -readonly 1
    95    119     catchsql { SELECT * FROM t1 } db2
    96    120   } {0 {1 2 3 4 5 6}}
    97    121   
    98    122   catch { db2 close }
    99    123   finish_test