3 # Run this script to generate the pragma name lookup table C code.
5 # To add new pragmas, first add the name and other relevant attributes
6 # of the pragma to the "pragma_def" object below. Then run this script
7 # to generate the ../src/pragma.h header file that contains macros and
8 # the lookup table needed for pragma name lookup in the pragma.c module.
9 # Then add the extra "case PragTyp_XXXXX:" and subsequent code for the
10 # new pragma in ../src/pragma.c.
14 set flagMeaning
(NeedSchema
) {Force schema
load before running
}
15 set flagMeaning
(ReadOnly
) {Read-only HEADER_VALUE
}
16 set flagMeaning
(Result0
) {Acts as query when no argument
}
17 set flagMeaning
(Result1
) {Acts as query when has one argument
}
18 set flagMeaning
(SchemaReq
) {Schema required
- "main" is
default}
19 set flagMeaning
(SchemaOpt
) {Schema restricts name search
if present
}
20 set flagMeaning
(NoColumns
) {OP_ResultRow called with zero columns
}
21 set flagMeaning
(NoColumns1
) {zero columns
if RHS argument is present
}
24 NAME
: full_column_names
26 ARG
: SQLITE_FullColNames
27 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
29 NAME
: short_column_names
31 ARG
: SQLITE_ShortColNames
32 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
37 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
39 NAME
: empty_result_callbacks
41 ARG
: SQLITE_NullCallback
42 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
44 NAME
: legacy_file_format
46 ARG
: SQLITE_LegacyFileFmt
47 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
52 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
54 NAME
: checkpoint_fullfsync
56 ARG
: SQLITE_CkptFullFSync
57 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
60 FLAG
: Result0 SchemaReq NoColumns1
61 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
63 NAME
: reverse_unordered_selects
65 ARG
: SQLITE_ReverseOrder
66 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
71 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
76 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
77 IF
: !defined
(SQLITE_OMIT_AUTOMATIC_INDEX
)
82 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
83 IF
: defined
(SQLITE_DEBUG
)
87 ARG
: SQLITE_VdbeListing
88 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
89 IF
: defined
(SQLITE_DEBUG
)
94 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
95 IF
: defined
(SQLITE_DEBUG
)
99 ARG
: SQLITE_VdbeAddopTrace
100 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
101 IF
: defined
(SQLITE_DEBUG
)
105 ARG
: SQLITE_SqlTrace|SQLITE_VdbeListing|SQLITE_VdbeTrace
106 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
107 IF
: defined
(SQLITE_DEBUG
)
112 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
113 IF
: defined
(SQLITE_DEBUG
)
115 NAME
: ignore_check_constraints
117 ARG
: SQLITE_IgnoreChecks
118 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
119 IF
: !defined
(SQLITE_OMIT_CHECK
)
121 NAME
: writable_schema
123 ARG
: SQLITE_WriteSchema
124 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
126 NAME
: read_uncommitted
128 ARG
: SQLITE_ReadUncommit
129 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
131 NAME
: recursive_triggers
133 ARG
: SQLITE_RecTriggers
134 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
138 ARG
: SQLITE_ForeignKeys
139 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
140 IF
: !defined
(SQLITE_OMIT_FOREIGN_KEY
) && !defined
(SQLITE_OMIT_TRIGGER
)
142 NAME
: defer_foreign_keys
145 IF
: !defined
(SQLITE_OMIT_FLAG_PRAGMAS
)
146 IF
: !defined
(SQLITE_OMIT_FOREIGN_KEY
) && !defined
(SQLITE_OMIT_TRIGGER
)
148 NAME
: cell_size_check
150 ARG
: SQLITE_CellSizeCk
152 NAME
: default_cache_size
153 FLAG
: NeedSchema Result0 SchemaReq NoColumns1
155 IF
: !defined
(SQLITE_OMIT_PAGER_PRAGMAS
) && !defined
(SQLITE_OMIT_DEPRECATED
)
158 FLAG
: Result0 SchemaReq NoColumns1
159 IF
: !defined
(SQLITE_OMIT_PAGER_PRAGMAS
)
163 IF
: !defined
(SQLITE_OMIT_PAGER_PRAGMAS
)
166 FLAG
: NeedSchema Result0 SchemaReq
167 IF
: !defined
(SQLITE_OMIT_PAGER_PRAGMAS
)
171 FLAG
: NeedSchema Result0 SchemaReq
172 IF
: !defined
(SQLITE_OMIT_PAGER_PRAGMAS
)
175 FLAG
: Result0 SchemaReq
176 IF
: !defined
(SQLITE_OMIT_PAGER_PRAGMAS
)
179 FLAG
: NeedSchema Result0 SchemaReq
180 IF
: !defined
(SQLITE_OMIT_PAGER_PRAGMAS
)
182 NAME
: journal_size_limit
183 FLAG
: Result0 SchemaReq
184 IF
: !defined
(SQLITE_OMIT_PAGER_PRAGMAS
)
187 FLAG
: NeedSchema Result0 SchemaReq NoColumns1
188 IF
: !defined
(SQLITE_OMIT_PAGER_PRAGMAS
)
191 IF
: !defined
(SQLITE_OMIT_PAGER_PRAGMAS
)
194 FLAG
: NeedSchema Result0 SchemaReq NoColumns1
195 IF
: !defined
(SQLITE_OMIT_AUTOVACUUM
)
197 NAME
: incremental_vacuum
198 FLAG
: NeedSchema NoColumns
199 IF
: !defined
(SQLITE_OMIT_AUTOVACUUM
)
202 FLAG
: Result0 NoColumns1
203 IF
: !defined
(SQLITE_OMIT_PAGER_PRAGMAS
)
205 NAME
: temp_store_directory
207 IF
: !defined
(SQLITE_OMIT_PAGER_PRAGMAS
)
209 NAME
: data_store_directory
211 IF
: !defined
(SQLITE_OMIT_PAGER_PRAGMAS
) && SQLITE_OS_WIN
213 NAME
: lock_proxy_file
215 IF
: !defined
(SQLITE_OMIT_PAGER_PRAGMAS
) && SQLITE_ENABLE_LOCKING_STYLE
218 FLAG
: NeedSchema Result0 SchemaReq NoColumns1
219 IF
: !defined
(SQLITE_OMIT_PAGER_PRAGMAS
)
222 FLAG
: NeedSchema Result1 SchemaOpt
223 COLS
: cid name type notnull dflt_value pk
224 IF
: !defined
(SQLITE_OMIT_SCHEMA_PRAGMAS
)
227 FLAG
: NeedSchema Result0 SchemaReq
228 COLS
: tbl idx wdth hght flgs
229 IF
: !defined
(SQLITE_OMIT_SCHEMA_PRAGMAS
) && defined
(SQLITE_DEBUG
)
234 FLAG
: NeedSchema Result1 SchemaOpt
236 IF
: !defined
(SQLITE_OMIT_SCHEMA_PRAGMAS
)
241 FLAG
: NeedSchema Result1 SchemaOpt
242 COLS
: seqno cid name desc coll key
243 IF
: !defined
(SQLITE_OMIT_SCHEMA_PRAGMAS
)
246 FLAG
: NeedSchema Result1 SchemaOpt
247 COLS
: seq name unique origin partial
248 IF
: !defined
(SQLITE_OMIT_SCHEMA_PRAGMAS
)
251 FLAG
: NeedSchema Result0
253 IF
: !defined
(SQLITE_OMIT_SCHEMA_PRAGMAS
)
258 IF
: !defined
(SQLITE_OMIT_SCHEMA_PRAGMAS
)
259 IF
: defined
(SQLITE_INTROSPECTION_PRAGMAS
)
264 IF
: !defined
(SQLITE_OMIT_SCHEMA_PRAGMAS
)
265 IF
: !defined
(SQLITE_OMIT_VIRTUALTABLE
)
266 IF
: defined
(SQLITE_INTROSPECTION_PRAGMAS
)
271 IF
: defined
(SQLITE_INTROSPECTION_PRAGMAS
)
276 IF
: !defined
(SQLITE_OMIT_SCHEMA_PRAGMAS
)
278 NAME
: foreign_key_list
279 FLAG
: NeedSchema Result1 SchemaOpt
280 COLS
: id seq table from to on_update on_delete match
281 IF
: !defined
(SQLITE_OMIT_FOREIGN_KEY
)
283 NAME
: foreign_key_check
284 FLAG
: NeedSchema Result0
285 COLS
: table rowid parent fkid
286 IF
: !defined
(SQLITE_OMIT_FOREIGN_KEY
) && !defined
(SQLITE_OMIT_TRIGGER
)
289 IF
: defined
(SQLITE_DEBUG
) && !defined
(SQLITE_OMIT_PARSER_TRACE
)
291 NAME
: case_sensitive_like
294 NAME
: integrity_check
295 FLAG
: NeedSchema Result0 Result1
296 IF
: !defined
(SQLITE_OMIT_INTEGRITY_CHECK
)
299 TYPE
: INTEGRITY_CHECK
300 FLAG
: NeedSchema Result0 Result1
301 IF
: !defined
(SQLITE_OMIT_INTEGRITY_CHECK
)
304 FLAG
: Result0 NoColumns1
305 IF
: !defined
(SQLITE_OMIT_UTF16
)
309 ARG
: BTREE_SCHEMA_VERSION
310 FLAG
: NoColumns1 Result0
311 IF
: !defined
(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
)
315 ARG
: BTREE_USER_VERSION
316 FLAG
: NoColumns1 Result0
317 IF
: !defined
(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
)
321 ARG
: BTREE_DATA_VERSION
322 FLAG
: ReadOnly Result0
323 IF
: !defined
(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
)
327 ARG
: BTREE_FREE_PAGE_COUNT
328 FLAG
: ReadOnly Result0
329 IF
: !defined
(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
)
333 ARG
: BTREE_APPLICATION_ID
334 FLAG
: NoColumns1 Result0
335 IF
: !defined
(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
)
337 NAME
: compile_options
339 IF
: !defined
(SQLITE_OMIT_COMPILEOPTION_DIAGS
)
343 COLS
: busy log checkpointed
344 IF
: !defined
(SQLITE_OMIT_WAL
)
346 NAME
: wal_autocheckpoint
347 IF
: !defined
(SQLITE_OMIT_WAL
)
358 COLS
: database status
359 IF
: defined
(SQLITE_DEBUG
) || defined
(SQLITE_TEST
)
362 IF
: defined
(SQLITE_HAS_CODEC
)
365 IF
: defined
(SQLITE_HAS_CODEC
)
368 IF
: defined
(SQLITE_HAS_CODEC
)
372 IF
: defined
(SQLITE_HAS_CODEC
)
374 NAME
: activate_extensions
375 IF
: defined
(SQLITE_HAS_CODEC
) || defined
(SQLITE_ENABLE_CEROD
)
377 NAME
: soft_heap_limit
384 FLAG
: Result1 NeedSchema
387 # Open the output file
389 set destfile
"[file dir [file dir [file normal $argv0]]]/src/pragma.h"
390 puts "Overwriting $destfile with new pragma table..."
391 set fd
[open $destfile wb
]
392 puts $fd {/* DO NOT EDIT
!
393 ** This
file is automatically generated by the script at
394 ** ..
/tool
/mkpragmatab.tcl. To
update the
set of pragmas
, edit
395 ** that script and rerun it.
398 # Parse the PRAGMA table above.
408 global name type
if arg allbyname typebyif flags cols allcols
409 global cols_list colUsedBy
410 if {$name==""} return
412 if {![info exists allcols
($cols)]} {
413 lappend cols_list
$cols
414 set allcols
($cols) [llength $cols_list]
416 set cx
$allcols($cols)
417 lappend colUsedBy
($cols) $name
421 set allbyname
($name) [list $type $arg $if $flags $cx]
429 foreach line
[split $pragma_def \n] {
430 set line
[string trim
$line]
431 if {$line==""} continue
432 foreach {id val
} [split $line :] break
433 set val
[string trim
$val]
437 set type
[string toupper
$val]
438 } elseif
{$id=="TYPE"} {
441 lappend flags Result0 NoColumns1
443 } elseif
{$id=="ARG"} {
445 } elseif
{$id=="COLS"} {
447 } elseif
{$id=="IF"} {
449 } elseif
{$id=="FLAG"} {
450 foreach term
[split $val] {
452 set allflags
($term) 1
455 error "bad pragma_def line: $line"
459 set allnames
[lsort [array names allbyname
]]
461 # Generate #defines for all pragma type names. Group the pragmas that are
462 # omit in default builds (defined(SQLITE_DEBUG) and defined(SQLITE_HAS_CODEC))
465 puts $fd "\n/* The various pragma types */"
467 foreach name
$allnames {
468 set type
[lindex $allbyname($name) 0]
469 if {[info exists seentype
($type)]} continue
470 set if [lindex $allbyname($name) 2]
471 if {[regexp SQLITE_DEBUG
$if] ||
[regexp SQLITE_HAS_CODEC
$if]} continue
472 set seentype
($type) 1
473 puts $fd [format {#define %-35s %4d} PragTyp_$type $pnum]
476 foreach name
$allnames {
477 set type
[lindex $allbyname($name) 0]
478 if {[info exists seentype
($type)]} continue
479 set if [lindex $allbyname($name) 2]
480 if {[regexp SQLITE_DEBUG
$if]} continue
481 set seentype
($type) 1
482 puts $fd [format {#define %-35s %4d} PragTyp_$type $pnum]
485 foreach name
$allnames {
486 set type
[lindex $allbyname($name) 0]
487 if {[info exists seentype
($type)]} continue
488 set seentype
($type) 1
489 puts $fd [format {#define %-35s %4d} PragTyp_$type $pnum]
493 # Generate #defines for flags
495 puts $fd "\n/* Property flags associated with various pragma. */"
497 foreach f
[lsort [array names allflags
]] {
498 puts $fd [format {#define PragFlg_%-10s 0x%02x /* %s */} \
499 $f $fv $flagMeaning($f)]
500 set fv
[expr {$fv*2}]
503 # Generate the array of column names used by pragmas that act like
506 puts $fd "\n/* Names of columns for pragmas that return multi-column result"
507 puts $fd "** or that return single-column results where the name of the"
508 puts $fd "** result column is different from the name of the pragma\n*/"
509 puts $fd "static const char *const pragCName\[\] = {"
511 foreach cols
$cols_list {
512 set cols_offset
($allcols($cols)) $offset
513 set ub
" /* Used by: $colUsedBy($cols) */"
515 puts $fd [format " /* %3d */ %-14s%s" $offset \"$c\", $ub]
522 # Generate the lookup table
524 puts $fd "\n/* Definitions of all built-in pragmas */"
525 puts $fd "typedef struct PragmaName \173"
526 puts $fd " const char *const zName; /* Name of pragma */"
527 puts $fd " u8 ePragTyp; /* PragTyp_XXX value */"
528 puts $fd " u8 mPragFlg; /* Zero or more PragFlg_XXX values */"
529 puts $fd { u8 iPragCName
; /* Start of column names in pragCName
[] */}
530 puts $fd " u8 nPragCName; \
531 /* Num of col names. 0 means use pragma name */"
532 puts $fd " u32 iArg; /* Extra argument */"
533 puts $fd "\175 PragmaName;"
534 puts $fd "static const PragmaName aPragmaName\[\] = \173"
537 set spacer
[format { %26s
} {}]
538 foreach name
$allnames {
539 foreach {type arg
if flag cx
} $allbyname($name) break
544 set cy
$cols_offset($cx)
545 set nx
[llength [lindex $cols_list [expr {$cx-1}]]]
547 if {$if!=$current_if} {
548 if {$current_if!=""} {
549 foreach this_if
$current_if {
554 if {$current_if!=""} {
555 foreach this_if
$current_if {
556 puts $fd "#if $this_if"
560 set typex
[format PragTyp_
%-23s $type,]
564 set flagx PragFlg_
[join $flag {|PragFlg_
}]
566 puts $fd " \173/* zName: */ \"$name\","
567 puts $fd " /* ePragTyp: */ PragTyp_$type,"
568 puts $fd " /* ePragFlg: */ $flagx,"
569 puts $fd " /* ColNames: */ $cy, $nx,"
570 puts $fd " /* iArg: */ $arg \175,"
572 if {$current_if!=""} {
573 foreach this_if
$current_if {
579 # count the number of pragmas, for information purposes
583 foreach name
$allnames {
585 set if [lindex $allbyname($name) 2]
586 if {[regexp {^defined
} $if] ||
[regexp {[^
!]defined
} $if]} continue
589 puts $fd "/* Number of pragmas: $dfltcnt on by default, $allcnt total. */"