interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / test / thread3.test

77 lines · 1602 bytes Raw Blame History
1# 2023 May 13
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
6# May you do good and not evil.
7# May you find forgiveness for yourself and forgive others.
8# May you share freely, never taking more than you give.
9#
10#***********************************************************************
11#
12
13set testdir [file dirname $argv0]
14
15source $testdir/tester.tcl
16source $testdir/lock_common.tcl
17if {[run_thread_tests]==0} { finish_test ; return }
18
19set testprefix thread3
20
21do_execsql_test 1.0 {
22 CREATE TABLE t1(a, b);
23 PRAGMA journal_mode = DELETE;
24} {delete}
25
26proc wait_for_var {varname} {
27 if {0==[uplevel [list info exists $varname]]} {
28 uplevel [list vwait $varname]
29 }
30 uplevel [list set $varname]
31}
32
33set nAttempt 250
34
35do_test 1.1 {
36 for {set i 0} {$i < $nAttempt} {incr i} {
37 unset -nocomplain X
38 unset -nocomplain Y
39
40 sqlthread spawn X {
41 sqlite3 dbI test.db
42 dbI timeout 100
43 set rc 1
44 set nBusy 0
45 while {$rc} {
46 set rc [catch {
47 dbI eval { INSERT INTO t1 VALUES(203, 'message') RETURNING a; }
48 } msg]
49 if {$rc} { incr nBusy }
50 }
51 dbI close
52 set nBusy
53 }
54
55 sqlthread spawn Y {
56 sqlite3 dbR test.db
57 catch {
58 dbR eval { SELECT count(*) FROM t1 }
59 } msg
60 dbR close
61 set msg
62 }
63
64 wait_for_var X
65 wait_for_var Y
66 incr nTotalBusy $X
67 }
68
69 execsql { SELECT count(*) FROM t1 }
70 set {} {}
71} {}
72
73do_execsql_test "1.Total BUSY errors: $nTotalBusy .2" {
74 SELECT count(*) FROM t1;
75} $nAttempt
76
77finish_test