mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Fix a bug that was emptying shared-schema tables during an ATTACH. (CVS 2867)
FossilOrigin-Name: 752a2754879becc32da9f9b910f3330f8c7145e4
This commit is contained in:
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the SELECT statement.
|
||||
#
|
||||
# $Id: shared.test,v 1.2 2006/01/05 11:34:34 danielk1977 Exp $
|
||||
# $Id: shared.test,v 1.3 2006/01/06 06:33:13 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -32,6 +32,8 @@ set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
|
||||
# external locking protocol is still working.
|
||||
# shared-3.*: Simple test of read-uncommitted mode.
|
||||
#
|
||||
# shared-4.*: Check that the schema is locked and unlocked correctly.
|
||||
#
|
||||
|
||||
do_test shared-1.1 {
|
||||
# Open a second database on the file test.db. It should use the same pager
|
||||
@ -218,6 +220,58 @@ catch {db close}
|
||||
catch {db2 close}
|
||||
catch {db3 close}
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# Tests shared-4.* test that the schema locking rules are applied
|
||||
# correctly. i.e.:
|
||||
#
|
||||
# 1. All transactions require a read-lock on the schemas of databases they
|
||||
# access.
|
||||
# 2. Transactions that modify a database schema require a write-lock on that
|
||||
# schema.
|
||||
# 3. It is not possible to compile a statement while another handle has a
|
||||
# write-lock on the schema.
|
||||
#
|
||||
|
||||
# Open two database handles db and db2. Each has a single attach database
|
||||
# (as well as main):
|
||||
#
|
||||
# db.main -> ./test.db
|
||||
# db.test2 -> ./test2.db
|
||||
# db2.main -> ./test2.db
|
||||
# db2.test -> ./test.db
|
||||
#
|
||||
file delete -force test.db
|
||||
file delete -force test2.db
|
||||
file delete -force test2.db-journal
|
||||
sqlite3 db test.db
|
||||
sqlite3 db2 test2.db
|
||||
do_test shared-4.1.1 {
|
||||
set sqlite_open_file_count
|
||||
} {2}
|
||||
do_test shared-4.1.2 {
|
||||
execsql {ATTACH 'test2.db' AS test2}
|
||||
set sqlite_open_file_count
|
||||
} {2}
|
||||
do_test shared-4.1.3 {
|
||||
execsql {ATTACH 'test.db' AS test} db2
|
||||
set sqlite_open_file_count
|
||||
} {2}
|
||||
|
||||
do_test shared-4.2.1 {
|
||||
execsql {
|
||||
CREATE TABLE abc(a, b, c);
|
||||
INSERT INTO abc VALUES('i', 'ii', 'iii');
|
||||
}
|
||||
} {}
|
||||
do_test shared-4.2.2 {
|
||||
execsql {
|
||||
SELECT * FROM test.abc;
|
||||
} db2
|
||||
} {i ii iii}
|
||||
|
||||
catch {db2 close}
|
||||
catch {db close}
|
||||
|
||||
finish_test
|
||||
sqlite3_enable_shared_cache $::enable_shared_cache
|
||||
|
||||
|
Reference in New Issue
Block a user