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.
84 sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
87 SELECT sqlite_compileoption_used('SQLITE_THREADSAFE');
92 SELECT sqlite_compileoption_used('THREADSAFE');
97 SELECT sqlite_compileoption_used("THREADSAFE");
102 set ans1 [ catchsql {
103 SELECT sqlite_compileoption_used('THREADSAFE=0');
105 set ans2 [ catchsql {
106 SELECT sqlite_compileoption_used('THREADSAFE=1');
108 set ans3 [ catchsql {
109 SELECT sqlite_compileoption_used('THREADSAFE=2');
111 lsort [ list $ans1 $ans2 $ans3 ]
112 } {{0 0} {0 0} {0 1}}
116 SELECT sqlite_compileoption_used('THREADSAFE=');
120 do_test ctime-1.7.1 {
122 SELECT sqlite_compileoption_used('SQLITE_OMIT_COMPILEOPTION_DIAGS');
125 do_test ctime-1.7.2 {
127 SELECT sqlite_compileoption_used('OMIT_COMPILEOPTION_DIAGS');
131 #####################
132 # ctime-2.*: Test function support.
134 do_test ctime-2.1.1 {
136 SELECT sqlite_compileoption_used();
138 } {1 {wrong number of arguments to function sqlite_compileoption_used()}}
139 do_test ctime-2.1.2 {
141 SELECT sqlite_compileoption_used(NULL);
144 do_test ctime-2.1.3 {
146 SELECT sqlite_compileoption_used("");
149 do_test ctime-2.1.4 {
151 SELECT sqlite_compileoption_used('');
154 do_test ctime-2.1.5 {
156 SELECT sqlite_compileoption_used(foo);
158 } {1 {no such column: foo}}
159 do_test ctime-2.1.6 {
161 SELECT sqlite_compileoption_used('THREADSAFE', 0);
163 } {1 {wrong number of arguments to function sqlite_compileoption_used()}}
164 do_test ctime-2.1.7 {
166 SELECT sqlite_compileoption_used(0);
169 do_test ctime-2.1.8 {
171 SELECT sqlite_compileoption_used('0');
174 do_test ctime-2.1.9 {
176 SELECT sqlite_compileoption_used(1.0);
180 do_test ctime-2.2.1 {
182 SELECT sqlite_compileoption_get();
184 } {1 {wrong number of arguments to function sqlite_compileoption_get()}}
185 do_test ctime-2.2.2 {
187 SELECT sqlite_compileoption_get(0, 0);
189 } {1 {wrong number of arguments to function sqlite_compileoption_get()}}
191 # This assumes there is at least 1 compile time option
192 # (see SQLITE_THREADSAFE above).
195 SELECT sqlite_compileoption_used(sqlite_compileoption_get(0));
199 # This assumes there is at least 1 compile time option
200 # (see SQLITE_THREADSAFE above).
203 SELECT sqlite_compileoption_get(0);
208 # Get the list of defines using the pragma,
209 # then try querying each one with the functions.
211 PRAGMA compile_options;
213 set opts [ lindex $ans 1 ]
216 do_test ctime-2.5.$tc {
217 set N [ expr {$tc-1} ]
218 set ans1 [catch {db one {
219 SELECT sqlite_compileoption_get($N);
222 set ans2 [ catchsql {
223 SELECT sqlite_compileoption_used($opt);
225 list [ lindex $ans1 0 ] [ expr { [lindex $ans1 1]==$opt } ] \
230 # test 1 past array bounds
231 do_test ctime-2.5.$tc {
232 set N [ expr {$tc-1} ]
234 SELECT sqlite_compileoption_get($N);
238 # test 1 before array bounds (N=-1)
239 do_test ctime-2.5.$tc {
242 SELECT sqlite_compileoption_get($N);
246 #--------------------------------------------------------------------------
247 # Test that SQLITE_DIRECT_OVERFLOW_READ is reflected in the output of
248 # "PRAGMA compile_options".
250 ifcapable direct_read {
255 do_test ctime-3.0.1 {
256 expr [lsearch [db eval {PRAGMA compile_options}] DIRECT_OVERFLOW_READ]>=0