Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Changes to compile time option diags to report values for some defines. Added test cases to TCL test suite (ctime.test). |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
dd480f62afa56ff85c2dd57ee7a16eee |
User & Date: | shaneh 2010-02-24 19:36:10.000 |
Context
2010-02-24
| ||
21:44 | Add testcase() macros beside each sqlite3_log() call to make sure it is tested with both logging enable and disabled. (check-in: 1168763d2c user: drh tags: trunk) | |
19:36 | Changes to compile time option diags to report values for some defines. Added test cases to TCL test suite (ctime.test). (check-in: dd480f62af user: shaneh tags: trunk) | |
19:23 | Add a sqlite3_log() call on anonymous constraint failures. Fix the output of test cases having to do with improved reprepare reporting. Fix the VACUUM command to report more helpful error messages when things go wrong. (check-in: 69a493182f user: drh tags: trunk) | |
Changes
Changes to src/ctime.c.
︙ | ︙ | |||
15 16 17 18 19 20 21 | */ #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS #include "sqliteInt.h" /* | | > | > > > > > > > > > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | */ #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS #include "sqliteInt.h" /* ** An array of names of all compile-time options. This array should ** be sorted A-Z. ** ** This array looks large, but in a typical installation actually uses ** only a handful of compile-time options, so most times this array is usually ** rather short and uses little memory space. */ static const char * const azCompileOpt[] = { /* These macros are provided to "stringify" the value of the define ** for those options in which the value is meaningful. */ #define CTIMEOPT_VAL_(opt) #opt #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt) #ifdef SQLITE_32BIT_ROWID "32BIT_ROWID", #endif #ifdef SQLITE_4_BYTE_ALIGNED_MALLOC "4_BYTE_ALIGNED_MALLOC", #endif #ifdef SQLITE_CASE_SENSITIVE_LIKE "CASE_SENSITIVE_LIKE", #endif #ifdef SQLITE_CHECK_PAGES "CHECK_PAGES", #endif #ifdef SQLITE_COVERAGE_TEST "COVERAGE_TEST", #endif #ifdef SQLITE_DEBUG "DEBUG", #endif #ifdef SQLITE_DEFAULT_LOCKING_MODE "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE), #endif #ifdef SQLITE_DISABLE_DIRSYNC "DISABLE_DIRSYNC", #endif #ifdef SQLITE_DISABLE_LFS "DISABLE_LFS", #endif #ifdef SQLITE_ENABLE_ATOMIC_WRITE |
︙ | ︙ | |||
83 84 85 86 87 88 89 | #ifdef SQLITE_ENABLE_IOTRACE "ENABLE_IOTRACE", #endif #ifdef SQLITE_ENABLE_LOAD_EXTENSION "ENABLE_LOAD_EXTENSION", #endif #ifdef SQLITE_ENABLE_LOCKING_STYLE | | | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | #ifdef SQLITE_ENABLE_IOTRACE "ENABLE_IOTRACE", #endif #ifdef SQLITE_ENABLE_LOAD_EXTENSION "ENABLE_LOAD_EXTENSION", #endif #ifdef SQLITE_ENABLE_LOCKING_STYLE "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE), #endif #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT "ENABLE_MEMORY_MANAGEMENT", #endif #ifdef SQLITE_ENABLE_MEMSYS3 "ENABLE_MEMSYS3", #endif |
︙ | ︙ | |||
319 320 321 322 323 324 325 326 327 328 329 330 331 332 | #endif #ifdef SQLITE_SOUNDEX "SOUNDEX", #endif #ifdef SQLITE_TCL "TCL", #endif #ifdef SQLITE_TEST "TEST", #endif #ifdef SQLITE_USE_ALLOCA "USE_ALLOCA", #endif #ifdef SQLITE_ZERO_MALLOC | > > > > > > | | > | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | #endif #ifdef SQLITE_SOUNDEX "SOUNDEX", #endif #ifdef SQLITE_TCL "TCL", #endif #ifdef SQLITE_TEMP_STORE "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE), #endif #ifdef SQLITE_TEST "TEST", #endif #ifdef SQLITE_THREADSAFE "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE), #endif #ifdef SQLITE_USE_ALLOCA "USE_ALLOCA", #endif #ifdef SQLITE_ZERO_MALLOC "ZERO_MALLOC" #endif }; /* ** Given the name of a compile-time option, return true if that option ** was used and false if not. ** ** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix ** is not required for a match. */ int sqlite3_compileoption_used(const char *zOptName){ int i, n; if( sqlite3StrNICmp(zOptName, "SQLITE_", 7)==0 ) zOptName += 7; n = sqlite3Strlen30(zOptName); /* Since ArraySize(azCompileOpt) is normally in single digits, a ** linear search is adequate. No need for a binary search. */ for(i=0; i<ArraySize(azCompileOpt); i++){ if( (sqlite3StrNICmp(zOptName, azCompileOpt[i], n)==0) && ( (azCompileOpt[i][n]==0) || (azCompileOpt[i][n]=='=') ) ) return 1; } return 0; } /* ** Return the N-th compile-time option string. If N is out of range, ** return a NULL pointer. |
︙ | ︙ |
Changes to src/test_config.c.
︙ | ︙ | |||
179 180 181 182 183 184 185 | Tcl_SetVar2(interp, "sqlite_options", "oversize_cell_check", "1", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "sqlite_options", "oversize_cell_check", "0", TCL_GLOBAL_ONLY); #endif | | > > > > | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | Tcl_SetVar2(interp, "sqlite_options", "oversize_cell_check", "1", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "sqlite_options", "oversize_cell_check", "0", TCL_GLOBAL_ONLY); #endif #ifdef SQLITE_OMIT_COMPILEOPTION_DIAGS Tcl_SetVar2(interp, "sqlite_options", "compileoption_diags", "0", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "sqlite_options", "compileoption_diags", "1", TCL_GLOBAL_ONLY); #endif #ifdef SQLITE_OMIT_COMPLETE Tcl_SetVar2(interp, "sqlite_options", "complete", "0", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "sqlite_options", "complete", "1", TCL_GLOBAL_ONLY); #endif |
︙ | ︙ |
Added test/ctime.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | # 2009 February 24 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the compile time diagnostic # functions. # set testdir [file dirname $argv0] source $testdir/tester.tcl # Test organization: # # ctime-1.*: Test pragma support. # ctime-2.*: Test function support. # ifcapable !pragma||!compileoption_diags { finish_test return } ##################### # ctime-1.*: Test pragma support. do_test ctime-1.1.1 { catchsql { PRAGMA compile_options(); } } {1 {near ")": syntax error}} do_test ctime-1.1.2 { catchsql { PRAGMA compile_options(NULL); } } {1 {near "NULL": syntax error}} do_test ctime-1.1.3 { catchsql { PRAGMA compile_options *; } } {1 {near "*": syntax error}} do_test ctime-1.2.1 { set ans [ catchsql { PRAGMA compile_options; } ] list [ lindex $ans 0 ] } {0} # the results should be in sorted order already do_test ctime-1.2.2 { set ans [ catchsql { PRAGMA compile_options; } ] list [ lindex $ans 0 ] [ expr { [lsort [lindex $ans 1]]==[lindex $ans 1] } ] } {0 1} do_test ctime-1.3.1 { catchsql { PRAGMA compile_option(); } } {1 {near ")": syntax error}} do_test ctime-1.3.2 { catchsql { PRAGMA compile_option(NULL); } } {1 {near "NULL": syntax error}} do_test ctime-1.3.3 { catchsql { PRAGMA compile_option foo; } } {1 {near "foo": syntax error}} do_test ctime-1.3.4 { catchsql { PRAGMA compile_option 'foo'; } } {1 {near "'foo'": syntax error}} # SQLITE_THREADSAFE should pretty much always be defined # one way or the other, and it must have a value of 0 or 1. do_test ctime-1.4.1 { catchsql { PRAGMA compile_option('SQLITE_THREADSAFE'); } } {0 1} do_test ctime-1.4.2 { catchsql { PRAGMA compile_option('THREADSAFE'); } } {0 1} do_test ctime-1.4.3 { catchsql { PRAGMA compile_option("THREADSAFE"); } } {0 1} do_test ctime-1.4.4 { catchsql { PRAGMA compile_option='THREADSAFE'; } } {0 1} do_test ctime-1.4.5 { catchsql { PRAGMA compile_option="THREADSAFE"; } } {0 1} do_test ctime-1.4 { set ans1 [ catchsql { PRAGMA compile_option('THREADSAFE=0'); } ] set ans2 [ catchsql { PRAGMA compile_option('THREADSAFE=1'); } ] lsort [ list $ans1 $ans2 ] } {{0 0} {0 1}} do_test ctime-1.5 { execsql { PRAGMA compile_option('THREADSAFE='); } } {0} do_test ctime-1.6 { execsql { PRAGMA compile_option('SQLITE_OMIT_COMPILEOPTION_DIAGS'); } } {0} do_test ctime-1.7 { execsql { PRAGMA compile_option('OMIT_COMPILEOPTION_DIAGS'); } } {0} ##################### # ctime-2.*: Test function support. do_test ctime-2.1.1 { catchsql { SELECT sqlite_compile_option_used(); } } {1 {wrong number of arguments to function sqlite_compile_option_used()}} do_test ctime-2.1.2 { catchsql { SELECT sqlite_compile_option_used(NULL); } } {0 {{}}} do_test ctime-2.1.3 { catchsql { SELECT sqlite_compile_option_used(""); } } {0 0} do_test ctime-2.1.4 { catchsql { SELECT sqlite_compile_option_used(''); } } {0 0} do_test ctime-2.1.5 { catchsql { SELECT sqlite_compile_option_used(foo); } } {1 {no such column: foo}} do_test ctime-2.1.6 { catchsql { SELECT sqlite_compile_option_used('THREADSAFE', 0); } } {1 {wrong number of arguments to function sqlite_compile_option_used()}} do_test ctime-2.2.1 { catchsql { SELECT sqlite_compile_option_get(); } } {1 {wrong number of arguments to function sqlite_compile_option_get()}} do_test ctime-2.2.2 { catchsql { SELECT sqlite_compile_option_get(0, 0); } } {1 {wrong number of arguments to function sqlite_compile_option_get()}} # This assumes there is at least 1 compile time option # (see SQLITE_THREADSAFE above). do_test ctime-2.3 { catchsql { SELECT sqlite_compile_option_used(sqlite_compile_option_get(0)); } } {0 1} # This assumes there is at least 1 compile time option # (see SQLITE_THREADSAFE above). do_test ctime-2.4 { set res [ catchsql { SELECT sqlite_compile_option_get(0); } ] list [lindex $res 0] } {0} # Get the list of defines using the pragma, # then try querying each one with the functions. set ans [ catchsql { PRAGMA compile_options; } ] set opts [ lindex $ans 1 ] set tc 1 foreach opt $opts { do_test ctime-2.5.$tc { set N [ expr {$tc-1} ] set ans1 [ catchsql { SELECT sqlite_compile_option_get($N); } ] set ans2 [ catchsql { SELECT sqlite_compile_option_used($opt); } ] list [ lindex $ans1 0 ] [ expr { [lindex $ans1 1]==$opt } ] \ [ expr { $ans2 } ] } {0 1 {0 1}} incr tc 1 } # test 1 past array bounds do_test ctime-2.5.$tc { set N [ expr {$tc-1} ] set ans [ catchsql { SELECT sqlite_compile_option_get($N); } ] } {0 {{}}} incr tc 1 # test 1 before array bounds (N=-1) do_test ctime-2.5.$tc { set N -1 set ans [ catchsql { SELECT sqlite_compile_option_get($N); } ] } {0 {{}}} finish_test |