3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
13 package require sqlite3
16 set db
[pg_connect
-conninfo "dbname=postgres user=postgres password=postgres"]
21 set sql
[string map
{{WITHOUT ROWID
} {}} $sql]
25 while {[string length
$sql]>0} {
26 set i
[string first
";" $sql]
28 append frag
[string range
$sql 0 $i]
29 set sql
[string range
$sql $i+1 end
]
30 if {[sqlite complete
$frag]} {
47 set res
[pg_exec
$::db $stmt]
48 set err
[pg_result
$res -error]
49 if {$err!=""} { error $err }
51 for {set i
0} {$i < [pg_result
$res -numTuples]} {incr i
} {
52 set t
[pg_result
$res -getTuple $i]
53 set nNew
[string length
$t]
54 if {$nChar>0 && ($nChar+$nNew+3)>75} {
72 proc execsql_test
{tn sql
} {
73 set res
[execsql
$sql]
74 set sql
[string map
{string_agg group_concat
} $sql]
75 # set sql [string map [list {NULLS FIRST} {}] $sql]
76 # set sql [string map [list {NULLS LAST} {}] $sql]
77 puts $::fd "do_execsql_test $tn {"
78 puts $::fd " [string trim $sql]"
83 proc errorsql_test
{tn sql
} {
84 set rc
[catch {execsql
$sql} msg
]
86 error "errorsql_test SQL did not cause an error!"
88 set msg
[lindex [split [string trim
$msg] "\n"] 0]
89 puts $::fd "# PG says $msg"
90 set sql
[string map
{string_agg group_concat
} $sql]
91 puts $::fd "do_test $tn { catch { execsql {"
92 puts $::fd " [string trim $sql]"
97 # Same as [execsql_test], except coerce all results to floating point values
98 # with two decimal points.
100 proc execsql_float_test
{tn sql
} {
103 set res
[execsql
$sql]
106 if {$r != ""} { set r
[format $F $r] }
110 set sql
[string trim
$sql]
111 puts $::fd [subst -nocommands {
114 foreach r
[db
eval {$sql}] {
115 lappend myres
[format $F [set r
]]
119 foreach r
[set myres
] r2
[set res2
] {
120 if {[set r
]<([set r2
]-$T) ||
[set r
]>([set r2
]+$T)} {
121 error "list element [set i] does not match: got=[set r] expected=[set r2]"
130 proc start_test
{name date
} {
131 set dir
[file dirname
$::argv0]
132 set output
[file join $dir $name.test
]
133 set ::fd [open $output w
]
134 puts $::fd [string trimleft
"
137 # The author disclaims copyright to this source code. In place of
138 # a legal notice, here is a blessing:
140 # May you do good and not evil.
141 # May you find forgiveness for yourself and forgive others.
142 # May you share freely, never taking more than you give.
144 #***********************************************************************
145 # This file implements regression tests for SQLite library.
148 ####################################################
149 # DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
150 ####################################################
152 puts $::fd {set testdir
[file dirname
$argv0]}
153 puts $::fd {source $testdir/tester.tcl
}
154 puts $::fd "set testprefix $name"
162 proc ========== {args
} {
163 puts $::fd "#[string repeat = 74]"
167 proc finish_test
{} {
168 puts $::fd finish_test
172 proc ifcapable
{arg
} {
173 puts $::fd "ifcapable $arg { finish_test ; return }"