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 #***********************************************************************
11 # This file implements regression tests for SQLite library.
13 # This file implements tests for the compile time diagnostic
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
22 # ctime-1.*: Test pragma support.
23 # ctime-2.*: Test function support.
26 ifcapable !pragma||!compileoption_diags {
32 # ctime-1.*: Test pragma support.
36 PRAGMA compile_options();
38 } {1 {near ")": syntax error}}
41 PRAGMA compile_options(NULL);
43 } {1 {near "NULL": syntax error}}
46 PRAGMA compile_options *;
48 } {1 {near "*": syntax error}}
52 PRAGMA compile_options;
54 list [ lindex $ans 0 ]
56 # the results should be in sorted order already
59 PRAGMA compile_options;
61 list [ lindex $ans 0 ] [ expr { [lsort [lindex $ans 1]]==[lindex $ans 1] } ]
64 # Check the THREADSAFE option for SQLITE_THREADSAFE=2 builds (there are
65 # a couple of these configurations in releasetest.tcl).
67 ifcapable threadsafe2 {
68 foreach {tn opt res} {
76 do_execsql_test ctime-1.3.$tn {
77 SELECT sqlite_compileoption_used($opt)
82 # SQLITE_THREADSAFE should pretty much always be defined
83 # one way or the other, and it must have a value of 0 or 1.
86 SELECT sqlite_compileoption_used('SQLITE_THREADSAFE');
91 SELECT sqlite_compileoption_used('THREADSAFE');
96 SELECT sqlite_compileoption_used("THREADSAFE");
101 set ans1 [ catchsql {
102 SELECT sqlite_compileoption_used('THREADSAFE=0');
104 set ans2 [ catchsql {
105 SELECT sqlite_compileoption_used('THREADSAFE=1');
107 set ans3 [ catchsql {
108 SELECT sqlite_compileoption_used('THREADSAFE=2');
110 lsort [ list $ans1 $ans2 $ans3 ]
111 } {{0 0} {0 0} {0 1}}
115 SELECT sqlite_compileoption_used('THREADSAFE=');
119 do_test ctime-1.7.1 {
121 SELECT sqlite_compileoption_used('SQLITE_OMIT_COMPILEOPTION_DIAGS');
124 do_test ctime-1.7.2 {
126 SELECT sqlite_compileoption_used('OMIT_COMPILEOPTION_DIAGS');
130 #####################
131 # ctime-2.*: Test function support.
133 do_test ctime-2.1.1 {
135 SELECT sqlite_compileoption_used();
137 } {1 {wrong number of arguments to function sqlite_compileoption_used()}}
138 do_test ctime-2.1.2 {
140 SELECT sqlite_compileoption_used(NULL);
143 do_test ctime-2.1.3 {
145 SELECT sqlite_compileoption_used("");
148 do_test ctime-2.1.4 {
150 SELECT sqlite_compileoption_used('');
153 do_test ctime-2.1.5 {
155 SELECT sqlite_compileoption_used(foo);
157 } {1 {no such column: foo}}
158 do_test ctime-2.1.6 {
160 SELECT sqlite_compileoption_used('THREADSAFE', 0);
162 } {1 {wrong number of arguments to function sqlite_compileoption_used()}}
163 do_test ctime-2.1.7 {
165 SELECT sqlite_compileoption_used(0);
168 do_test ctime-2.1.8 {
170 SELECT sqlite_compileoption_used('0');
173 do_test ctime-2.1.9 {
175 SELECT sqlite_compileoption_used(1.0);
179 do_test ctime-2.2.1 {
181 SELECT sqlite_compileoption_get();
183 } {1 {wrong number of arguments to function sqlite_compileoption_get()}}
184 do_test ctime-2.2.2 {
186 SELECT sqlite_compileoption_get(0, 0);
188 } {1 {wrong number of arguments to function sqlite_compileoption_get()}}
190 # This assumes there is at least 1 compile time option
191 # (see SQLITE_THREADSAFE above).
194 SELECT sqlite_compileoption_used(sqlite_compileoption_get(0));
198 # This assumes there is at least 1 compile time option
199 # (see SQLITE_THREADSAFE above).
202 SELECT sqlite_compileoption_get(0);
207 # Get the list of defines using the pragma,
208 # then try querying each one with the functions.
210 PRAGMA compile_options;
212 set opts [ lindex $ans 1 ]
215 do_test ctime-2.5.$tc {
216 set N [ expr {$tc-1} ]
217 set ans1 [catch {db one {
218 SELECT sqlite_compileoption_get($N);
221 set ans2 [ catchsql {
222 SELECT sqlite_compileoption_used($opt);
224 list [ lindex $ans1 0 ] [ expr { [lindex $ans1 1]==$opt } ] \
229 # test 1 past array bounds
230 do_test ctime-2.5.$tc {
231 set N [ expr {$tc-1} ]
233 SELECT sqlite_compileoption_get($N);
237 # test 1 before array bounds (N=-1)
238 do_test ctime-2.5.$tc {
241 SELECT sqlite_compileoption_get($N);
245 #--------------------------------------------------------------------------
246 # Test that SQLITE_DIRECT_OVERFLOW_READ is reflected in the output of
247 # "PRAGMA compile_options".
249 ifcapable direct_read {
254 do_test ctime-3.0.1 {
255 expr [lsearch [db eval {PRAGMA compile_options}] DIRECT_OVERFLOW_READ]>=0