1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-01 06:27:03 +03:00

Do not put a write lock on the main database file when writing to a temporary

table. (CVS 750)

FossilOrigin-Name: 3f253afe15d4f7392555f340a41d780d1248087f
This commit is contained in:
drh
2002-09-14 13:47:32 +00:00
parent 41a3bd0a01
commit cabb081971
12 changed files with 195 additions and 53 deletions

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script is database locks.
#
# $Id: lock.test,v 1.17 2002/08/29 23:59:50 drh Exp $
# $Id: lock.test,v 1.18 2002/09/14 13:47:33 drh Exp $
set testdir [file dirname $argv0]
@ -270,7 +270,62 @@ do_test lock-4.3 {
set rc [catch {db2 eval {SELECT * FROM t1}} msg]
lappend rc $msg $::callback_value
} {1 {database is locked} {1 2 3 4 5}}
execsql {ROLLBACK}
# When one thread is writing, other threads cannot read. Except if the
# writing thread is writing to its temporary tables, the other threads
# can still read.
#
proc tx_exec {sql} {
db2 eval $sql
}
do_test lock-5.1 {
execsql {
SELECT * FROM t1
}
} {2 1}
do_test lock-5.2 {
db function tx_exec tx_exec
catchsql {
INSERT INTO t1(a,b) SELECT 3, tx_exec('SELECT y FROM t2 LIMIT 1');
}
} {1 {database is locked}}
do_test lock-5.3 {
execsql {
CREATE TEMP TABLE t3(x);
SELECT * FROM t3;
}
} {}
do_test lock-5.4 {
catchsql {
INSERT INTO t3 SELECT tx_exec('SELECT y FROM t2 LIMIT 1');
}
} {0 {}}
do_test lock-5.5 {
execsql {
SELECT * FROM t3;
}
} {8}
do_test lock-5.6 {
catchsql {
UPDATE t1 SET a=tx_exec('SELECT x FROM t2');
}
} {1 {database is locked}}
do_test lock-5.7 {
execsql {
SELECT * FROM t1;
}
} {2 1}
do_test lock-5.8 {
catchsql {
UPDATE t3 SET x=tx_exec('SELECT x FROM t2');
}
} {0 {}}
do_test lock-5.9 {
execsql {
SELECT * FROM t3;
}
} {9}
do_test lock-999.1 {
rename db2 {}

View File

@ -15,7 +15,7 @@
# interface is pretty well tested. This file contains some addition
# tests for fringe issues that the main test suite does not cover.
#
# $Id: tclsqlite.test,v 1.7 2002/06/25 19:31:18 drh Exp $
# $Id: tclsqlite.test,v 1.8 2002/09/14 13:47:33 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -29,7 +29,7 @@ do_test tcl-1.1 {
do_test tcl-1.2 {
set v [catch {db bogus} msg]
lappend v $msg
} {1 {bad option "bogus": must be busy, changes, close, complete, eval, last_insert_rowid, open_aux_file, or timeout}}
} {1 {bad option "bogus": must be busy, changes, close, complete, eval, function, last_insert_rowid, open_aux_file, or timeout}}
do_test tcl-1.3 {
execsql {CREATE TABLE t1(a int, b int)}
execsql {INSERT INTO t1 VALUES(10,20)}