mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Fix a race condition causing SQLite to use a busy-handler for an operation that should not.
FossilOrigin-Name: 6ab9ed8eef77781898375038ab05fc6e5f46b745e4906691393b8b1d90570eb6
This commit is contained in:
89
test/walsetlk2.test
Normal file
89
test/walsetlk2.test
Normal file
@ -0,0 +1,89 @@
|
||||
# 2025 Jan 24
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# TESTRUNNER: slow
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/lock_common.tcl
|
||||
set testprefix walsetlk2
|
||||
|
||||
ifcapable !wal {finish_test ; return }
|
||||
ifcapable !setlk_timeout {finish_test ; return }
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Check that xShmLock calls are as expected for write transactions in
|
||||
# setlk mode.
|
||||
#
|
||||
reset_db
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(a, b, c);
|
||||
INSERT INTO t1 VALUES(1, 2, 3);
|
||||
} {wal}
|
||||
db close
|
||||
|
||||
testvfs tvfs
|
||||
tvfs script xShmLock_callback
|
||||
tvfs filter xShmLock
|
||||
|
||||
set ::xshmlock [list]
|
||||
proc xShmLock_callback {method path name detail} {
|
||||
lappend ::xshmlock $detail
|
||||
}
|
||||
|
||||
sqlite3 db test.db -vfs tvfs
|
||||
db timeout 1000
|
||||
|
||||
do_execsql_test 1.1 {
|
||||
SELECT * FROM t1
|
||||
} {1 2 3}
|
||||
|
||||
do_execsql_test 1.2 {
|
||||
INSERT INTO t1 VALUES(4, 5, 6);
|
||||
}
|
||||
|
||||
set ::xshmlock [list]
|
||||
do_execsql_test 1.3 {
|
||||
INSERT INTO t1 VALUES(7, 8, 9);
|
||||
}
|
||||
|
||||
do_test 1.4 {
|
||||
set ::xshmlock
|
||||
} [list \
|
||||
{0 1 lock exclusive} \
|
||||
{4 1 lock exclusive} {4 1 unlock exclusive} \
|
||||
{4 1 lock shared} \
|
||||
{0 1 unlock exclusive} \
|
||||
{4 1 unlock shared}
|
||||
]
|
||||
|
||||
do_execsql_test 1.5.1 { SELECT * FROM t1 } {1 2 3 4 5 6 7 8 9}
|
||||
set ::xshmlock [list]
|
||||
do_execsql_test 1.5.2 {
|
||||
INSERT INTO t1 VALUES(10, 11, 12);
|
||||
}
|
||||
do_test 1.5.3 {
|
||||
set ::xshmlock
|
||||
} [list \
|
||||
{0 1 lock exclusive} \
|
||||
{4 1 lock shared} \
|
||||
{0 1 unlock exclusive} \
|
||||
{4 1 unlock shared}
|
||||
]
|
||||
|
||||
db close
|
||||
tvfs delete
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user