OLD | NEW |
| (Empty) |
1 #!/usr/bin/tclsh | |
2 # | |
3 # Run this script to generate the pragma name lookup table C code. | |
4 # | |
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 C-code for the lookup table and copy/paste the output | |
8 # of this script into the appropriate spot in the pragma.c source file. | |
9 # Then add the extra "case PragTyp_XXXXX:" and subsequent code for the | |
10 # new pragma. | |
11 # | |
12 | |
13 set pragma_def { | |
14 NAME: full_column_names | |
15 TYPE: FLAG | |
16 ARG: SQLITE_FullColNames | |
17 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
18 | |
19 NAME: short_column_names | |
20 TYPE: FLAG | |
21 ARG: SQLITE_ShortColNames | |
22 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
23 | |
24 NAME: count_changes | |
25 TYPE: FLAG | |
26 ARG: SQLITE_CountRows | |
27 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
28 | |
29 NAME: empty_result_callbacks | |
30 TYPE: FLAG | |
31 ARG: SQLITE_NullCallback | |
32 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
33 | |
34 NAME: legacy_file_format | |
35 TYPE: FLAG | |
36 ARG: SQLITE_LegacyFileFmt | |
37 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
38 | |
39 NAME: fullfsync | |
40 TYPE: FLAG | |
41 ARG: SQLITE_FullFSync | |
42 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
43 | |
44 NAME: checkpoint_fullfsync | |
45 TYPE: FLAG | |
46 ARG: SQLITE_CkptFullFSync | |
47 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
48 | |
49 NAME: cache_spill | |
50 TYPE: FLAG | |
51 ARG: SQLITE_CacheSpill | |
52 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
53 | |
54 NAME: reverse_unordered_selects | |
55 TYPE: FLAG | |
56 ARG: SQLITE_ReverseOrder | |
57 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
58 | |
59 NAME: query_only | |
60 TYPE: FLAG | |
61 ARG: SQLITE_QueryOnly | |
62 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
63 | |
64 NAME: automatic_index | |
65 TYPE: FLAG | |
66 ARG: SQLITE_AutoIndex | |
67 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
68 IF: !defined(SQLITE_OMIT_AUTOMATIC_INDEX) | |
69 | |
70 NAME: sql_trace | |
71 TYPE: FLAG | |
72 ARG: SQLITE_SqlTrace | |
73 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
74 IF: defined(SQLITE_DEBUG) | |
75 | |
76 NAME: vdbe_listing | |
77 TYPE: FLAG | |
78 ARG: SQLITE_VdbeListing | |
79 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
80 IF: defined(SQLITE_DEBUG) | |
81 | |
82 NAME: vdbe_trace | |
83 TYPE: FLAG | |
84 ARG: SQLITE_VdbeTrace | |
85 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
86 IF: defined(SQLITE_DEBUG) | |
87 | |
88 NAME: vdbe_addoptrace | |
89 TYPE: FLAG | |
90 ARG: SQLITE_VdbeAddopTrace | |
91 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
92 IF: defined(SQLITE_DEBUG) | |
93 | |
94 NAME: vdbe_debug | |
95 TYPE: FLAG | |
96 ARG: SQLITE_SqlTrace|SQLITE_VdbeListing|SQLITE_VdbeTrace | |
97 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
98 IF: defined(SQLITE_DEBUG) | |
99 | |
100 NAME: vdbe_eqp | |
101 TYPE: FLAG | |
102 ARG: SQLITE_VdbeEQP | |
103 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
104 IF: defined(SQLITE_DEBUG) | |
105 | |
106 NAME: ignore_check_constraints | |
107 TYPE: FLAG | |
108 ARG: SQLITE_IgnoreChecks | |
109 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
110 IF: !defined(SQLITE_OMIT_CHECK) | |
111 | |
112 NAME: writable_schema | |
113 TYPE: FLAG | |
114 ARG: SQLITE_WriteSchema|SQLITE_RecoveryMode | |
115 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
116 | |
117 NAME: read_uncommitted | |
118 TYPE: FLAG | |
119 ARG: SQLITE_ReadUncommitted | |
120 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
121 | |
122 NAME: recursive_triggers | |
123 TYPE: FLAG | |
124 ARG: SQLITE_RecTriggers | |
125 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
126 | |
127 NAME: foreign_keys | |
128 TYPE: FLAG | |
129 ARG: SQLITE_ForeignKeys | |
130 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
131 IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) | |
132 | |
133 NAME: defer_foreign_keys | |
134 TYPE: FLAG | |
135 ARG: SQLITE_DeferFKs | |
136 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | |
137 IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) | |
138 | |
139 NAME: default_cache_size | |
140 FLAG: NeedSchema | |
141 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED) | |
142 | |
143 NAME: page_size | |
144 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | |
145 | |
146 NAME: secure_delete | |
147 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | |
148 | |
149 NAME: page_count | |
150 FLAG: NeedSchema | |
151 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | |
152 | |
153 NAME: max_page_count | |
154 TYPE: PAGE_COUNT | |
155 FLAG: NeedSchema | |
156 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | |
157 | |
158 NAME: locking_mode | |
159 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | |
160 | |
161 NAME: journal_mode | |
162 FLAG: NeedSchema | |
163 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | |
164 | |
165 NAME: journal_size_limit | |
166 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | |
167 | |
168 NAME: cache_size | |
169 FLAG: NeedSchema | |
170 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | |
171 | |
172 NAME: mmap_size | |
173 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | |
174 | |
175 NAME: auto_vacuum | |
176 FLAG: NeedSchema | |
177 IF: !defined(SQLITE_OMIT_AUTOVACUUM) | |
178 | |
179 NAME: incremental_vacuum | |
180 FLAG: NeedSchema | |
181 IF: !defined(SQLITE_OMIT_AUTOVACUUM) | |
182 | |
183 NAME: temp_store | |
184 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | |
185 | |
186 NAME: temp_store_directory | |
187 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | |
188 | |
189 NAME: data_store_directory | |
190 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN | |
191 | |
192 NAME: lock_proxy_file | |
193 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE | |
194 | |
195 NAME: synchronous | |
196 FLAG: NeedSchema | |
197 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | |
198 | |
199 NAME: table_info | |
200 FLAG: NeedSchema | |
201 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) | |
202 | |
203 NAME: stats | |
204 FLAG: NeedSchema | |
205 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) | |
206 | |
207 NAME: index_info | |
208 FLAG: NeedSchema | |
209 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) | |
210 | |
211 NAME: index_list | |
212 FLAG: NeedSchema | |
213 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) | |
214 | |
215 NAME: database_list | |
216 FLAG: NeedSchema | |
217 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) | |
218 | |
219 NAME: collation_list | |
220 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) | |
221 | |
222 NAME: foreign_key_list | |
223 FLAG: NeedSchema | |
224 IF: !defined(SQLITE_OMIT_FOREIGN_KEY) | |
225 | |
226 NAME: foreign_key_check | |
227 FLAG: NeedSchema | |
228 IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) | |
229 | |
230 NAME: parser_trace | |
231 IF: defined(SQLITE_DEBUG) | |
232 | |
233 NAME: case_sensitive_like | |
234 | |
235 NAME: integrity_check | |
236 FLAG: NeedSchema | |
237 IF: !defined(SQLITE_OMIT_INTEGRITY_CHECK) | |
238 | |
239 NAME: quick_check | |
240 TYPE: INTEGRITY_CHECK | |
241 FLAG: NeedSchema | |
242 IF: !defined(SQLITE_OMIT_INTEGRITY_CHECK) | |
243 | |
244 NAME: encoding | |
245 IF: !defined(SQLITE_OMIT_UTF16) | |
246 | |
247 NAME: schema_version | |
248 TYPE: HEADER_VALUE | |
249 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) | |
250 | |
251 NAME: user_version | |
252 TYPE: HEADER_VALUE | |
253 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) | |
254 | |
255 NAME: freelist_count | |
256 TYPE: HEADER_VALUE | |
257 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) | |
258 | |
259 NAME: application_id | |
260 TYPE: HEADER_VALUE | |
261 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) | |
262 | |
263 NAME: compile_options | |
264 IF: !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS) | |
265 | |
266 NAME: wal_checkpoint | |
267 FLAG: NeedSchema | |
268 IF: !defined(SQLITE_OMIT_WAL) | |
269 | |
270 NAME: wal_autocheckpoint | |
271 IF: !defined(SQLITE_OMIT_WAL) | |
272 | |
273 NAME: shrink_memory | |
274 | |
275 NAME: busy_timeout | |
276 | |
277 NAME: lock_status | |
278 IF: defined(SQLITE_DEBUG) || defined(SQLITE_TEST) | |
279 | |
280 NAME: key | |
281 IF: defined(SQLITE_HAS_CODEC) | |
282 | |
283 NAME: rekey | |
284 IF: defined(SQLITE_HAS_CODEC) | |
285 | |
286 NAME: hexkey | |
287 IF: defined(SQLITE_HAS_CODEC) | |
288 | |
289 NAME: hexrekey | |
290 TYPE: HEXKEY | |
291 IF: defined(SQLITE_HAS_CODEC) | |
292 | |
293 NAME: activate_extensions | |
294 IF: defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD) | |
295 | |
296 NAME: soft_heap_limit | |
297 | |
298 NAME: threads | |
299 } | |
300 fconfigure stdout -translation lf | |
301 set name {} | |
302 set type {} | |
303 set if {} | |
304 set flags {} | |
305 set arg 0 | |
306 proc record_one {} { | |
307 global name type if arg allbyname typebyif flags | |
308 if {$name==""} return | |
309 set allbyname($name) [list $type $arg $if $flags] | |
310 set name {} | |
311 set type {} | |
312 set if {} | |
313 set flags {} | |
314 set arg 0 | |
315 } | |
316 foreach line [split $pragma_def \n] { | |
317 set line [string trim $line] | |
318 if {$line==""} continue | |
319 foreach {id val} [split $line :] break | |
320 set val [string trim $val] | |
321 if {$id=="NAME"} { | |
322 record_one | |
323 set name $val | |
324 set type [string toupper $val] | |
325 } elseif {$id=="TYPE"} { | |
326 set type $val | |
327 } elseif {$id=="ARG"} { | |
328 set arg $val | |
329 } elseif {$id=="IF"} { | |
330 lappend if $val | |
331 } elseif {$id=="FLAG"} { | |
332 foreach term [split $val] { | |
333 lappend flags $term | |
334 set allflags($term) 1 | |
335 } | |
336 } else { | |
337 error "bad pragma_def line: $line" | |
338 } | |
339 } | |
340 record_one | |
341 set allnames [lsort [array names allbyname]] | |
342 | |
343 # Generate #defines for all pragma type names. Group the pragmas that are | |
344 # omit in default builds (defined(SQLITE_DEBUG) and defined(SQLITE_HAS_CODEC)) | |
345 # at the end. | |
346 # | |
347 set pnum 0 | |
348 foreach name $allnames { | |
349 set type [lindex $allbyname($name) 0] | |
350 if {[info exists seentype($type)]} continue | |
351 set if [lindex $allbyname($name) 2] | |
352 if {[regexp SQLITE_DEBUG $if] || [regexp SQLITE_HAS_CODEC $if]} continue | |
353 set seentype($type) 1 | |
354 puts [format {#define %-35s %4d} PragTyp_$type $pnum] | |
355 incr pnum | |
356 } | |
357 foreach name $allnames { | |
358 set type [lindex $allbyname($name) 0] | |
359 if {[info exists seentype($type)]} continue | |
360 set if [lindex $allbyname($name) 2] | |
361 if {[regexp SQLITE_DEBUG $if]} continue | |
362 set seentype($type) 1 | |
363 puts [format {#define %-35s %4d} PragTyp_$type $pnum] | |
364 incr pnum | |
365 } | |
366 foreach name $allnames { | |
367 set type [lindex $allbyname($name) 0] | |
368 if {[info exists seentype($type)]} continue | |
369 set seentype($type) 1 | |
370 puts [format {#define %-35s %4d} PragTyp_$type $pnum] | |
371 incr pnum | |
372 } | |
373 | |
374 # Generate #defines for flags | |
375 # | |
376 set fv 1 | |
377 foreach f [lsort [array names allflags]] { | |
378 puts [format {#define PragFlag_%-20s 0x%02x} $f $fv] | |
379 set fv [expr {$fv*2}] | |
380 } | |
381 | |
382 # Generate the lookup table | |
383 # | |
384 puts "static const struct sPragmaNames \173" | |
385 puts " const char *const zName; /* Name of pragma */" | |
386 puts " u8 ePragTyp; /* PragTyp_XXX value */" | |
387 puts " u8 mPragFlag; /* Zero or more PragFlag_XXX values */" | |
388 puts " u32 iArg; /* Extra argument */" | |
389 puts "\175 aPragmaNames\[\] = \173" | |
390 | |
391 set current_if {} | |
392 set spacer [format { %26s } {}] | |
393 foreach name $allnames { | |
394 foreach {type arg if flag} $allbyname($name) break | |
395 if {$if!=$current_if} { | |
396 if {$current_if!=""} { | |
397 foreach this_if $current_if { | |
398 puts "#endif" | |
399 } | |
400 } | |
401 set current_if $if | |
402 if {$current_if!=""} { | |
403 foreach this_if $current_if { | |
404 puts "#if $this_if" | |
405 } | |
406 } | |
407 } | |
408 set typex [format PragTyp_%-23s $type,] | |
409 if {$flag==""} { | |
410 set flagx "0" | |
411 } else { | |
412 set flagx PragFlag_[join $flag {|PragFlag_}] | |
413 } | |
414 puts " \173 /* zName: */ \"$name\"," | |
415 puts " /* ePragTyp: */ PragTyp_$type," | |
416 puts " /* ePragFlag: */ $flagx," | |
417 puts " /* iArg: */ $arg \175," | |
418 } | |
419 if {$current_if!=""} { | |
420 foreach this_if $current_if { | |
421 puts "#endif" | |
422 } | |
423 } | |
424 puts "\175;" | |
425 | |
426 # count the number of pragmas, for information purposes | |
427 # | |
428 set allcnt 0 | |
429 set dfltcnt 0 | |
430 foreach name $allnames { | |
431 incr allcnt | |
432 set if [lindex $allbyname($name) 2] | |
433 if {[regexp {^defined} $if] || [regexp {[^!]defined} $if]} continue | |
434 incr dfltcnt | |
435 } | |
436 puts "/* Number of pragmas: $dfltcnt on by default, $allcnt total. */" | |
OLD | NEW |