1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Check for schema updates if the parser fails to find a table. More locking

test updates. (CVS 1555)

FossilOrigin-Name: a22283512afe2df09d5783d189fbd7389ed313ad
This commit is contained in:
drh
2004-06-10 00:29:09 +00:00
parent f8646695a2
commit a6ecd33851
6 changed files with 69 additions and 37 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.22 2004/06/09 23:15:22 drh Exp $
# $Id: lock.test,v 1.23 2004/06/10 00:29:12 drh Exp $
set testdir [file dirname $argv0]
@ -47,7 +47,6 @@ do_test lock-1.7.1 {
catchsql {SELECT * FROM t1} db2
} {1 {no such table: t1}}
do_test lock-1.7.2 {
execsql {SELECT * FROM sqlite_master LIMIT 1} db2
catchsql {SELECT * FROM t1} db2
} {0 {1 2}}
do_test lock-1.8 {
@ -64,7 +63,7 @@ do_test lock-1.10 {
} {2 1}
do_test lock-1.11 {
catchsql {SELECT * FROM t1} db2
} {1 {database is locked}}
} {0 {2 1}}
do_test lock-1.12 {
execsql {ROLLBACK}
catchsql {SELECT * FROM t1}
@ -151,7 +150,8 @@ if {$::tcl_platform(platform)=="unix"} {
integrity_check lock-1.23
# If one thread has a transaction another thread cannot start
# a transaction.
# a transaction. -> Not true in version 3.0. But if one thread
# as a RESERVED lock another thread cannot acquire one.
#
do_test lock-2.1 {
execsql {BEGIN TRANSACTION}
@ -162,15 +162,14 @@ do_test lock-2.1 {
lappend r $msg
} {1 {database is locked}}
# Nor can the other thread do a query.
# A thread can read when another has a RESERVED lock.
#
do_test lock-2.2 {
set r [catch {execsql {SELECT * FROM t2} db2} msg]
lappend r $msg
} {1 {database is locked}}
catchsql {SELECT * FROM t2} db2
} {0 {9 8}}
# If the other thread (the one that does not hold the transaction)
# tries to start a transaction, we get a busy callback.
# If the other thread (the one that does not hold the transaction with
# a RESERVED lock) tries to get a RESERVED lock, we get a busy callback.
#
do_test lock-2.3 {
proc callback {args} {
@ -179,7 +178,7 @@ do_test lock-2.3 {
}
set ::callback_value {}
db2 busy callback
set r [catch {execsql {BEGIN TRANSACTION} db2} msg]
set r [catch {execsql {UPDATE t1 SET a=b, b=a} db2} msg]
lappend r $msg
lappend r $::callback_value
} {1 {database is locked} {{} 1}}
@ -190,7 +189,7 @@ do_test lock-2.4 {
}
set ::callback_value {}
db2 busy callback
set r [catch {execsql {BEGIN TRANSACTION} db2} msg]
set r [catch {execsql {UPDATE t1 SET a=b, b=a} db2} msg]
lappend r $msg
lappend r $::callback_value
} {1 {database is locked} {1 2 3 4 5}}
@ -204,7 +203,7 @@ do_test lock-2.5 {
set r [catch {execsql {SELECT * FROM t1} db2} msg]
lappend r $msg
lappend r $::callback_value
} {1 {database is locked} {1 2 3 4 5}}
} {0 {2 1} {}}
# In this test, the 3rd invocation of the busy callback causes
# the first thread to release its transaction. That allows the
@ -222,10 +221,8 @@ do_test lock-2.6 {
set r [catch {execsql {SELECT * FROM t2} db2} msg]
lappend r $msg
lappend r $::callback_value
} {0 {9 8} {1 2 3}}
} {0 {9 8} {}}
do_test lock-2.7 {
execsql {BEGIN TRANSACTION}
execsql {UPDATE t1 SET a = 0 WHERE 0}
proc callback {file count} {
lappend ::callback_value $count
if {$count>2} {
@ -276,12 +273,11 @@ do_test lock-4.1 {
db eval BEGIN
db eval {UPDATE t1 SET a=0 WHERE 0}
sqlite db2 ./test.db
set rc [catch {db2 eval {SELECT * FROM t1}} msg]
lappend rc $msg
catchsql {UPDATE t1 SET a=0} db2
} {1 {database is locked}}
do_test lock-4.2 {
set ::callback_value {}
set rc [catch {db2 eval {SELECT * FROM t1}} msg]
set rc [catch {db2 eval {UPDATE t1 SET a=0}} msg]
lappend rc $msg $::callback_value
} {1 {database is locked} {}}
do_test lock-4.3 {
@ -290,14 +286,15 @@ do_test lock-4.3 {
if {$count>4} break
}
db2 busy callback
set rc [catch {db2 eval {SELECT * FROM t1}} msg]
set rc [catch {db2 eval {UPDATE t1 SET a=0}} 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.
# can still read. -> Not so in 3.0. One thread can read while another
# holds a RESERVED lock.
#
proc tx_exec {sql} {
db2 eval $sql
@ -312,7 +309,7 @@ do_test lock-5.2 {
catchsql {
INSERT INTO t1(a,b) SELECT 3, tx_exec('SELECT y FROM t2 LIMIT 1');
}
} {1 {database is locked}}
} {0 {}}
do_test lock-5.3 {
execsql {
CREATE TEMP TABLE t3(x);
@ -333,12 +330,12 @@ do_test lock-5.6 {
catchsql {
UPDATE t1 SET a=tx_exec('SELECT x FROM t2');
}
} {1 {database is locked}}
} {0 {}}
do_test lock-5.7 {
execsql {
SELECT * FROM t1;
}
} {2 1}
} {9 1 9 8}
do_test lock-5.8 {
catchsql {
UPDATE t3 SET x=tx_exec('SELECT x FROM t2');