SQLite4
Check-in [5dfd8651df]
Not logged in

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

Overview
Comment:Add test file lsm3.test, which should have been added a few days ago.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5dfd8651df51d4c28e895ecc604e8e0a640a4852
User & Date: dan 2013-02-05 09:52:35
Context
2013-02-05
16:03
Change the BLOCK_SIZE, AUTOFLUSH and AUTOCHECKPOINT lsm_config() options to work in KB instead of bytes. This matches the user guide. check-in: 340c9dcd22 user: dan tags: trunk
09:52
Add test file lsm3.test, which should have been added a few days ago. check-in: 5dfd8651df user: dan tags: trunk
2013-02-02
16:45
Fix LSM single-process mode so that it holds an exclusive lock on the database file - preventing connections from within external processes. check-in: d6bd08ca0e user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added test/lsm3.test.

            1  +# 2012 November 02
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +# This file tests that the LSM_CONFIG_MULTIPLE_PROCESSES parameter seems
           13  +# to work as documented.
           14  +#
           15  +set testdir [file dirname $argv0]
           16  +source $testdir/tester.tcl
           17  +source $testdir/lock_common.tcl
           18  +set testprefix lsm3
           19  +db close
           20  +
           21  +do_multiclient_test tn {
           22  +
           23  +  # The [do_multiclient_test] command automatically opens a connection
           24  +  # in each process (or three connections in this process). We don't want
           25  +  # them in this case.
           26  +  code1 { db close }
           27  +  code2 { db2 close }
           28  +  code3 { db3 close }
           29  +
           30  +  if { $tn==1 } {
           31  +    set locked {1 {database is locked}}
           32  +  } else {
           33  +    set locked {0 {}}
           34  +  }
           35  +
           36  +  # Open a single-process connection to the database from an external
           37  +  # process (if $tn==1, otherwise open it from within the current 
           38  +  # process).
           39  +  code2 { sqlite4 db2 file:test.db?lsm_multiple_processes=0 }
           40  +
           41  +  # Try to open some other connections to the database file, both in multi
           42  +  # and single process mode. If ($tn==1), then all such attempts fail. Or,
           43  +  # if ($tn==2), they all succeed.
           44  +  do_test $tn.1 {
           45  +    catch { db close }
           46  +    list [catch {sqlite4 db file:test.db?lsm_multiple_processes=0} msg] $msg
           47  +  } $locked
           48  +  do_test $tn.2 {
           49  +    catch { db close }
           50  +    list [catch {sqlite4 db file:test.db?lsm_multiple_processes=0} msg] $msg
           51  +  } $locked
           52  +  do_test $tn.3 {
           53  +    catch { db close }
           54  +    list [catch {sqlite4 db file:test.db?lsm_multiple_processes=1} msg] $msg
           55  +  } $locked
           56  +  do_test $tn.4 {
           57  +    catch { db close }
           58  +    list [catch {sqlite4 db file:test.db?lsm_multiple_processes=1} msg] $msg
           59  +  } $locked
           60  +
           61  +  # Now open a connection from an external process in multi-proc mode.
           62  +  # Observe that further connections are allowed if they are from within
           63  +  # the same process or if the LSM_CONFIG_MULTIPLE_PROCESSES parameter
           64  +  # is set to true.
           65  +  code2 { 
           66  +    db2 close
           67  +    sqlite4 db2 file:test.db
           68  +  }
           69  +
           70  +  do_test $tn.5 {
           71  +    catch { db close }
           72  +    list [catch {sqlite4 db file:test.db?lsm_multiple_processes=0} msg] $msg
           73  +  } $locked
           74  +  do_test $tn.6 {
           75  +    catch { db close }
           76  +    list [catch {sqlite4 db file:test.db?lsm_multiple_processes=0} msg] $msg
           77  +  } $locked
           78  +  do_test $tn.7 {
           79  +    catch { db close }
           80  +    list [catch {sqlite4 db file:test.db?lsm_multiple_processes=1} msg] $msg
           81  +  } {0 {}}
           82  +  do_test $tn.8 {
           83  +    catch { db close }
           84  +    list [catch {sqlite4 db file:test.db?lsm_multiple_processes=1} msg] $msg
           85  +  } {0 {}}
           86  +}
           87  +
           88  +
           89  +finish_test