First public contribution.
4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing:
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.
11 *************************************************************************
13 ** This file contains code used for testing the SQLite system.
14 ** None of the code in this file goes into a deliverable build.
16 ** The focus of this file is providing the TCL testing layer
17 ** access to compile-time constants.
19 ** $Id: test_config.c,v 1.37 2008/09/23 10:16:05 drh Exp $
22 #include "sqliteLimit.h"
24 #include "sqliteInt.h"
30 ** Macro to stringify the results of the evaluation a pre-processor
31 ** macro. i.e. so that STRINGVALUE(SQLITE_NOMEM) -> "7".
33 #define STRINGVALUE2(x) #x
34 #define STRINGVALUE(x) STRINGVALUE2(x)
37 ** This routine sets entries in the global ::sqlite_options() array variable
38 ** according to the compile-time configuration of the database. Test
39 ** procedures use this to determine when tests should be omitted.
41 static void set_options(Tcl_Interp *interp){
42 #ifdef SQLITE_32BIT_ROWID
43 Tcl_SetVar2(interp, "sqlite_options", "rowid32", "1", TCL_GLOBAL_ONLY);
45 Tcl_SetVar2(interp, "sqlite_options", "rowid32", "0", TCL_GLOBAL_ONLY);
48 #ifdef SQLITE_CASE_SENSITIVE_LIKE
49 Tcl_SetVar2(interp, "sqlite_options","casesensitivelike","1",TCL_GLOBAL_ONLY);
51 Tcl_SetVar2(interp, "sqlite_options","casesensitivelike","0",TCL_GLOBAL_ONLY);
55 Tcl_SetVar2(interp, "sqlite_options", "debug", "1", TCL_GLOBAL_ONLY);
57 Tcl_SetVar2(interp, "sqlite_options", "debug", "0", TCL_GLOBAL_ONLY);
60 #ifdef SQLITE_DISABLE_DIRSYNC
61 Tcl_SetVar2(interp, "sqlite_options", "dirsync", "0", TCL_GLOBAL_ONLY);
63 Tcl_SetVar2(interp, "sqlite_options", "dirsync", "1", TCL_GLOBAL_ONLY);
66 #ifdef SQLITE_DISABLE_LFS
67 Tcl_SetVar2(interp, "sqlite_options", "lfs", "0", TCL_GLOBAL_ONLY);
69 Tcl_SetVar2(interp, "sqlite_options", "lfs", "1", TCL_GLOBAL_ONLY);
72 #if 1 /* def SQLITE_MEMDEBUG */
73 Tcl_SetVar2(interp, "sqlite_options", "memdebug", "1", TCL_GLOBAL_ONLY);
75 Tcl_SetVar2(interp, "sqlite_options", "memdebug", "0", TCL_GLOBAL_ONLY);
78 #ifdef SQLITE_ENABLE_MEMSYS3
79 Tcl_SetVar2(interp, "sqlite_options", "mem3", "1", TCL_GLOBAL_ONLY);
81 Tcl_SetVar2(interp, "sqlite_options", "mem3", "0", TCL_GLOBAL_ONLY);
84 #ifdef SQLITE_ENABLE_MEMSYS5
85 Tcl_SetVar2(interp, "sqlite_options", "mem5", "1", TCL_GLOBAL_ONLY);
87 Tcl_SetVar2(interp, "sqlite_options", "mem5", "0", TCL_GLOBAL_ONLY);
90 #ifdef SQLITE_OMIT_ALTERTABLE
91 Tcl_SetVar2(interp, "sqlite_options", "altertable", "0", TCL_GLOBAL_ONLY);
93 Tcl_SetVar2(interp, "sqlite_options", "altertable", "1", TCL_GLOBAL_ONLY);
96 #ifdef SQLITE_OMIT_ANALYZE
97 Tcl_SetVar2(interp, "sqlite_options", "analyze", "0", TCL_GLOBAL_ONLY);
99 Tcl_SetVar2(interp, "sqlite_options", "analyze", "1", TCL_GLOBAL_ONLY);
102 #ifdef SQLITE_ENABLE_ATOMIC_WRITE
103 Tcl_SetVar2(interp, "sqlite_options", "atomicwrite", "1", TCL_GLOBAL_ONLY);
105 Tcl_SetVar2(interp, "sqlite_options", "atomicwrite", "0", TCL_GLOBAL_ONLY);
108 #ifdef SQLITE_OMIT_ATTACH
109 Tcl_SetVar2(interp, "sqlite_options", "attach", "0", TCL_GLOBAL_ONLY);
111 Tcl_SetVar2(interp, "sqlite_options", "attach", "1", TCL_GLOBAL_ONLY);
114 #ifdef SQLITE_OMIT_AUTHORIZATION
115 Tcl_SetVar2(interp, "sqlite_options", "auth", "0", TCL_GLOBAL_ONLY);
117 Tcl_SetVar2(interp, "sqlite_options", "auth", "1", TCL_GLOBAL_ONLY);
120 #ifdef SQLITE_OMIT_AUTOINCREMENT
121 Tcl_SetVar2(interp, "sqlite_options", "autoinc", "0", TCL_GLOBAL_ONLY);
123 Tcl_SetVar2(interp, "sqlite_options", "autoinc", "1", TCL_GLOBAL_ONLY);
126 #ifdef SQLITE_OMIT_AUTOVACUUM
127 Tcl_SetVar2(interp, "sqlite_options", "autovacuum", "0", TCL_GLOBAL_ONLY);
129 Tcl_SetVar2(interp, "sqlite_options", "autovacuum", "1", TCL_GLOBAL_ONLY);
130 #endif /* SQLITE_OMIT_AUTOVACUUM */
131 #if !defined(SQLITE_DEFAULT_AUTOVACUUM)
132 Tcl_SetVar2(interp,"sqlite_options","default_autovacuum","0",TCL_GLOBAL_ONLY);
134 Tcl_SetVar2(interp, "sqlite_options", "default_autovacuum",
135 STRINGVALUE(SQLITE_DEFAULT_AUTOVACUUM), TCL_GLOBAL_ONLY);
138 #ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION
139 Tcl_SetVar2(interp, "sqlite_options", "between_opt", "0", TCL_GLOBAL_ONLY);
141 Tcl_SetVar2(interp, "sqlite_options", "between_opt", "1", TCL_GLOBAL_ONLY);
144 #ifdef SQLITE_OMIT_BUILTIN_TEST
145 Tcl_SetVar2(interp, "sqlite_options", "builtin_test", "0", TCL_GLOBAL_ONLY);
147 Tcl_SetVar2(interp, "sqlite_options", "builtin_test", "1", TCL_GLOBAL_ONLY);
150 #ifdef SQLITE_OMIT_BLOB_LITERAL
151 Tcl_SetVar2(interp, "sqlite_options", "bloblit", "0", TCL_GLOBAL_ONLY);
153 Tcl_SetVar2(interp, "sqlite_options", "bloblit", "1", TCL_GLOBAL_ONLY);
156 #ifdef SQLITE_OMIT_CAST
157 Tcl_SetVar2(interp, "sqlite_options", "cast", "0", TCL_GLOBAL_ONLY);
159 Tcl_SetVar2(interp, "sqlite_options", "cast", "1", TCL_GLOBAL_ONLY);
162 #ifdef SQLITE_OMIT_CHECK
163 Tcl_SetVar2(interp, "sqlite_options", "check", "0", TCL_GLOBAL_ONLY);
165 Tcl_SetVar2(interp, "sqlite_options", "check", "1", TCL_GLOBAL_ONLY);
168 #ifdef SQLITE_ENABLE_COLUMN_METADATA
169 Tcl_SetVar2(interp, "sqlite_options", "columnmetadata", "1", TCL_GLOBAL_ONLY);
171 Tcl_SetVar2(interp, "sqlite_options", "columnmetadata", "0", TCL_GLOBAL_ONLY);
174 #ifdef SQLITE_OMIT_COMPLETE
175 Tcl_SetVar2(interp, "sqlite_options", "complete", "0", TCL_GLOBAL_ONLY);
177 Tcl_SetVar2(interp, "sqlite_options", "complete", "1", TCL_GLOBAL_ONLY);
180 #ifdef SQLITE_OMIT_COMPOUND_SELECT
181 Tcl_SetVar2(interp, "sqlite_options", "compound", "0", TCL_GLOBAL_ONLY);
183 Tcl_SetVar2(interp, "sqlite_options", "compound", "1", TCL_GLOBAL_ONLY);
186 #ifdef SQLITE_OMIT_CONFLICT_CLAUSE
187 Tcl_SetVar2(interp, "sqlite_options", "conflict", "0", TCL_GLOBAL_ONLY);
189 Tcl_SetVar2(interp, "sqlite_options", "conflict", "1", TCL_GLOBAL_ONLY);
193 Tcl_SetVar2(interp, "sqlite_options", "crashtest", "1", TCL_GLOBAL_ONLY);
195 Tcl_SetVar2(interp, "sqlite_options", "crashtest", "0", TCL_GLOBAL_ONLY);
198 #ifdef SQLITE_OMIT_DATETIME_FUNCS
199 Tcl_SetVar2(interp, "sqlite_options", "datetime", "0", TCL_GLOBAL_ONLY);
201 Tcl_SetVar2(interp, "sqlite_options", "datetime", "1", TCL_GLOBAL_ONLY);
204 #ifdef SQLITE_OMIT_DECLTYPE
205 Tcl_SetVar2(interp, "sqlite_options", "decltype", "0", TCL_GLOBAL_ONLY);
207 Tcl_SetVar2(interp, "sqlite_options", "decltype", "1", TCL_GLOBAL_ONLY);
210 #ifdef SQLITE_OMIT_DISKIO
211 Tcl_SetVar2(interp, "sqlite_options", "diskio", "0", TCL_GLOBAL_ONLY);
213 Tcl_SetVar2(interp, "sqlite_options", "diskio", "1", TCL_GLOBAL_ONLY);
216 #ifdef SQLITE_OMIT_EXPLAIN
217 Tcl_SetVar2(interp, "sqlite_options", "explain", "0", TCL_GLOBAL_ONLY);
219 Tcl_SetVar2(interp, "sqlite_options", "explain", "1", TCL_GLOBAL_ONLY);
222 #ifdef SQLITE_OMIT_FLOATING_POINT
223 Tcl_SetVar2(interp, "sqlite_options", "floatingpoint", "0", TCL_GLOBAL_ONLY);
225 Tcl_SetVar2(interp, "sqlite_options", "floatingpoint", "1", TCL_GLOBAL_ONLY);
228 #ifdef SQLITE_OMIT_FOREIGN_KEY
229 Tcl_SetVar2(interp, "sqlite_options", "foreignkey", "0", TCL_GLOBAL_ONLY);
231 Tcl_SetVar2(interp, "sqlite_options", "foreignkey", "1", TCL_GLOBAL_ONLY);
234 #ifdef SQLITE_ENABLE_FTS1
235 Tcl_SetVar2(interp, "sqlite_options", "fts1", "1", TCL_GLOBAL_ONLY);
237 Tcl_SetVar2(interp, "sqlite_options", "fts1", "0", TCL_GLOBAL_ONLY);
240 #ifdef SQLITE_ENABLE_FTS2
241 Tcl_SetVar2(interp, "sqlite_options", "fts2", "1", TCL_GLOBAL_ONLY);
243 Tcl_SetVar2(interp, "sqlite_options", "fts2", "0", TCL_GLOBAL_ONLY);
246 #ifdef SQLITE_ENABLE_FTS3
247 Tcl_SetVar2(interp, "sqlite_options", "fts3", "1", TCL_GLOBAL_ONLY);
249 Tcl_SetVar2(interp, "sqlite_options", "fts3", "0", TCL_GLOBAL_ONLY);
252 #ifdef SQLITE_OMIT_GET_TABLE
253 Tcl_SetVar2(interp, "sqlite_options", "gettable", "0", TCL_GLOBAL_ONLY);
255 Tcl_SetVar2(interp, "sqlite_options", "gettable", "1", TCL_GLOBAL_ONLY);
258 #ifdef SQLITE_OMIT_GLOBALRECOVER
259 Tcl_SetVar2(interp, "sqlite_options", "globalrecover", "0", TCL_GLOBAL_ONLY);
261 Tcl_SetVar2(interp, "sqlite_options", "globalrecover", "1", TCL_GLOBAL_ONLY);
264 #ifdef SQLITE_ENABLE_ICU
265 Tcl_SetVar2(interp, "sqlite_options", "icu", "1", TCL_GLOBAL_ONLY);
267 Tcl_SetVar2(interp, "sqlite_options", "icu", "0", TCL_GLOBAL_ONLY);
270 #ifdef SQLITE_OMIT_INCRBLOB
271 Tcl_SetVar2(interp, "sqlite_options", "incrblob", "0", TCL_GLOBAL_ONLY);
273 Tcl_SetVar2(interp, "sqlite_options", "incrblob", "1", TCL_GLOBAL_ONLY);
274 #endif /* SQLITE_OMIT_AUTOVACUUM */
276 #ifdef SQLITE_OMIT_INTEGRITY_CHECK
277 Tcl_SetVar2(interp, "sqlite_options", "integrityck", "0", TCL_GLOBAL_ONLY);
279 Tcl_SetVar2(interp, "sqlite_options", "integrityck", "1", TCL_GLOBAL_ONLY);
282 #if defined(SQLITE_DEFAULT_FILE_FORMAT) && SQLITE_DEFAULT_FILE_FORMAT==1
283 Tcl_SetVar2(interp, "sqlite_options", "legacyformat", "1", TCL_GLOBAL_ONLY);
285 Tcl_SetVar2(interp, "sqlite_options", "legacyformat", "0", TCL_GLOBAL_ONLY);
288 #ifdef SQLITE_OMIT_LIKE_OPTIMIZATION
289 Tcl_SetVar2(interp, "sqlite_options", "like_opt", "0", TCL_GLOBAL_ONLY);
291 Tcl_SetVar2(interp, "sqlite_options", "like_opt", "1", TCL_GLOBAL_ONLY);
294 #ifdef SQLITE_OMIT_LOAD_EXTENSION
295 Tcl_SetVar2(interp, "sqlite_options", "load_ext", "0", TCL_GLOBAL_ONLY);
297 Tcl_SetVar2(interp, "sqlite_options", "load_ext", "1", TCL_GLOBAL_ONLY);
300 #ifdef SQLITE_OMIT_LOCALTIME
301 Tcl_SetVar2(interp, "sqlite_options", "localtime", "0", TCL_GLOBAL_ONLY);
303 Tcl_SetVar2(interp, "sqlite_options", "localtime", "1", TCL_GLOBAL_ONLY);
306 Tcl_SetVar2(interp, "sqlite_options", "long_double",
307 sizeof(LONGDOUBLE_TYPE)>sizeof(double) ? "1" : "0",
310 #ifdef SQLITE_OMIT_MEMORYDB
311 Tcl_SetVar2(interp, "sqlite_options", "memorydb", "0", TCL_GLOBAL_ONLY);
313 Tcl_SetVar2(interp, "sqlite_options", "memorydb", "1", TCL_GLOBAL_ONLY);
316 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
317 Tcl_SetVar2(interp, "sqlite_options", "memorymanage", "1", TCL_GLOBAL_ONLY);
319 Tcl_SetVar2(interp, "sqlite_options", "memorymanage", "0", TCL_GLOBAL_ONLY);
322 #ifdef SQLITE_OMIT_OR_OPTIMIZATION
323 Tcl_SetVar2(interp, "sqlite_options", "or_opt", "0", TCL_GLOBAL_ONLY);
325 Tcl_SetVar2(interp, "sqlite_options", "or_opt", "1", TCL_GLOBAL_ONLY);
328 #ifdef SQLITE_OMIT_PAGER_PRAGMAS
329 Tcl_SetVar2(interp, "sqlite_options", "pager_pragmas", "0", TCL_GLOBAL_ONLY);
331 Tcl_SetVar2(interp, "sqlite_options", "pager_pragmas", "1", TCL_GLOBAL_ONLY);
334 #ifdef SQLITE_OMIT_PARSER
335 Tcl_SetVar2(interp, "sqlite_options", "parser", "0", TCL_GLOBAL_ONLY);
337 Tcl_SetVar2(interp, "sqlite_options", "parser", "1", TCL_GLOBAL_ONLY);
340 #if defined(SQLITE_OMIT_PRAGMA) || defined(SQLITE_OMIT_FLAG_PRAGMAS)
341 Tcl_SetVar2(interp, "sqlite_options", "pragma", "0", TCL_GLOBAL_ONLY);
342 Tcl_SetVar2(interp, "sqlite_options", "integrityck", "0", TCL_GLOBAL_ONLY);
344 Tcl_SetVar2(interp, "sqlite_options", "pragma", "1", TCL_GLOBAL_ONLY);
347 #ifdef SQLITE_OMIT_PROGRESS_CALLBACK
348 Tcl_SetVar2(interp, "sqlite_options", "progress", "0", TCL_GLOBAL_ONLY);
350 Tcl_SetVar2(interp, "sqlite_options", "progress", "1", TCL_GLOBAL_ONLY);
353 #ifdef SQLITE_OMIT_REINDEX
354 Tcl_SetVar2(interp, "sqlite_options", "reindex", "0", TCL_GLOBAL_ONLY);
356 Tcl_SetVar2(interp, "sqlite_options", "reindex", "1", TCL_GLOBAL_ONLY);
359 #ifdef SQLITE_ENABLE_RTREE
360 Tcl_SetVar2(interp, "sqlite_options", "rtree", "1", TCL_GLOBAL_ONLY);
362 Tcl_SetVar2(interp, "sqlite_options", "rtree", "0", TCL_GLOBAL_ONLY);
365 #ifdef SQLITE_OMIT_SCHEMA_PRAGMAS
366 Tcl_SetVar2(interp, "sqlite_options", "schema_pragmas", "0", TCL_GLOBAL_ONLY);
368 Tcl_SetVar2(interp, "sqlite_options", "schema_pragmas", "1", TCL_GLOBAL_ONLY);
371 #ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
372 Tcl_SetVar2(interp, "sqlite_options", "schema_version", "0", TCL_GLOBAL_ONLY);
374 Tcl_SetVar2(interp, "sqlite_options", "schema_version", "1", TCL_GLOBAL_ONLY);
377 #ifdef SQLITE_OMIT_SHARED_CACHE
378 Tcl_SetVar2(interp, "sqlite_options", "shared_cache", "0", TCL_GLOBAL_ONLY);
380 Tcl_SetVar2(interp, "sqlite_options", "shared_cache", "1", TCL_GLOBAL_ONLY);
383 #ifdef SQLITE_OMIT_SUBQUERY
384 Tcl_SetVar2(interp, "sqlite_options", "subquery", "0", TCL_GLOBAL_ONLY);
386 Tcl_SetVar2(interp, "sqlite_options", "subquery", "1", TCL_GLOBAL_ONLY);
389 #ifdef SQLITE_OMIT_TCL_VARIABLE
390 Tcl_SetVar2(interp, "sqlite_options", "tclvar", "0", TCL_GLOBAL_ONLY);
392 Tcl_SetVar2(interp, "sqlite_options", "tclvar", "1", TCL_GLOBAL_ONLY);
395 Tcl_SetVar2(interp, "sqlite_options", "threadsafe",
396 STRINGVALUE(SQLITE_THREADSAFE), TCL_GLOBAL_ONLY);
397 assert( sqlite3_threadsafe()==SQLITE_THREADSAFE );
399 #ifdef SQLITE_OMIT_TRACE
400 Tcl_SetVar2(interp, "sqlite_options", "trace", "0", TCL_GLOBAL_ONLY);
402 Tcl_SetVar2(interp, "sqlite_options", "trace", "1", TCL_GLOBAL_ONLY);
405 #ifdef SQLITE_OMIT_TRIGGER
406 Tcl_SetVar2(interp, "sqlite_options", "trigger", "0", TCL_GLOBAL_ONLY);
408 Tcl_SetVar2(interp, "sqlite_options", "trigger", "1", TCL_GLOBAL_ONLY);
411 #ifdef SQLITE_OMIT_TEMPDB
412 Tcl_SetVar2(interp, "sqlite_options", "tempdb", "0", TCL_GLOBAL_ONLY);
414 Tcl_SetVar2(interp, "sqlite_options", "tempdb", "1", TCL_GLOBAL_ONLY);
417 #ifdef SQLITE_OMIT_UTF16
418 Tcl_SetVar2(interp, "sqlite_options", "utf16", "0", TCL_GLOBAL_ONLY);
420 Tcl_SetVar2(interp, "sqlite_options", "utf16", "1", TCL_GLOBAL_ONLY);
423 #if defined(SQLITE_OMIT_VACUUM) || defined(SQLITE_OMIT_ATTACH)
424 Tcl_SetVar2(interp, "sqlite_options", "vacuum", "0", TCL_GLOBAL_ONLY);
426 Tcl_SetVar2(interp, "sqlite_options", "vacuum", "1", TCL_GLOBAL_ONLY);
429 #ifdef SQLITE_OMIT_VIEW
430 Tcl_SetVar2(interp, "sqlite_options", "view", "0", TCL_GLOBAL_ONLY);
432 Tcl_SetVar2(interp, "sqlite_options", "view", "1", TCL_GLOBAL_ONLY);
435 #ifdef SQLITE_OMIT_VIRTUALTABLE
436 Tcl_SetVar2(interp, "sqlite_options", "vtab", "0", TCL_GLOBAL_ONLY);
438 Tcl_SetVar2(interp, "sqlite_options", "vtab", "1", TCL_GLOBAL_ONLY);
441 #ifdef SQLITE_OMIT_WSD
442 Tcl_SetVar2(interp, "sqlite_options", "wsd", "0", TCL_GLOBAL_ONLY);
444 Tcl_SetVar2(interp, "sqlite_options", "wsd", "1", TCL_GLOBAL_ONLY);
447 #ifdef SQLITE_SECURE_DELETE
448 Tcl_SetVar2(interp, "sqlite_options", "secure_delete", "1", TCL_GLOBAL_ONLY);
450 Tcl_SetVar2(interp, "sqlite_options", "secure_delete", "0", TCL_GLOBAL_ONLY);
453 #ifdef YYTRACKMAXSTACKDEPTH
454 Tcl_SetVar2(interp, "sqlite_options", "yytrackmaxstackdepth", "1", TCL_GLOBAL_ONLY);
456 Tcl_SetVar2(interp, "sqlite_options", "yytrackmaxstackdepth", "0", TCL_GLOBAL_ONLY);
459 #define LINKVAR(x) { \
460 static const int cv_ ## x = SQLITE_ ## x; \
461 Tcl_LinkVar(interp, "SQLITE_" #x, (char *)&(cv_ ## x), \
462 TCL_LINK_INT | TCL_LINK_READ_ONLY); }
464 LINKVAR( MAX_LENGTH );
465 LINKVAR( MAX_COLUMN );
466 LINKVAR( MAX_SQL_LENGTH );
467 LINKVAR( MAX_EXPR_DEPTH );
468 LINKVAR( MAX_COMPOUND_SELECT );
469 LINKVAR( MAX_VDBE_OP );
470 LINKVAR( MAX_FUNCTION_ARG );
471 LINKVAR( MAX_VARIABLE_NUMBER );
472 LINKVAR( MAX_PAGE_SIZE );
473 LINKVAR( MAX_PAGE_COUNT );
474 LINKVAR( MAX_LIKE_PATTERN_LENGTH );
475 LINKVAR( DEFAULT_TEMP_CACHE_SIZE );
476 LINKVAR( DEFAULT_CACHE_SIZE );
477 LINKVAR( DEFAULT_PAGE_SIZE );
478 LINKVAR( DEFAULT_FILE_FORMAT );
479 LINKVAR( MAX_ATTACHED );
482 static const int cv_TEMP_STORE = SQLITE_TEMP_STORE;
483 Tcl_LinkVar(interp, "TEMP_STORE", (char *)&(cv_TEMP_STORE),
484 TCL_LINK_INT | TCL_LINK_READ_ONLY);
490 ** Register commands with the TCL interpreter.
492 int Sqliteconfig_Init(Tcl_Interp *interp){