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

Overview
Comment:Fix a bug in the lsm_unix.c xLock method.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e50e06e52cbb4b34ffce19434fcdc79232153d0a
User & Date: dan 2012-09-05 18:52:43.142
Context
2012-09-05
19:10
Add more simple inter-process locking tests. check-in: 3674a5075c user: dan tags: trunk
18:52
Fix a bug in the lsm_unix.c xLock method. check-in: e50e06e52c user: dan tags: trunk
17:15
Fix a problem in test script misuse.test. check-in: 0ed91ba599 user: dan tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/lsm_unix.c.
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
    if( e==EACCES || e==EAGAIN ){
      rc = LSM_BUSY;
    }else{
      rc = LSM_IOERR;
    }
  }

  return LSM_OK;
}

int lsmPosixOsShmMap(lsm_file *pFile, int iChunk, int sz, void **ppShm){
  PosixFile *p = (PosixFile *)pFile;

  *ppShm = 0;
  assert( sz==LSM_SHM_CHUNK_SIZE );







|







308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
    if( e==EACCES || e==EAGAIN ){
      rc = LSM_BUSY;
    }else{
      rc = LSM_IOERR;
    }
  }

  return rc;
}

int lsmPosixOsShmMap(lsm_file *pFile, int iChunk, int sz, void **ppShm){
  PosixFile *p = (PosixFile *)pFile;

  *ppShm = 0;
  assert( sz==LSM_SHM_CHUNK_SIZE );
Changes to test/lock_common.tcl.
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# code in this file allows testfixture to control another process (or
# processes) to test locking.
#

proc do_multiclient_test {varname script} {

  foreach code [list {
    puts "Skipping multi-process tests..."
    continue
    if {[info exists ::G(valgrind)]} { db close ; continue }
    set ::code2_chan [launch_testfixture]
    set ::code3_chan [launch_testfixture]
    proc code2 {tcl} { testfixture $::code2_chan $tcl }
    proc code3 {tcl} { testfixture $::code3_chan $tcl }
    set tn 1
  } {







<
<







12
13
14
15
16
17
18


19
20
21
22
23
24
25
# code in this file allows testfixture to control another process (or
# processes) to test locking.
#

proc do_multiclient_test {varname script} {

  foreach code [list {


    if {[info exists ::G(valgrind)]} { db close ; continue }
    set ::code2_chan [launch_testfixture]
    set ::code3_chan [launch_testfixture]
    proc code2 {tcl} { testfixture $::code2_chan $tcl }
    proc code3 {tcl} { testfixture $::code3_chan $tcl }
    set tn 1
  } {
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
proc launch_testfixture {{prg ""}} {
  write_main_loop
  if {$prg eq ""} { set prg [info nameofexec] }
  if {$prg eq ""} { set prg testfixture }
  if {[file tail $prg]==$prg} { set prg [file join . $prg] }
  set chan [open "|$prg tf_main.tcl" r+]
  fconfigure $chan -buffering line
  set rc [catch { 
    testfixture $chan "sqlite4_test_control_pending_byte $::sqlite_pending_byte"
  }]
  if {$rc} {
    testfixture $chan "set ::sqlite_pending_byte $::sqlite_pending_byte"
  }
  return $chan
}

# Execute a command in a child testfixture process, connected by two-way
# channel $chan. Return the result of the command, or an error message.
#
proc testfixture {chan cmd} {







<
<
<
<
<
<







70
71
72
73
74
75
76






77
78
79
80
81
82
83
proc launch_testfixture {{prg ""}} {
  write_main_loop
  if {$prg eq ""} { set prg [info nameofexec] }
  if {$prg eq ""} { set prg testfixture }
  if {[file tail $prg]==$prg} { set prg [file join . $prg] }
  set chan [open "|$prg tf_main.tcl" r+]
  fconfigure $chan -buffering line






  return $chan
}

# Execute a command in a child testfixture process, connected by two-way
# channel $chan. Return the result of the command, or an error message.
#
proc testfixture {chan cmd} {
Added test/mc1.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
# 2012 September 05
#
# 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.
#
#***********************************************************************
# The tests in this file were used while developing the SQLite 4 code. 
#

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


do_multiclient_test tn {

  do_test 1.$tn.1 { 
    sql1 { CREATE TABLE t1(a PRIMARY KEY, b) } 
    sql1 { INSERT INTO t1 VALUES(1, 2) }
    sql2 { SELECT * FROM t1 }
  } {1 2}

  do_test 1.$tn.2 { file size test.db } 0

  do_test 1.$tn.3 {
    sql2 { BEGIN; INSERT INTO t1 VALUES(2, 4); }
    sql1 { SELECT * FROM t1 }
  } {1 2}

  do_test 1.$tn.4 {
breakpoint
    csql1 { INSERT INTO t1 VALUES(3, 6) }
  } {1 {database is locked}}

}

finish_test


Changes to test/simple2.test.
10
11
12
13
14
15
16




17
18
19
20
21
22
23
24
#***********************************************************************
# The tests in this file were used while developing the SQLite 4 code. 
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix simple2






db_delete test2.db
do_execsql_test 1.1 {
  CREATE TABLE t1(a, b);
  INSERT INTO t1 VALUES('abc', 'def');
  ATTACH 'test2.db' AS aux;
  CREATE TABLE aux.t1 AS SELECT * FROM main.t1;
  DETACH aux;







>
>
>
>
|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#***********************************************************************
# The tests in this file were used while developing the SQLite 4 code. 
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix simple2

#-------------------------------------------------------------------------
# Test cases 1.* verify that file-descriptors are not closed while there
# are outstanding locks. And that file-descriptors left in the resulting
# deferred-close state are reused when possible.
#
db_delete test2.db
do_execsql_test 1.1 {
  CREATE TABLE t1(a, b);
  INSERT INTO t1 VALUES('abc', 'def');
  ATTACH 'test2.db' AS aux;
  CREATE TABLE aux.t1 AS SELECT * FROM main.t1;
  DETACH aux;