drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 1 | /* |
| 2 | ** 2007 May 7 |
| 3 | ** |
| 4 | ** The author disclaims copyright to this source code. In place of |
| 5 | ** a legal notice, here is a blessing: |
| 6 | ** |
| 7 | ** May you do good and not evil. |
| 8 | ** May you find forgiveness for yourself and forgive others. |
| 9 | ** May you share freely, never taking more than you give. |
| 10 | ** |
| 11 | ************************************************************************* |
| 12 | ** |
| 13 | ** This file contains code used for testing the SQLite system. |
| 14 | ** None of the code in this file goes into a deliverable build. |
| 15 | ** |
| 16 | ** The focus of this file is providing the TCL testing layer |
| 17 | ** access to compile-time constants. |
| 18 | ** |
drh | c5d0bd9 | 2008-04-14 01:00:57 +0000 | [diff] [blame^] | 19 | ** $Id: test_config.c,v 1.25 2008/04/14 01:00:58 drh Exp $ |
drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 20 | */ |
danielk1977 | e6a58a4 | 2007-08-31 17:42:48 +0000 | [diff] [blame] | 21 | |
| 22 | #include "sqliteLimit.h" |
| 23 | |
drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 24 | #include "sqliteInt.h" |
| 25 | #include "tcl.h" |
drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 26 | #include <stdlib.h> |
| 27 | #include <string.h> |
| 28 | |
| 29 | /* |
| 30 | ** This routine sets entries in the global ::sqlite_options() array variable |
| 31 | ** according to the compile-time configuration of the database. Test |
| 32 | ** procedures use this to determine when tests should be omitted. |
| 33 | */ |
| 34 | static void set_options(Tcl_Interp *interp){ |
drh | 01495b9 | 2008-01-23 12:52:40 +0000 | [diff] [blame] | 35 | int rc = 0; |
| 36 | |
drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 37 | #ifdef SQLITE_32BIT_ROWID |
| 38 | Tcl_SetVar2(interp, "sqlite_options", "rowid32", "1", TCL_GLOBAL_ONLY); |
| 39 | #else |
| 40 | Tcl_SetVar2(interp, "sqlite_options", "rowid32", "0", TCL_GLOBAL_ONLY); |
| 41 | #endif |
| 42 | |
| 43 | #ifdef SQLITE_CASE_SENSITIVE_LIKE |
| 44 | Tcl_SetVar2(interp, "sqlite_options","casesensitivelike","1",TCL_GLOBAL_ONLY); |
| 45 | #else |
| 46 | Tcl_SetVar2(interp, "sqlite_options","casesensitivelike","0",TCL_GLOBAL_ONLY); |
| 47 | #endif |
| 48 | |
danielk1977 | 6338c76 | 2007-05-17 16:38:30 +0000 | [diff] [blame] | 49 | #ifdef SQLITE_DEBUG |
| 50 | Tcl_SetVar2(interp, "sqlite_options", "debug", "1", TCL_GLOBAL_ONLY); |
| 51 | #else |
| 52 | Tcl_SetVar2(interp, "sqlite_options", "debug", "0", TCL_GLOBAL_ONLY); |
| 53 | #endif |
| 54 | |
drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 55 | #ifdef SQLITE_DISABLE_DIRSYNC |
| 56 | Tcl_SetVar2(interp, "sqlite_options", "dirsync", "0", TCL_GLOBAL_ONLY); |
| 57 | #else |
| 58 | Tcl_SetVar2(interp, "sqlite_options", "dirsync", "1", TCL_GLOBAL_ONLY); |
| 59 | #endif |
| 60 | |
| 61 | #ifdef SQLITE_DISABLE_LFS |
| 62 | Tcl_SetVar2(interp, "sqlite_options", "lfs", "0", TCL_GLOBAL_ONLY); |
| 63 | #else |
| 64 | Tcl_SetVar2(interp, "sqlite_options", "lfs", "1", TCL_GLOBAL_ONLY); |
| 65 | #endif |
| 66 | |
drh | f3a65f7 | 2007-08-22 20:18:21 +0000 | [diff] [blame] | 67 | #ifdef SQLITE_MEMDEBUG |
| 68 | Tcl_SetVar2(interp, "sqlite_options", "memdebug", "1", TCL_GLOBAL_ONLY); |
| 69 | #else |
| 70 | Tcl_SetVar2(interp, "sqlite_options", "memdebug", "0", TCL_GLOBAL_ONLY); |
| 71 | #endif |
| 72 | |
drh | 9c7a60d | 2007-10-19 17:47:24 +0000 | [diff] [blame] | 73 | #ifdef SQLITE_MEMORY_SIZE |
| 74 | Tcl_SetVar2(interp, "sqlite_options", "mem3", "1", TCL_GLOBAL_ONLY); |
| 75 | #else |
| 76 | Tcl_SetVar2(interp, "sqlite_options", "mem3", "0", TCL_GLOBAL_ONLY); |
| 77 | #endif |
| 78 | |
drh | 2d7636e | 2008-02-16 16:21:45 +0000 | [diff] [blame] | 79 | #ifdef SQLITE_POW2_MEMORY_SIZE |
| 80 | Tcl_SetVar2(interp, "sqlite_options", "mem5", "1", TCL_GLOBAL_ONLY); |
| 81 | #else |
| 82 | Tcl_SetVar2(interp, "sqlite_options", "mem5", "0", TCL_GLOBAL_ONLY); |
| 83 | #endif |
| 84 | |
drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 85 | #ifdef SQLITE_OMIT_ALTERTABLE |
| 86 | Tcl_SetVar2(interp, "sqlite_options", "altertable", "0", TCL_GLOBAL_ONLY); |
| 87 | #else |
| 88 | Tcl_SetVar2(interp, "sqlite_options", "altertable", "1", TCL_GLOBAL_ONLY); |
| 89 | #endif |
| 90 | |
| 91 | #ifdef SQLITE_OMIT_ANALYZE |
| 92 | Tcl_SetVar2(interp, "sqlite_options", "analyze", "0", TCL_GLOBAL_ONLY); |
| 93 | #else |
| 94 | Tcl_SetVar2(interp, "sqlite_options", "analyze", "1", TCL_GLOBAL_ONLY); |
| 95 | #endif |
| 96 | |
drh | d6b9386 | 2007-08-29 17:59:42 +0000 | [diff] [blame] | 97 | #ifdef SQLITE_ENABLE_ATOMIC_WRITE |
| 98 | Tcl_SetVar2(interp, "sqlite_options", "atomicwrite", "1", TCL_GLOBAL_ONLY); |
| 99 | #else |
| 100 | Tcl_SetVar2(interp, "sqlite_options", "atomicwrite", "0", TCL_GLOBAL_ONLY); |
| 101 | #endif |
| 102 | |
drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 103 | #ifdef SQLITE_OMIT_ATTACH |
| 104 | Tcl_SetVar2(interp, "sqlite_options", "attach", "0", TCL_GLOBAL_ONLY); |
| 105 | #else |
| 106 | Tcl_SetVar2(interp, "sqlite_options", "attach", "1", TCL_GLOBAL_ONLY); |
| 107 | #endif |
| 108 | |
| 109 | #ifdef SQLITE_OMIT_AUTHORIZATION |
| 110 | Tcl_SetVar2(interp, "sqlite_options", "auth", "0", TCL_GLOBAL_ONLY); |
| 111 | #else |
| 112 | Tcl_SetVar2(interp, "sqlite_options", "auth", "1", TCL_GLOBAL_ONLY); |
| 113 | #endif |
| 114 | |
| 115 | #ifdef SQLITE_OMIT_AUTOINCREMENT |
| 116 | Tcl_SetVar2(interp, "sqlite_options", "autoinc", "0", TCL_GLOBAL_ONLY); |
| 117 | #else |
| 118 | Tcl_SetVar2(interp, "sqlite_options", "autoinc", "1", TCL_GLOBAL_ONLY); |
| 119 | #endif |
| 120 | |
| 121 | #ifdef SQLITE_OMIT_AUTOVACUUM |
| 122 | Tcl_SetVar2(interp, "sqlite_options", "autovacuum", "0", TCL_GLOBAL_ONLY); |
| 123 | #else |
| 124 | Tcl_SetVar2(interp, "sqlite_options", "autovacuum", "1", TCL_GLOBAL_ONLY); |
| 125 | #endif /* SQLITE_OMIT_AUTOVACUUM */ |
| 126 | #if !defined(SQLITE_DEFAULT_AUTOVACUUM) || SQLITE_DEFAULT_AUTOVACUUM==0 |
| 127 | Tcl_SetVar2(interp,"sqlite_options","default_autovacuum","0",TCL_GLOBAL_ONLY); |
| 128 | #else |
| 129 | Tcl_SetVar2(interp,"sqlite_options","default_autovacuum","1",TCL_GLOBAL_ONLY); |
| 130 | #endif |
| 131 | |
| 132 | #ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION |
| 133 | Tcl_SetVar2(interp, "sqlite_options", "between_opt", "0", TCL_GLOBAL_ONLY); |
| 134 | #else |
| 135 | Tcl_SetVar2(interp, "sqlite_options", "between_opt", "1", TCL_GLOBAL_ONLY); |
| 136 | #endif |
| 137 | |
drh | 3088d59 | 2008-03-21 16:45:47 +0000 | [diff] [blame] | 138 | #ifdef SQLITE_OMIT_BUILTIN_TEST |
| 139 | Tcl_SetVar2(interp, "sqlite_options", "builtin_test", "0", TCL_GLOBAL_ONLY); |
| 140 | #else |
| 141 | Tcl_SetVar2(interp, "sqlite_options", "builtin_test", "1", TCL_GLOBAL_ONLY); |
| 142 | #endif |
| 143 | |
drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 144 | #ifdef SQLITE_OMIT_BLOB_LITERAL |
| 145 | Tcl_SetVar2(interp, "sqlite_options", "bloblit", "0", TCL_GLOBAL_ONLY); |
| 146 | #else |
| 147 | Tcl_SetVar2(interp, "sqlite_options", "bloblit", "1", TCL_GLOBAL_ONLY); |
| 148 | #endif |
| 149 | |
| 150 | #ifdef SQLITE_OMIT_CAST |
| 151 | Tcl_SetVar2(interp, "sqlite_options", "cast", "0", TCL_GLOBAL_ONLY); |
| 152 | #else |
| 153 | Tcl_SetVar2(interp, "sqlite_options", "cast", "1", TCL_GLOBAL_ONLY); |
| 154 | #endif |
| 155 | |
| 156 | #ifdef SQLITE_OMIT_CHECK |
| 157 | Tcl_SetVar2(interp, "sqlite_options", "check", "0", TCL_GLOBAL_ONLY); |
| 158 | #else |
| 159 | Tcl_SetVar2(interp, "sqlite_options", "check", "1", TCL_GLOBAL_ONLY); |
| 160 | #endif |
| 161 | |
| 162 | #ifdef SQLITE_ENABLE_COLUMN_METADATA |
| 163 | Tcl_SetVar2(interp, "sqlite_options", "columnmetadata", "1", TCL_GLOBAL_ONLY); |
| 164 | #else |
| 165 | Tcl_SetVar2(interp, "sqlite_options", "columnmetadata", "0", TCL_GLOBAL_ONLY); |
| 166 | #endif |
| 167 | |
| 168 | #ifdef SQLITE_OMIT_COMPLETE |
| 169 | Tcl_SetVar2(interp, "sqlite_options", "complete", "0", TCL_GLOBAL_ONLY); |
| 170 | #else |
| 171 | Tcl_SetVar2(interp, "sqlite_options", "complete", "1", TCL_GLOBAL_ONLY); |
| 172 | #endif |
| 173 | |
| 174 | #ifdef SQLITE_OMIT_COMPOUND_SELECT |
| 175 | Tcl_SetVar2(interp, "sqlite_options", "compound", "0", TCL_GLOBAL_ONLY); |
| 176 | #else |
| 177 | Tcl_SetVar2(interp, "sqlite_options", "compound", "1", TCL_GLOBAL_ONLY); |
| 178 | #endif |
| 179 | |
| 180 | #ifdef SQLITE_OMIT_CONFLICT_CLAUSE |
| 181 | Tcl_SetVar2(interp, "sqlite_options", "conflict", "0", TCL_GLOBAL_ONLY); |
| 182 | #else |
| 183 | Tcl_SetVar2(interp, "sqlite_options", "conflict", "1", TCL_GLOBAL_ONLY); |
| 184 | #endif |
| 185 | |
| 186 | #if OS_UNIX |
| 187 | Tcl_SetVar2(interp, "sqlite_options", "crashtest", "1", TCL_GLOBAL_ONLY); |
| 188 | #else |
| 189 | Tcl_SetVar2(interp, "sqlite_options", "crashtest", "0", TCL_GLOBAL_ONLY); |
| 190 | #endif |
| 191 | |
| 192 | #ifdef SQLITE_OMIT_DATETIME_FUNCS |
| 193 | Tcl_SetVar2(interp, "sqlite_options", "datetime", "0", TCL_GLOBAL_ONLY); |
| 194 | #else |
| 195 | Tcl_SetVar2(interp, "sqlite_options", "datetime", "1", TCL_GLOBAL_ONLY); |
| 196 | #endif |
| 197 | |
drh | 3f91357 | 2008-03-22 01:07:17 +0000 | [diff] [blame] | 198 | #ifdef SQLITE_OMIT_DECLTYPE |
| 199 | Tcl_SetVar2(interp, "sqlite_options", "decltype", "0", TCL_GLOBAL_ONLY); |
| 200 | #else |
| 201 | Tcl_SetVar2(interp, "sqlite_options", "decltype", "1", TCL_GLOBAL_ONLY); |
| 202 | #endif |
| 203 | |
drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 204 | #ifdef SQLITE_OMIT_DISKIO |
| 205 | Tcl_SetVar2(interp, "sqlite_options", "diskio", "0", TCL_GLOBAL_ONLY); |
| 206 | #else |
| 207 | Tcl_SetVar2(interp, "sqlite_options", "diskio", "1", TCL_GLOBAL_ONLY); |
| 208 | #endif |
| 209 | |
| 210 | #ifdef SQLITE_OMIT_EXPLAIN |
| 211 | Tcl_SetVar2(interp, "sqlite_options", "explain", "0", TCL_GLOBAL_ONLY); |
| 212 | #else |
| 213 | Tcl_SetVar2(interp, "sqlite_options", "explain", "1", TCL_GLOBAL_ONLY); |
| 214 | #endif |
| 215 | |
| 216 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 217 | Tcl_SetVar2(interp, "sqlite_options", "floatingpoint", "0", TCL_GLOBAL_ONLY); |
| 218 | #else |
| 219 | Tcl_SetVar2(interp, "sqlite_options", "floatingpoint", "1", TCL_GLOBAL_ONLY); |
| 220 | #endif |
| 221 | |
| 222 | #ifdef SQLITE_OMIT_FOREIGN_KEY |
| 223 | Tcl_SetVar2(interp, "sqlite_options", "foreignkey", "0", TCL_GLOBAL_ONLY); |
| 224 | #else |
| 225 | Tcl_SetVar2(interp, "sqlite_options", "foreignkey", "1", TCL_GLOBAL_ONLY); |
| 226 | #endif |
| 227 | |
| 228 | #ifdef SQLITE_ENABLE_FTS1 |
| 229 | Tcl_SetVar2(interp, "sqlite_options", "fts1", "1", TCL_GLOBAL_ONLY); |
| 230 | #else |
| 231 | Tcl_SetVar2(interp, "sqlite_options", "fts1", "0", TCL_GLOBAL_ONLY); |
| 232 | #endif |
| 233 | |
| 234 | #ifdef SQLITE_ENABLE_FTS2 |
| 235 | Tcl_SetVar2(interp, "sqlite_options", "fts2", "1", TCL_GLOBAL_ONLY); |
| 236 | #else |
| 237 | Tcl_SetVar2(interp, "sqlite_options", "fts2", "0", TCL_GLOBAL_ONLY); |
| 238 | #endif |
| 239 | |
drh | a2451e2 | 2007-08-20 23:50:24 +0000 | [diff] [blame] | 240 | #ifdef SQLITE_ENABLE_FTS3 |
| 241 | Tcl_SetVar2(interp, "sqlite_options", "fts3", "1", TCL_GLOBAL_ONLY); |
| 242 | #else |
| 243 | Tcl_SetVar2(interp, "sqlite_options", "fts3", "0", TCL_GLOBAL_ONLY); |
| 244 | #endif |
| 245 | |
drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 246 | #ifdef SQLITE_OMIT_GLOBALRECOVER |
| 247 | Tcl_SetVar2(interp, "sqlite_options", "globalrecover", "0", TCL_GLOBAL_ONLY); |
| 248 | #else |
| 249 | Tcl_SetVar2(interp, "sqlite_options", "globalrecover", "1", TCL_GLOBAL_ONLY); |
| 250 | #endif |
| 251 | |
| 252 | #ifdef SQLITE_ENABLE_ICU |
| 253 | Tcl_SetVar2(interp, "sqlite_options", "icu", "1", TCL_GLOBAL_ONLY); |
| 254 | #else |
| 255 | Tcl_SetVar2(interp, "sqlite_options", "icu", "0", TCL_GLOBAL_ONLY); |
| 256 | #endif |
| 257 | |
| 258 | #ifdef SQLITE_OMIT_INCRBLOB |
| 259 | Tcl_SetVar2(interp, "sqlite_options", "incrblob", "0", TCL_GLOBAL_ONLY); |
| 260 | #else |
| 261 | Tcl_SetVar2(interp, "sqlite_options", "incrblob", "1", TCL_GLOBAL_ONLY); |
| 262 | #endif /* SQLITE_OMIT_AUTOVACUUM */ |
| 263 | |
| 264 | #ifdef SQLITE_OMIT_INTEGRITY_CHECK |
| 265 | Tcl_SetVar2(interp, "sqlite_options", "integrityck", "0", TCL_GLOBAL_ONLY); |
| 266 | #else |
| 267 | Tcl_SetVar2(interp, "sqlite_options", "integrityck", "1", TCL_GLOBAL_ONLY); |
| 268 | #endif |
| 269 | |
| 270 | #if defined(SQLITE_DEFAULT_FILE_FORMAT) && SQLITE_DEFAULT_FILE_FORMAT==1 |
| 271 | Tcl_SetVar2(interp, "sqlite_options", "legacyformat", "1", TCL_GLOBAL_ONLY); |
| 272 | #else |
| 273 | Tcl_SetVar2(interp, "sqlite_options", "legacyformat", "0", TCL_GLOBAL_ONLY); |
| 274 | #endif |
| 275 | |
| 276 | #ifdef SQLITE_OMIT_LIKE_OPTIMIZATION |
| 277 | Tcl_SetVar2(interp, "sqlite_options", "like_opt", "0", TCL_GLOBAL_ONLY); |
| 278 | #else |
| 279 | Tcl_SetVar2(interp, "sqlite_options", "like_opt", "1", TCL_GLOBAL_ONLY); |
| 280 | #endif |
| 281 | |
| 282 | #ifdef SQLITE_OMIT_LOAD_EXTENSION |
| 283 | Tcl_SetVar2(interp, "sqlite_options", "load_ext", "0", TCL_GLOBAL_ONLY); |
| 284 | #else |
| 285 | Tcl_SetVar2(interp, "sqlite_options", "load_ext", "1", TCL_GLOBAL_ONLY); |
| 286 | #endif |
| 287 | |
drh | a7fba4b | 2007-08-13 15:18:27 +0000 | [diff] [blame] | 288 | Tcl_SetVar2(interp, "sqlite_options", "long_double", |
| 289 | sizeof(LONGDOUBLE_TYPE)>sizeof(double) ? "1" : "0", |
| 290 | TCL_GLOBAL_ONLY); |
| 291 | |
drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 292 | #ifdef SQLITE_OMIT_MEMORYDB |
| 293 | Tcl_SetVar2(interp, "sqlite_options", "memorydb", "0", TCL_GLOBAL_ONLY); |
| 294 | #else |
| 295 | Tcl_SetVar2(interp, "sqlite_options", "memorydb", "1", TCL_GLOBAL_ONLY); |
| 296 | #endif |
| 297 | |
| 298 | #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT |
| 299 | Tcl_SetVar2(interp, "sqlite_options", "memorymanage", "1", TCL_GLOBAL_ONLY); |
| 300 | #else |
| 301 | Tcl_SetVar2(interp, "sqlite_options", "memorymanage", "0", TCL_GLOBAL_ONLY); |
| 302 | #endif |
| 303 | |
| 304 | #ifdef SQLITE_OMIT_OR_OPTIMIZATION |
| 305 | Tcl_SetVar2(interp, "sqlite_options", "or_opt", "0", TCL_GLOBAL_ONLY); |
| 306 | #else |
| 307 | Tcl_SetVar2(interp, "sqlite_options", "or_opt", "1", TCL_GLOBAL_ONLY); |
| 308 | #endif |
| 309 | |
| 310 | #ifdef SQLITE_OMIT_PAGER_PRAGMAS |
| 311 | Tcl_SetVar2(interp, "sqlite_options", "pager_pragmas", "0", TCL_GLOBAL_ONLY); |
| 312 | #else |
| 313 | Tcl_SetVar2(interp, "sqlite_options", "pager_pragmas", "1", TCL_GLOBAL_ONLY); |
| 314 | #endif |
| 315 | |
| 316 | #ifdef SQLITE_OMIT_PARSER |
| 317 | Tcl_SetVar2(interp, "sqlite_options", "parser", "0", TCL_GLOBAL_ONLY); |
| 318 | #else |
| 319 | Tcl_SetVar2(interp, "sqlite_options", "parser", "1", TCL_GLOBAL_ONLY); |
| 320 | #endif |
| 321 | |
| 322 | #if defined(SQLITE_OMIT_PRAGMA) || defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 323 | Tcl_SetVar2(interp, "sqlite_options", "pragma", "0", TCL_GLOBAL_ONLY); |
| 324 | Tcl_SetVar2(interp, "sqlite_options", "integrityck", "0", TCL_GLOBAL_ONLY); |
| 325 | #else |
| 326 | Tcl_SetVar2(interp, "sqlite_options", "pragma", "1", TCL_GLOBAL_ONLY); |
| 327 | #endif |
| 328 | |
| 329 | #ifdef SQLITE_OMIT_PROGRESS_CALLBACK |
| 330 | Tcl_SetVar2(interp, "sqlite_options", "progress", "0", TCL_GLOBAL_ONLY); |
| 331 | #else |
| 332 | Tcl_SetVar2(interp, "sqlite_options", "progress", "1", TCL_GLOBAL_ONLY); |
| 333 | #endif |
| 334 | |
drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 335 | #ifdef SQLITE_OMIT_REINDEX |
| 336 | Tcl_SetVar2(interp, "sqlite_options", "reindex", "0", TCL_GLOBAL_ONLY); |
| 337 | #else |
| 338 | Tcl_SetVar2(interp, "sqlite_options", "reindex", "1", TCL_GLOBAL_ONLY); |
| 339 | #endif |
| 340 | |
| 341 | #ifdef SQLITE_OMIT_SCHEMA_PRAGMAS |
| 342 | Tcl_SetVar2(interp, "sqlite_options", "schema_pragmas", "0", TCL_GLOBAL_ONLY); |
| 343 | #else |
| 344 | Tcl_SetVar2(interp, "sqlite_options", "schema_pragmas", "1", TCL_GLOBAL_ONLY); |
| 345 | #endif |
| 346 | |
| 347 | #ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS |
| 348 | Tcl_SetVar2(interp, "sqlite_options", "schema_version", "0", TCL_GLOBAL_ONLY); |
| 349 | #else |
| 350 | Tcl_SetVar2(interp, "sqlite_options", "schema_version", "1", TCL_GLOBAL_ONLY); |
| 351 | #endif |
| 352 | |
| 353 | #ifdef SQLITE_OMIT_SHARED_CACHE |
| 354 | Tcl_SetVar2(interp, "sqlite_options", "shared_cache", "0", TCL_GLOBAL_ONLY); |
| 355 | #else |
| 356 | Tcl_SetVar2(interp, "sqlite_options", "shared_cache", "1", TCL_GLOBAL_ONLY); |
| 357 | #endif |
| 358 | |
| 359 | #ifdef SQLITE_OMIT_SUBQUERY |
| 360 | Tcl_SetVar2(interp, "sqlite_options", "subquery", "0", TCL_GLOBAL_ONLY); |
| 361 | #else |
| 362 | Tcl_SetVar2(interp, "sqlite_options", "subquery", "1", TCL_GLOBAL_ONLY); |
| 363 | #endif |
| 364 | |
| 365 | #ifdef SQLITE_OMIT_TCL_VARIABLE |
| 366 | Tcl_SetVar2(interp, "sqlite_options", "tclvar", "0", TCL_GLOBAL_ONLY); |
| 367 | #else |
| 368 | Tcl_SetVar2(interp, "sqlite_options", "tclvar", "1", TCL_GLOBAL_ONLY); |
| 369 | #endif |
| 370 | |
drh | 01495b9 | 2008-01-23 12:52:40 +0000 | [diff] [blame] | 371 | rc = sqlite3_threadsafe(); |
drh | d677b3d | 2007-08-20 22:48:41 +0000 | [diff] [blame] | 372 | #if SQLITE_THREADSAFE |
drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 373 | Tcl_SetVar2(interp, "sqlite_options", "threadsafe", "1", TCL_GLOBAL_ONLY); |
drh | 01495b9 | 2008-01-23 12:52:40 +0000 | [diff] [blame] | 374 | assert( rc ); |
drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 375 | #else |
| 376 | Tcl_SetVar2(interp, "sqlite_options", "threadsafe", "0", TCL_GLOBAL_ONLY); |
drh | 01495b9 | 2008-01-23 12:52:40 +0000 | [diff] [blame] | 377 | assert( !rc ); |
drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 378 | #endif |
| 379 | |
| 380 | #ifdef SQLITE_OMIT_TRACE |
| 381 | Tcl_SetVar2(interp, "sqlite_options", "trace", "0", TCL_GLOBAL_ONLY); |
| 382 | #else |
| 383 | Tcl_SetVar2(interp, "sqlite_options", "trace", "1", TCL_GLOBAL_ONLY); |
| 384 | #endif |
| 385 | |
| 386 | #ifdef SQLITE_OMIT_TRIGGER |
| 387 | Tcl_SetVar2(interp, "sqlite_options", "trigger", "0", TCL_GLOBAL_ONLY); |
| 388 | #else |
| 389 | Tcl_SetVar2(interp, "sqlite_options", "trigger", "1", TCL_GLOBAL_ONLY); |
| 390 | #endif |
| 391 | |
| 392 | #ifdef SQLITE_OMIT_TEMPDB |
| 393 | Tcl_SetVar2(interp, "sqlite_options", "tempdb", "0", TCL_GLOBAL_ONLY); |
| 394 | #else |
| 395 | Tcl_SetVar2(interp, "sqlite_options", "tempdb", "1", TCL_GLOBAL_ONLY); |
| 396 | #endif |
| 397 | |
| 398 | #ifdef SQLITE_OMIT_UTF16 |
| 399 | Tcl_SetVar2(interp, "sqlite_options", "utf16", "0", TCL_GLOBAL_ONLY); |
| 400 | #else |
| 401 | Tcl_SetVar2(interp, "sqlite_options", "utf16", "1", TCL_GLOBAL_ONLY); |
| 402 | #endif |
| 403 | |
| 404 | #if defined(SQLITE_OMIT_VACUUM) || defined(SQLITE_OMIT_ATTACH) |
| 405 | Tcl_SetVar2(interp, "sqlite_options", "vacuum", "0", TCL_GLOBAL_ONLY); |
| 406 | #else |
| 407 | Tcl_SetVar2(interp, "sqlite_options", "vacuum", "1", TCL_GLOBAL_ONLY); |
| 408 | #endif |
| 409 | |
| 410 | #ifdef SQLITE_OMIT_VIEW |
| 411 | Tcl_SetVar2(interp, "sqlite_options", "view", "0", TCL_GLOBAL_ONLY); |
| 412 | #else |
| 413 | Tcl_SetVar2(interp, "sqlite_options", "view", "1", TCL_GLOBAL_ONLY); |
| 414 | #endif |
| 415 | |
| 416 | #ifdef SQLITE_OMIT_VIRTUALTABLE |
| 417 | Tcl_SetVar2(interp, "sqlite_options", "vtab", "0", TCL_GLOBAL_ONLY); |
| 418 | #else |
| 419 | Tcl_SetVar2(interp, "sqlite_options", "vtab", "1", TCL_GLOBAL_ONLY); |
| 420 | #endif |
| 421 | |
drh | c5d0bd9 | 2008-04-14 01:00:57 +0000 | [diff] [blame^] | 422 | #ifdef SQLITE_SECURE_DELETE |
| 423 | Tcl_SetVar2(interp, "sqlite_options", "secure_delete", "1", TCL_GLOBAL_ONLY); |
| 424 | #else |
| 425 | Tcl_SetVar2(interp, "sqlite_options", "secure_delete", "0", TCL_GLOBAL_ONLY); |
| 426 | #endif |
| 427 | |
drh | bb4957f | 2008-03-20 14:03:29 +0000 | [diff] [blame] | 428 | #define LINKVAR(x) { \ |
| 429 | static const int cv_ ## x = SQLITE_ ## x; \ |
| 430 | Tcl_LinkVar(interp, "SQLITE_" #x, (char *)&(cv_ ## x), \ |
| 431 | TCL_LINK_INT | TCL_LINK_READ_ONLY); } |
danielk1977 | e6a58a4 | 2007-08-31 17:42:48 +0000 | [diff] [blame] | 432 | |
| 433 | LINKVAR( MAX_LENGTH ); |
| 434 | LINKVAR( MAX_COLUMN ); |
| 435 | LINKVAR( MAX_SQL_LENGTH ); |
| 436 | LINKVAR( MAX_EXPR_DEPTH ); |
| 437 | LINKVAR( MAX_COMPOUND_SELECT ); |
| 438 | LINKVAR( MAX_VDBE_OP ); |
| 439 | LINKVAR( MAX_FUNCTION_ARG ); |
| 440 | LINKVAR( MAX_VARIABLE_NUMBER ); |
| 441 | LINKVAR( MAX_PAGE_SIZE ); |
| 442 | LINKVAR( MAX_PAGE_COUNT ); |
| 443 | LINKVAR( MAX_LIKE_PATTERN_LENGTH ); |
drh | bb4957f | 2008-03-20 14:03:29 +0000 | [diff] [blame] | 444 | LINKVAR( DEFAULT_TEMP_CACHE_SIZE ); |
| 445 | LINKVAR( DEFAULT_CACHE_SIZE ); |
| 446 | LINKVAR( DEFAULT_PAGE_SIZE ); |
| 447 | LINKVAR( DEFAULT_FILE_FORMAT ); |
| 448 | LINKVAR( MAX_ATTACHED ); |
danielk1977 | e6a58a4 | 2007-08-31 17:42:48 +0000 | [diff] [blame] | 449 | |
drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 450 | { |
drh | bb4957f | 2008-03-20 14:03:29 +0000 | [diff] [blame] | 451 | static const int cv_TEMP_STORE = TEMP_STORE; |
| 452 | Tcl_LinkVar(interp, "TEMP_STORE", (char *)&(cv_TEMP_STORE), |
| 453 | TCL_LINK_INT | TCL_LINK_READ_ONLY); |
danielk1977 | 832b266 | 2007-05-09 11:37:22 +0000 | [diff] [blame] | 454 | } |
drh | c797d4d | 2007-05-08 01:08:49 +0000 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | |
| 458 | /* |
| 459 | ** Register commands with the TCL interpreter. |
| 460 | */ |
| 461 | int Sqliteconfig_Init(Tcl_Interp *interp){ |
| 462 | set_options(interp); |
| 463 | return TCL_OK; |
| 464 | } |