aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/sqlite/unix/sqlite-3.5.1/test/thread_common.tcl
diff options
context:
space:
mode:
authordan miller2007-10-20 02:49:29 +0000
committerdan miller2007-10-20 02:49:29 +0000
commite36d23a85ebff914d74bb541558c2b6082b78edb (patch)
tree54b58fdf162e78af64055282a6035c8d2443389d /libraries/sqlite/unix/sqlite-3.5.1/test/thread_common.tcl
parent* Fixed an issue whereby avatar chat distances were being calculated against ... (diff)
downloadopensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.zip
opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.gz
opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.bz2
opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.xz
sqlite source (unix build) added to libraries
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/test/thread_common.tcl')
-rw-r--r--libraries/sqlite/unix/sqlite-3.5.1/test/thread_common.tcl88
1 files changed, 88 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/test/thread_common.tcl b/libraries/sqlite/unix/sqlite-3.5.1/test/thread_common.tcl
new file mode 100644
index 0000000..5e34b17
--- /dev/null
+++ b/libraries/sqlite/unix/sqlite-3.5.1/test/thread_common.tcl
@@ -0,0 +1,88 @@
1# 2007 September 10
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# $Id: thread_common.tcl,v 1.2 2007/09/10 10:53:02 danielk1977 Exp $
13
14set testdir [file dirname $argv0]
15source $testdir/tester.tcl
16
17if {[info commands sqlthread] eq ""} {
18 puts -nonewline "Skipping thread-safety tests - "
19 puts " not running a threadsafe sqlite/tcl build"
20 puts -nonewline "Both SQLITE_THREADSAFE and TCL_THREADS must be defined when"
21 puts " building testfixture"
22 finish_test
23 return
24}
25
26# The following script is sourced by every thread spawned using
27# [sqlthread spawn]:
28set thread_procs {
29
30 # Execute the supplied SQL using database handle $::DB.
31 #
32 proc execsql {sql} {
33
34 set rc SQLITE_LOCKED
35 while {$rc eq "SQLITE_LOCKED"
36 || $rc eq "SQLITE_BUSY"
37 || $rc eq "SQLITE_SCHEMA"} {
38 set res [list]
39
40 set err [catch {
41 set ::STMT [sqlite3_prepare_v2 $::DB $sql -1 dummy_tail]
42 } msg]
43
44 if {$err == 0} {
45 while {[set rc [sqlite3_step $::STMT]] eq "SQLITE_ROW"} {
46 for {set i 0} {$i < [sqlite3_column_count $::STMT]} {incr i} {
47 lappend res [sqlite3_column_text $::STMT 0]
48 }
49 }
50 set rc [sqlite3_finalize $::STMT]
51 } else {
52 if {[string first (6) $msg]} {
53 set rc SQLITE_LOCKED
54 } else {
55 set rc SQLITE_ERROR
56 }
57 }
58
59 if {[string first locked [sqlite3_errmsg $::DB]]>=0} {
60 set rc SQLITE_LOCKED
61 }
62
63 if {$rc eq "SQLITE_LOCKED" || $rc eq "SQLITE_BUSY"} {
64 #puts -nonewline "([sqlthread id] $rc)"
65 #flush stdout
66 after 20
67 }
68 }
69
70 if {$rc ne "SQLITE_OK"} {
71 error "$rc - [sqlite3_errmsg $::DB]"
72 }
73 set res
74 }
75
76 proc do_test {name script result} {
77 set res [eval $script]
78 if {$res ne $result} {
79 error "$name failed: expected \"$result\" got \"$res\""
80 }
81 }
82}
83
84proc thread_spawn {varname args} {
85 sqlthread spawn $varname [join $args ;]
86}
87
88return 0