mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Candidate fixes for problems revealed by notify2.test. Notify2.test is still failing at this point.
FossilOrigin-Name: ea0428f9b6e63066e7444a2ba2f8c12a2e3ab7e4
This commit is contained in:
115
test/sharedA.test
Normal file
115
test/sharedA.test
Normal file
@ -0,0 +1,115 @@
|
||||
# 2013 May 14
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# Test some specific circumstances to do with shared cache mode.
|
||||
#
|
||||
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
db close
|
||||
set ::testprefix x
|
||||
|
||||
set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
do_test 1.1 {
|
||||
sqlite3 db1 test.db
|
||||
sqlite3 db2 test.db
|
||||
db2 eval {
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1 VALUES(123);
|
||||
}
|
||||
db1 eval {
|
||||
SELECT * FROM t1;
|
||||
CREATE INDEX i1 ON t1(x);
|
||||
}
|
||||
} {123}
|
||||
|
||||
do_test 1.2 {
|
||||
db2 eval { SELECT * FROM t1 ORDER BY x; }
|
||||
|
||||
db1 eval {
|
||||
BEGIN; DROP INDEX i1;
|
||||
}
|
||||
db1 close
|
||||
|
||||
db2 eval { SELECT * FROM t1 ORDER BY x; }
|
||||
} {123}
|
||||
|
||||
do_test 1.3 {
|
||||
db2 close
|
||||
} {}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
testvfs tvfs
|
||||
tvfs filter xRead
|
||||
tvfs script read_callback
|
||||
proc read_callback {args} { }
|
||||
|
||||
do_test 2.1 {
|
||||
forcedelete test.db test.db2
|
||||
sqlite3 db1 test.db -vfs tvfs
|
||||
db1 eval { ATTACH 'test.db2' AS two }
|
||||
|
||||
db1 eval {
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1 VALUES(1);
|
||||
INSERT INTO t1 VALUES(2);
|
||||
INSERT INTO t1 VALUES(3);
|
||||
CREATE TABLE two.t2(x);
|
||||
INSERT INTO t2 SELECT * FROM t1;
|
||||
}
|
||||
|
||||
sqlite3 db2 test.db -vfs tvfs
|
||||
db2 eval { SELECT * FROM t1 }
|
||||
} {1 2 3}
|
||||
|
||||
do_test 2.2 {
|
||||
set ::STMT [sqlite3_prepare db2 "CREATE INDEX i1 ON t1(x)" -1 tail]
|
||||
set {} {}
|
||||
} {}
|
||||
|
||||
do_test 2.3 {
|
||||
db1 eval {
|
||||
BEGIN;
|
||||
CREATE INDEX i1 ON t1(x);
|
||||
INSERT INTO t2 VALUES('value!');
|
||||
}
|
||||
} {}
|
||||
|
||||
set ::bFired 0
|
||||
proc read_callback {call file args} {
|
||||
if { $::bFired==0 && [string match *test.db2-journal $file] } {
|
||||
sqlthread spawn ::thread_result [subst -nocommands {
|
||||
sqlite3_step $::STMT
|
||||
set rc [sqlite3_finalize $::STMT]
|
||||
}]
|
||||
after 1000 { set ::bFired 1 }
|
||||
vwait ::bFired
|
||||
}
|
||||
}
|
||||
do_test 2.4 { db1 eval ROLLBACK } {}
|
||||
|
||||
if {[info exists ::thread_result]==0} { vwait ::thread_result }
|
||||
do_test 2.5 {
|
||||
list $::thread_result [sqlite3_errmsg db2]
|
||||
} {SQLITE_SCHEMA {database schema has changed}}
|
||||
|
||||
db1 close
|
||||
db2 close
|
||||
tvfs delete
|
||||
|
||||
sqlite3_enable_shared_cache $::enable_shared_cache
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user