Attempt to reduce the memory used by VALUES clauses in as many statements as possible...
[sqlite.git] / tool / mkctimec.tcl
blob9e425c0fdcb83969a5a8d44dbdc678d2c8b38f6c
1 #!/usr/bin/tclsh
3 # To build the
5 # const char **azCompileOpt[]
7 # definition used in src/ctime.c, run this script from
8 # the checkout root. It generates src/ctime.c .
10 # Results are normally written into src/ctime.c. But if an argument is
11 # provided, results are written there instead. Examples:
13 # tclsh tool/mkctimec.tcl ;# <-- results to src/ctime.c
15 # tclsh tool/mkctimec.tcl /dev/tty ;# <-- results to the terminal
19 set ::headWarning {/* DO NOT EDIT!
20 ** This file is automatically generated by the script in the canonical
21 ** SQLite source tree at tool/mkctimec.tcl.
23 ** To modify this header, edit any of the various lists in that script
24 ** which specify categories of generated conditionals in this file.
25 */}
27 # Make { and } easier to put into literals (even on EBCDIC machines.)
28 regexp {(\{)(\})} "{}" ma ::lb ::rb
30 set ::headCode "
32 ** 2010 February 23
34 ** The author disclaims copyright to this source code. In place of
35 ** a legal notice, here is a blessing:
37 ** May you do good and not evil.
38 ** May you find forgiveness for yourself and forgive others.
39 ** May you share freely, never taking more than you give.
41 *************************************************************************
43 ** This file implements routines used to report what compile-time options
44 ** SQLite was built with.
46 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS /* IMP: R-16824-07538 */
49 ** Include the configuration header output by 'configure' if we're using the
50 ** autoconf-based build
52 #if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
53 #include \"sqlite_cfg.h\"
54 #define SQLITECONFIG_H 1
55 #endif
57 /* These macros are provided to \"stringify\" the value of the define
58 ** for those options in which the value is meaningful. */
59 #define CTIMEOPT_VAL_(opt) #opt
60 #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
62 /* Like CTIMEOPT_VAL, but especially for SQLITE_DEFAULT_LOOKASIDE. This
63 ** option requires a separate macro because legal values contain a single
64 ** comma. e.g. (-DSQLITE_DEFAULT_LOOKASIDE=\"100,100\") */
65 #define CTIMEOPT_VAL2_(opt1,opt2) #opt1 \",\" #opt2
66 #define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt)
67 #include \"sqliteInt.h\"
70 ** An array of names of all compile-time options. This array should
71 ** be sorted A-Z.
73 ** This array looks large, but in a typical installation actually uses
74 ** only a handful of compile-time options, so most times this array is usually
75 ** rather short and uses little memory space.
77 static const char * const sqlite3azCompileOpt\[\] = $::lb
80 set ::tailCode "
81 $::rb ;
83 const char **sqlite3CompileOptions(int *pnOpt){
84 *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt\[0\]);
85 return (const char**)sqlite3azCompileOpt;
88 #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
91 # All Boolean compile time options which default to something
92 # other than 0 or empty. The default is paired with the PP
93 # symbol so that a differing define can be detected.
95 set boolean_defnnz_options {
96 {SQLITE_HOMEGROWN_RECURSIVE_MUTEX 1}
97 {SQLITE_POWERSAFE_OVERWRITE 1}
98 {SQLITE_DEFAULT_MEMSTATUS 1}
99 {SQLITE_OMIT_TRACE 1}
100 {SQLITE_ALLOW_COVERING_INDEX_SCAN 1}
103 # All Boolean compile time options which default to 0 or empty.
105 set boolean_defnil_options {
106 SQLITE_32BIT_ROWID
107 SQLITE_4_BYTE_ALIGNED_MALLOC
108 SQLITE_ALLOW_URI_AUTHORITY
109 SQLITE_BUG_COMPATIBLE_20160819
110 SQLITE_CASE_SENSITIVE_LIKE
111 SQLITE_CHECK_PAGES
112 SQLITE_COVERAGE_TEST
113 SQLITE_DEBUG
114 SQLITE_DEFAULT_AUTOMATIC_INDEX
115 SQLITE_DEFAULT_AUTOVACUUM
116 SQLITE_DEFAULT_CKPTFULLFSYNC
117 SQLITE_DEFAULT_FOREIGN_KEYS
118 SQLITE_DEFAULT_LOCKING_MODE
119 SQLITE_DEFAULT_RECURSIVE_TRIGGERS
120 SQLITE_DEFAULT_SYNCHRONOUS
121 SQLITE_DEFAULT_WAL_SYNCHRONOUS
122 SQLITE_DIRECT_OVERFLOW_READ
123 SQLITE_DISABLE_DIRSYNC
124 SQLITE_DISABLE_FTS3_UNICODE
125 SQLITE_DISABLE_FTS4_DEFERRED
126 SQLITE_DISABLE_INTRINSIC
127 SQLITE_DISABLE_LFS
128 SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
129 SQLITE_DISABLE_SKIPAHEAD_DISTINCT
130 SQLITE_ENABLE_8_3_NAMES
131 SQLITE_ENABLE_API_ARMOR
132 SQLITE_ENABLE_ATOMIC_WRITE
133 SQLITE_ENABLE_BATCH_ATOMIC_WRITE
134 SQLITE_ENABLE_BYTECODE_VTAB
135 SQLITE_ENABLE_COLUMN_METADATA
136 SQLITE_ENABLE_COLUMN_USED_MASK
137 SQLITE_ENABLE_COSTMULT
138 SQLITE_ENABLE_CURSOR_HINTS
139 SQLITE_ENABLE_DBPAGE_VTAB
140 SQLITE_ENABLE_DBSTAT_VTAB
141 SQLITE_ENABLE_EXPENSIVE_ASSERT
142 SQLITE_ENABLE_EXPLAIN_COMMENTS
143 SQLITE_ENABLE_FTS3
144 SQLITE_ENABLE_FTS3_PARENTHESIS
145 SQLITE_ENABLE_FTS3_TOKENIZER
146 SQLITE_ENABLE_FTS4
147 SQLITE_ENABLE_FTS5
148 SQLITE_ENABLE_GEOPOLY
149 SQLITE_ENABLE_HIDDEN_COLUMNS
150 SQLITE_ENABLE_ICU
151 SQLITE_ENABLE_IOTRACE
152 SQLITE_ENABLE_LOAD_EXTENSION
153 SQLITE_ENABLE_LOCKING_STYLE
154 SQLITE_ENABLE_MATH_FUNCTIONS
155 SQLITE_ENABLE_MEMORY_MANAGEMENT
156 SQLITE_ENABLE_MEMSYS3
157 SQLITE_ENABLE_MEMSYS5
158 SQLITE_ENABLE_MULTIPLEX
159 SQLITE_ENABLE_NORMALIZE
160 SQLITE_ENABLE_NULL_TRIM
161 SQLITE_ENABLE_OFFSET_SQL_FUNC
162 SQLITE_ENABLE_OVERSIZE_CELL_CHECK
163 SQLITE_ENABLE_PREUPDATE_HOOK
164 SQLITE_ENABLE_QPSG
165 SQLITE_ENABLE_RBU
166 SQLITE_ENABLE_RTREE
167 SQLITE_ENABLE_SESSION
168 SQLITE_ENABLE_SNAPSHOT
169 SQLITE_ENABLE_SORTER_REFERENCES
170 SQLITE_ENABLE_SQLLOG
171 SQLITE_ENABLE_STAT4
172 SQLITE_ENABLE_STMT_SCANSTATUS
173 SQLITE_ENABLE_STMTVTAB
174 SQLITE_ENABLE_TREETRACE
175 SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
176 SQLITE_ENABLE_UNLOCK_NOTIFY
177 SQLITE_ENABLE_UPDATE_DELETE_LIMIT
178 SQLITE_ENABLE_URI_00_ERROR
179 SQLITE_ENABLE_VFSTRACE
180 SQLITE_ENABLE_WHERETRACE
181 SQLITE_ENABLE_ZIPVFS
182 SQLITE_EXPLAIN_ESTIMATED_ROWS
183 SQLITE_EXTRA_IFNULLROW
184 SQLITE_FTS5_ENABLE_TEST_MI
185 SQLITE_FTS5_NO_WITHOUT_ROWID
186 SQLITE_IGNORE_AFP_LOCK_ERRORS
187 SQLITE_IGNORE_FLOCK_LOCK_ERRORS
188 SQLITE_INLINE_MEMCPY
189 SQLITE_INT64_TYPE
190 SQLITE_LEGACY_JSON_VALID
191 SQLITE_LIKE_DOESNT_MATCH_BLOBS
192 SQLITE_LOCK_TRACE
193 SQLITE_LOG_CACHE_SPILL
194 SQLITE_MEMDEBUG
195 SQLITE_MIXED_ENDIAN_64BIT_FLOAT
196 SQLITE_MMAP_READWRITE
197 SQLITE_MUTEX_NOOP
198 SQLITE_MUTEX_OMIT
199 SQLITE_MUTEX_PTHREADS
200 SQLITE_MUTEX_W32
201 SQLITE_NEED_ERR_NAME
202 SQLITE_NO_SYNC
203 SQLITE_OMIT_ALTERTABLE
204 SQLITE_OMIT_ANALYZE
205 SQLITE_OMIT_ATTACH
206 SQLITE_OMIT_AUTHORIZATION
207 SQLITE_OMIT_AUTOINCREMENT
208 SQLITE_OMIT_AUTOINIT
209 SQLITE_OMIT_AUTOMATIC_INDEX
210 SQLITE_OMIT_AUTORESET
211 SQLITE_OMIT_AUTOVACUUM
212 SQLITE_OMIT_BETWEEN_OPTIMIZATION
213 SQLITE_OMIT_BLOB_LITERAL
214 SQLITE_OMIT_CAST
215 SQLITE_OMIT_CHECK
216 SQLITE_OMIT_COMPLETE
217 SQLITE_OMIT_COMPOUND_SELECT
218 SQLITE_OMIT_CONFLICT_CLAUSE
219 SQLITE_OMIT_CTE
220 SQLITE_OMIT_DECLTYPE
221 SQLITE_OMIT_DEPRECATED
222 SQLITE_OMIT_DESERIALIZE
223 SQLITE_OMIT_DISKIO
224 SQLITE_OMIT_EXPLAIN
225 SQLITE_OMIT_FLAG_PRAGMAS
226 SQLITE_OMIT_FLOATING_POINT
227 SQLITE_OMIT_FOREIGN_KEY
228 SQLITE_OMIT_GET_TABLE
229 SQLITE_OMIT_HEX_INTEGER
230 SQLITE_OMIT_INCRBLOB
231 SQLITE_OMIT_INTEGRITY_CHECK
232 SQLITE_OMIT_INTROSPECTION_PRAGMAS
233 SQLITE_OMIT_JSON
234 SQLITE_OMIT_LIKE_OPTIMIZATION
235 SQLITE_OMIT_LOAD_EXTENSION
236 SQLITE_OMIT_LOCALTIME
237 SQLITE_OMIT_LOOKASIDE
238 SQLITE_OMIT_MEMORYDB
239 SQLITE_OMIT_OR_OPTIMIZATION
240 SQLITE_OMIT_PAGER_PRAGMAS
241 SQLITE_OMIT_PARSER_TRACE
242 SQLITE_OMIT_POPEN
243 SQLITE_OMIT_PRAGMA
244 SQLITE_OMIT_PROGRESS_CALLBACK
245 SQLITE_OMIT_QUICKBALANCE
246 SQLITE_OMIT_REINDEX
247 SQLITE_OMIT_SCHEMA_PRAGMAS
248 SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
249 SQLITE_OMIT_SEH
250 SQLITE_OMIT_SHARED_CACHE
251 SQLITE_OMIT_SHUTDOWN_DIRECTORIES
252 SQLITE_OMIT_SUBQUERY
253 SQLITE_OMIT_TCL_VARIABLE
254 SQLITE_OMIT_TEMPDB
255 SQLITE_OMIT_TEST_CONTROL
256 SQLITE_OMIT_TRIGGER
257 SQLITE_OMIT_TRUNCATE_OPTIMIZATION
258 SQLITE_OMIT_UTF16
259 SQLITE_OMIT_VACUUM
260 SQLITE_OMIT_VIEW
261 SQLITE_OMIT_VIRTUALTABLE
262 SQLITE_OMIT_WAL
263 SQLITE_OMIT_WSD
264 SQLITE_OMIT_XFER_OPT
265 SQLITE_PERFORMANCE_TRACE
266 SQLITE_PREFER_PROXY_LOCKING
267 SQLITE_PROXY_DEBUG
268 SQLITE_REVERSE_UNORDERED_SELECTS
269 SQLITE_RTREE_INT_ONLY
270 SQLITE_SECURE_DELETE
271 SQLITE_SMALL_STACK
272 SQLITE_SOUNDEX
273 SQLITE_SUBSTR_COMPATIBILITY
274 SQLITE_TCL
275 SQLITE_TEST
276 SQLITE_UNLINK_AFTER_CLOSE
277 SQLITE_UNTESTABLE
278 SQLITE_USE_ALLOCA
279 SQLITE_USE_FCNTL_TRACE
280 SQLITE_USER_AUTHENTICATION
281 SQLITE_USE_URI
282 SQLITE_VDBE_COVERAGE
283 SQLITE_WIN32_MALLOC
284 SQLITE_ZERO_MALLOC
287 # All compile time options for which the assigned value is other than boolean
288 # and is a comma-separated scalar pair.
290 set value2_options {
291 SQLITE_DEFAULT_LOOKASIDE
294 # All compile time options for which the assigned value is other than boolean
295 # and is a single scalar.
297 set value_options {
298 SQLITE_ATOMIC_INTRINSICS
299 SQLITE_BITMASK_TYPE
300 SQLITE_DEFAULT_CACHE_SIZE
301 SQLITE_DEFAULT_FILE_FORMAT
302 SQLITE_DEFAULT_FILE_PERMISSIONS
303 SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
304 SQLITE_DEFAULT_LOCKING_MODE
305 SQLITE_DEFAULT_MMAP_SIZE
306 SQLITE_DEFAULT_PAGE_SIZE
307 SQLITE_DEFAULT_PCACHE_INITSZ
308 SQLITE_DEFAULT_PROXYDIR_PERMISSIONS
309 SQLITE_DEFAULT_ROWEST
310 SQLITE_DEFAULT_SECTOR_SIZE
311 SQLITE_DEFAULT_SYNCHRONOUS
312 SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
313 SQLITE_DEFAULT_WAL_SYNCHRONOUS
314 SQLITE_DEFAULT_WORKER_THREADS
315 SQLITE_DQS
316 SQLITE_ENABLE_8_3_NAMES
317 SQLITE_ENABLE_CEROD
318 SQLITE_ENABLE_LOCKING_STYLE
319 SQLITE_EXTRA_AUTOEXT
320 SQLITE_EXTRA_INIT
321 SQLITE_EXTRA_SHUTDOWN
322 SQLITE_FTS3_MAX_EXPR_DEPTH
323 SQLITE_INTEGRITY_CHECK_ERROR_MAX
324 SQLITE_MALLOC_SOFT_LIMIT
325 SQLITE_MAX_ATTACHED
326 SQLITE_MAX_COLUMN
327 SQLITE_MAX_COMPOUND_SELECT
328 SQLITE_MAX_DEFAULT_PAGE_SIZE
329 SQLITE_MAX_EXPR_DEPTH
330 SQLITE_MAX_FUNCTION_ARG
331 SQLITE_MAX_LENGTH
332 SQLITE_MAX_LIKE_PATTERN_LENGTH
333 SQLITE_MAX_MEMORY
334 SQLITE_MAX_MMAP_SIZE
335 SQLITE_MAX_MMAP_SIZE_
336 SQLITE_MAX_PAGE_COUNT
337 SQLITE_MAX_PAGE_SIZE
338 SQLITE_MAX_SCHEMA_RETRY
339 SQLITE_MAX_SQL_LENGTH
340 SQLITE_MAX_TRIGGER_DEPTH
341 SQLITE_MAX_VARIABLE_NUMBER
342 SQLITE_MAX_VDBE_OP
343 SQLITE_MAX_WORKER_THREADS
344 SQLITE_SORTER_PMASZ
345 SQLITE_STAT4_SAMPLES
346 SQLITE_STMTJRNL_SPILL
347 SQLITE_TEMP_STORE
350 # Options that require custom code.
352 set options(COMPILER) {
353 #if defined(__clang__) && defined(__clang_major__)
354 "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "."
355 CTIMEOPT_VAL(__clang_minor__) "."
356 CTIMEOPT_VAL(__clang_patchlevel__),
357 #elif defined(_MSC_VER)
358 "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER),
359 #elif defined(__GNUC__) && defined(__VERSION__)
360 "COMPILER=gcc-" __VERSION__,
361 #endif
363 set options(HAVE_ISNAN) {
364 #if HAVE_ISNAN || SQLITE_HAVE_ISNAN
365 "HAVE_ISNAN",
366 #endif
368 set options(OMIT_DATETIME_FUNCS) {
369 #if defined(SQLITE_OMIT_DATETIME_FUNCS) || defined(SQLITE_OMIT_FLOATING_POINT)
370 "OMIT_DATETIME_FUNCS",
371 #endif
373 set options(SYSTEM_MALLOC) "\
374 #if (!defined(SQLITE_WIN32_MALLOC) \\
375 && !defined(SQLITE_ZERO_MALLOC) \\
376 && !defined(SQLITE_MEMDEBUG) \\
377 ) || defined(SQLITE_SYSTEM_MALLOC)
378 \"SYSTEM_MALLOC\",
379 #endif
381 set options(THREADSAFE) {
382 #if defined(SQLITE_THREADSAFE)
383 "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
384 #elif defined(THREADSAFE)
385 "THREADSAFE=" CTIMEOPT_VAL(THREADSAFE),
386 #else
387 "THREADSAFE=1",
388 #endif
391 proc trim_name {in} {
392 set ret $in
393 if {[string range $in 0 6]=="SQLITE_"} {
394 set ret [string range $in 7 end]
396 return $ret
399 foreach name_defval $boolean_defnnz_options {
400 set b [lindex $name_defval 0]
401 set defval [lindex $name_defval 1]
402 set name [trim_name $b]
403 set options($name) [subst {
404 #ifdef $b
405 # if $b != $defval
406 "$name=" CTIMEOPT_VAL($b),
407 # endif
408 #endif
412 foreach b $boolean_defnil_options {
413 set name [trim_name $b]
414 set options($name) [subst {
415 #ifdef $b
416 "$name",
417 #endif
421 foreach v $value_options {
422 set name [trim_name $v]
423 set options($name) [subst {
424 #ifdef $v
425 "$name=" CTIMEOPT_VAL($v),
426 #endif
430 foreach v $value2_options {
431 set name [trim_name $v]
432 set options($name) [subst {
433 #ifdef $v
434 "$name=" CTIMEOPT_VAL2($v),
435 #endif
439 if {$argc>0} {
440 set destfile [lindex $argv 0]
441 } else {
442 set destfile "[file dir [file dir [file normal $argv0]]]/src/ctime.c"
443 puts "Overwriting $destfile..."
446 if {[catch {set cfd [open $destfile w]}]!=0} {
447 puts stderr "File '$destfile' unwritable."
448 exit 1;
451 puts $cfd $::headWarning;
452 puts $cfd $::headCode;
453 foreach o [lsort [array names options]] {
454 puts $cfd [string trim $options($o)]
456 puts -nonewline $cfd $::tailCode;
458 close $cfd