OLD | NEW |
1 #!/usr/bin/tclsh | 1 #!/usr/bin/tclsh |
2 # | 2 # |
3 # Run this script to generate the pragma name lookup table C code. | 3 # Run this script to generate the pragma name lookup table C code. |
4 # | 4 # |
5 # To add new pragmas, first add the name and other relevant attributes | 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 | 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 | 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. | 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 | 9 # Then add the extra "case PragTyp_XXXXX:" and subsequent code for the |
10 # new pragma in ../src/pragma.c. | 10 # new pragma in ../src/pragma.c. |
11 # | 11 # |
12 | 12 |
| 13 # Flag meanings: |
| 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} |
| 22 |
13 set pragma_def { | 23 set pragma_def { |
14 NAME: full_column_names | 24 NAME: full_column_names |
15 TYPE: FLAG | 25 TYPE: FLAG |
16 ARG: SQLITE_FullColNames | 26 ARG: SQLITE_FullColNames |
17 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | 27 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
18 | 28 |
19 NAME: short_column_names | 29 NAME: short_column_names |
20 TYPE: FLAG | 30 TYPE: FLAG |
21 ARG: SQLITE_ShortColNames | 31 ARG: SQLITE_ShortColNames |
22 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | 32 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
(...skipping 17 matching lines...) Expand all Loading... |
40 TYPE: FLAG | 50 TYPE: FLAG |
41 ARG: SQLITE_FullFSync | 51 ARG: SQLITE_FullFSync |
42 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | 52 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
43 | 53 |
44 NAME: checkpoint_fullfsync | 54 NAME: checkpoint_fullfsync |
45 TYPE: FLAG | 55 TYPE: FLAG |
46 ARG: SQLITE_CkptFullFSync | 56 ARG: SQLITE_CkptFullFSync |
47 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | 57 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
48 | 58 |
49 NAME: cache_spill | 59 NAME: cache_spill |
| 60 FLAG: Result0 SchemaReq NoColumns1 |
50 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | 61 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
51 | 62 |
52 NAME: reverse_unordered_selects | 63 NAME: reverse_unordered_selects |
53 TYPE: FLAG | 64 TYPE: FLAG |
54 ARG: SQLITE_ReverseOrder | 65 ARG: SQLITE_ReverseOrder |
55 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | 66 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
56 | 67 |
57 NAME: query_only | 68 NAME: query_only |
58 TYPE: FLAG | 69 TYPE: FLAG |
59 ARG: SQLITE_QueryOnly | 70 ARG: SQLITE_QueryOnly |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 TYPE: FLAG | 143 TYPE: FLAG |
133 ARG: SQLITE_DeferFKs | 144 ARG: SQLITE_DeferFKs |
134 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) | 145 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
135 IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) | 146 IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) |
136 | 147 |
137 NAME: cell_size_check | 148 NAME: cell_size_check |
138 TYPE: FLAG | 149 TYPE: FLAG |
139 ARG: SQLITE_CellSizeCk | 150 ARG: SQLITE_CellSizeCk |
140 | 151 |
141 NAME: default_cache_size | 152 NAME: default_cache_size |
142 FLAG: NeedSchema | 153 FLAG: NeedSchema Result0 SchemaReq NoColumns1 |
| 154 COLS: cache_size |
143 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED) | 155 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED) |
144 | 156 |
145 NAME: page_size | 157 NAME: page_size |
| 158 FLAG: Result0 SchemaReq NoColumns1 |
146 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | 159 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
147 | 160 |
148 NAME: secure_delete | 161 NAME: secure_delete |
| 162 FLAG: Result0 |
149 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | 163 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
150 | 164 |
151 NAME: page_count | 165 NAME: page_count |
152 FLAG: NeedSchema | 166 FLAG: NeedSchema Result0 SchemaReq |
153 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | 167 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
154 | 168 |
155 NAME: max_page_count | 169 NAME: max_page_count |
156 TYPE: PAGE_COUNT | 170 TYPE: PAGE_COUNT |
157 FLAG: NeedSchema | 171 FLAG: NeedSchema Result0 SchemaReq |
158 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | 172 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
159 | 173 |
160 NAME: locking_mode | 174 NAME: locking_mode |
| 175 FLAG: Result0 SchemaReq |
161 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | 176 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
162 | 177 |
163 NAME: journal_mode | 178 NAME: journal_mode |
164 FLAG: NeedSchema | 179 FLAG: NeedSchema Result0 SchemaReq |
165 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | 180 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
166 | 181 |
167 NAME: journal_size_limit | 182 NAME: journal_size_limit |
| 183 FLAG: Result0 SchemaReq |
168 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | 184 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
169 | 185 |
170 NAME: cache_size | 186 NAME: cache_size |
171 FLAG: NeedSchema | 187 FLAG: NeedSchema Result0 SchemaReq NoColumns1 |
172 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | 188 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
173 | 189 |
174 NAME: mmap_size | 190 NAME: mmap_size |
175 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | 191 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
176 | 192 |
177 NAME: auto_vacuum | 193 NAME: auto_vacuum |
178 FLAG: NeedSchema | 194 FLAG: NeedSchema Result0 SchemaReq NoColumns1 |
179 IF: !defined(SQLITE_OMIT_AUTOVACUUM) | 195 IF: !defined(SQLITE_OMIT_AUTOVACUUM) |
180 | 196 |
181 NAME: incremental_vacuum | 197 NAME: incremental_vacuum |
182 FLAG: NeedSchema | 198 FLAG: NeedSchema NoColumns |
183 IF: !defined(SQLITE_OMIT_AUTOVACUUM) | 199 IF: !defined(SQLITE_OMIT_AUTOVACUUM) |
184 | 200 |
185 NAME: temp_store | 201 NAME: temp_store |
| 202 FLAG: Result0 NoColumns1 |
186 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | 203 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
187 | 204 |
188 NAME: temp_store_directory | 205 NAME: temp_store_directory |
| 206 FLAG: NoColumns1 |
189 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | 207 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
190 | 208 |
191 NAME: data_store_directory | 209 NAME: data_store_directory |
| 210 FLAG: NoColumns1 |
192 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN | 211 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN |
193 | 212 |
194 NAME: lock_proxy_file | 213 NAME: lock_proxy_file |
| 214 FLAG: NoColumns1 |
195 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE | 215 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE |
196 | 216 |
197 NAME: synchronous | 217 NAME: synchronous |
198 FLAG: NeedSchema | 218 FLAG: NeedSchema Result0 SchemaReq NoColumns1 |
199 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) | 219 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
200 | 220 |
201 NAME: table_info | 221 NAME: table_info |
202 FLAG: NeedSchema | 222 FLAG: NeedSchema Result1 SchemaOpt |
| 223 COLS: cid name type notnull dflt_value pk |
203 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) | 224 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
204 | 225 |
205 NAME: stats | 226 NAME: stats |
206 FLAG: NeedSchema | 227 FLAG: NeedSchema Result0 SchemaReq |
| 228 COLS: table index width height |
207 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) | 229 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
208 | 230 |
209 NAME: index_info | 231 NAME: index_info |
210 TYPE: INDEX_INFO | 232 TYPE: INDEX_INFO |
211 ARG: 0 | 233 ARG: 0 |
212 FLAG: NeedSchema | 234 FLAG: NeedSchema Result1 SchemaOpt |
| 235 COLS: seqno cid name |
213 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) | 236 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
214 | 237 |
215 NAME: index_xinfo | 238 NAME: index_xinfo |
216 TYPE: INDEX_INFO | 239 TYPE: INDEX_INFO |
217 ARG: 1 | 240 ARG: 1 |
218 FLAG: NeedSchema | 241 FLAG: NeedSchema Result1 SchemaOpt |
| 242 COLS: seqno cid name desc coll key |
219 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) | 243 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
220 | 244 |
221 NAME: index_list | 245 NAME: index_list |
222 FLAG: NeedSchema | 246 FLAG: NeedSchema Result1 SchemaOpt |
| 247 COLS: seq name unique origin partial |
223 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) | 248 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
224 | 249 |
225 NAME: database_list | 250 NAME: database_list |
226 FLAG: NeedSchema | 251 FLAG: NeedSchema Result0 |
| 252 COLS: seq name file |
227 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) | 253 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
228 | 254 |
229 NAME: collation_list | 255 NAME: collation_list |
| 256 FLAG: Result0 |
| 257 COLS: seq name |
230 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) | 258 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
231 | 259 |
232 NAME: foreign_key_list | 260 NAME: foreign_key_list |
233 FLAG: NeedSchema | 261 FLAG: NeedSchema Result1 SchemaOpt |
| 262 COLS: id seq table from to on_update on_delete match |
234 IF: !defined(SQLITE_OMIT_FOREIGN_KEY) | 263 IF: !defined(SQLITE_OMIT_FOREIGN_KEY) |
235 | 264 |
236 NAME: foreign_key_check | 265 NAME: foreign_key_check |
237 FLAG: NeedSchema | 266 FLAG: NeedSchema |
| 267 COLS: table rowid parent fkid |
238 IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) | 268 IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) |
239 | 269 |
240 NAME: parser_trace | 270 NAME: parser_trace |
241 IF: defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_PARSER_TRACE) | 271 IF: defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_PARSER_TRACE) |
242 | 272 |
243 NAME: case_sensitive_like | 273 NAME: case_sensitive_like |
| 274 FLAG: NoColumns |
244 | 275 |
245 NAME: integrity_check | 276 NAME: integrity_check |
246 FLAG: NeedSchema | 277 FLAG: NeedSchema |
247 IF: !defined(SQLITE_OMIT_INTEGRITY_CHECK) | 278 IF: !defined(SQLITE_OMIT_INTEGRITY_CHECK) |
248 | 279 |
249 NAME: quick_check | 280 NAME: quick_check |
250 TYPE: INTEGRITY_CHECK | 281 TYPE: INTEGRITY_CHECK |
251 FLAG: NeedSchema | 282 FLAG: NeedSchema |
252 IF: !defined(SQLITE_OMIT_INTEGRITY_CHECK) | 283 IF: !defined(SQLITE_OMIT_INTEGRITY_CHECK) |
253 | 284 |
254 NAME: encoding | 285 NAME: encoding |
| 286 FLAG: Result0 NoColumns1 |
255 IF: !defined(SQLITE_OMIT_UTF16) | 287 IF: !defined(SQLITE_OMIT_UTF16) |
256 | 288 |
257 NAME: schema_version | 289 NAME: schema_version |
258 TYPE: HEADER_VALUE | 290 TYPE: HEADER_VALUE |
259 ARG: BTREE_SCHEMA_VERSION | 291 ARG: BTREE_SCHEMA_VERSION |
| 292 FLAG: NoColumns1 Result0 |
260 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) | 293 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) |
261 | 294 |
262 NAME: user_version | 295 NAME: user_version |
263 TYPE: HEADER_VALUE | 296 TYPE: HEADER_VALUE |
264 ARG: BTREE_USER_VERSION | 297 ARG: BTREE_USER_VERSION |
| 298 FLAG: NoColumns1 Result0 |
265 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) | 299 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) |
266 | 300 |
267 NAME: data_version | 301 NAME: data_version |
268 TYPE: HEADER_VALUE | 302 TYPE: HEADER_VALUE |
269 ARG: BTREE_DATA_VERSION | 303 ARG: BTREE_DATA_VERSION |
270 FLAG: ReadOnly | 304 FLAG: ReadOnly Result0 |
271 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) | 305 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) |
272 | 306 |
273 NAME: freelist_count | 307 NAME: freelist_count |
274 TYPE: HEADER_VALUE | 308 TYPE: HEADER_VALUE |
275 ARG: BTREE_FREE_PAGE_COUNT | 309 ARG: BTREE_FREE_PAGE_COUNT |
276 FLAG: ReadOnly | 310 FLAG: ReadOnly Result0 |
277 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) | 311 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) |
278 | 312 |
279 NAME: application_id | 313 NAME: application_id |
280 TYPE: HEADER_VALUE | 314 TYPE: HEADER_VALUE |
281 ARG: BTREE_APPLICATION_ID | 315 ARG: BTREE_APPLICATION_ID |
| 316 FLAG: NoColumns1 Result0 |
282 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) | 317 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) |
283 | 318 |
284 NAME: compile_options | 319 NAME: compile_options |
| 320 FLAG: Result0 |
285 IF: !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS) | 321 IF: !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS) |
286 | 322 |
287 NAME: wal_checkpoint | 323 NAME: wal_checkpoint |
288 FLAG: NeedSchema | 324 FLAG: NeedSchema |
| 325 COLS: busy log checkpointed |
289 IF: !defined(SQLITE_OMIT_WAL) | 326 IF: !defined(SQLITE_OMIT_WAL) |
290 | 327 |
291 NAME: wal_autocheckpoint | 328 NAME: wal_autocheckpoint |
292 IF: !defined(SQLITE_OMIT_WAL) | 329 IF: !defined(SQLITE_OMIT_WAL) |
293 | 330 |
294 NAME: shrink_memory | 331 NAME: shrink_memory |
| 332 FLAG: NoColumns |
295 | 333 |
296 NAME: busy_timeout | 334 NAME: busy_timeout |
| 335 FLAG: Result0 |
| 336 COLS: timeout |
297 | 337 |
298 NAME: lock_status | 338 NAME: lock_status |
| 339 FLAG: Result0 |
| 340 COLS: database status |
299 IF: defined(SQLITE_DEBUG) || defined(SQLITE_TEST) | 341 IF: defined(SQLITE_DEBUG) || defined(SQLITE_TEST) |
300 | 342 |
301 NAME: key | 343 NAME: key |
302 IF: defined(SQLITE_HAS_CODEC) | 344 IF: defined(SQLITE_HAS_CODEC) |
303 | 345 |
304 NAME: rekey | 346 NAME: rekey |
305 IF: defined(SQLITE_HAS_CODEC) | 347 IF: defined(SQLITE_HAS_CODEC) |
306 | 348 |
307 NAME: hexkey | 349 NAME: hexkey |
308 IF: defined(SQLITE_HAS_CODEC) | 350 IF: defined(SQLITE_HAS_CODEC) |
309 | 351 |
310 NAME: hexrekey | 352 NAME: hexrekey |
311 TYPE: HEXKEY | 353 TYPE: HEXKEY |
312 IF: defined(SQLITE_HAS_CODEC) | 354 IF: defined(SQLITE_HAS_CODEC) |
313 | 355 |
314 NAME: activate_extensions | 356 NAME: activate_extensions |
315 IF: defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD) | 357 IF: defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD) |
316 | 358 |
317 NAME: soft_heap_limit | 359 NAME: soft_heap_limit |
| 360 FLAG: Result0 |
318 | 361 |
319 NAME: threads | 362 NAME: threads |
| 363 FLAG: Result0 |
320 } | 364 } |
321 | 365 |
322 # Open the output file | 366 # Open the output file |
323 # | 367 # |
324 set destfile "[file dir [file dir [file normal $argv0]]]/src/pragma.h" | 368 set destfile "[file dir [file dir [file normal $argv0]]]/src/pragma.h" |
325 puts "Overwriting $destfile with new pragma table..." | 369 puts "Overwriting $destfile with new pragma table..." |
326 set fd [open $destfile wb] | 370 set fd [open $destfile wb] |
327 puts $fd {/* DO NOT EDIT! | 371 puts $fd {/* DO NOT EDIT! |
328 ** This file is automatically generated by the script at | 372 ** This file is automatically generated by the script at |
329 ** ../tool/mkpragmatab.tcl. To update the set of pragmas, edit | 373 ** ../tool/mkpragmatab.tcl. To update the set of pragmas, edit |
330 ** that script and rerun it. | 374 ** that script and rerun it. |
331 */} | 375 */} |
332 | 376 |
333 # Parse the PRAGMA table above. | 377 # Parse the PRAGMA table above. |
334 # | 378 # |
335 set name {} | 379 set name {} |
336 set type {} | 380 set type {} |
337 set if {} | 381 set if {} |
338 set flags {} | 382 set flags {} |
| 383 set cols {} |
| 384 set cols_list {} |
339 set arg 0 | 385 set arg 0 |
340 proc record_one {} { | 386 proc record_one {} { |
341 global name type if arg allbyname typebyif flags | 387 global name type if arg allbyname typebyif flags cols allcols |
| 388 global cols_list colUsedBy |
342 if {$name==""} return | 389 if {$name==""} return |
343 set allbyname($name) [list $type $arg $if $flags] | 390 if {$cols!=""} { |
| 391 if {![info exists allcols($cols)]} { |
| 392 lappend cols_list $cols |
| 393 set allcols($cols) [llength $cols_list] |
| 394 } |
| 395 set cx $allcols($cols) |
| 396 lappend colUsedBy($cols) $name |
| 397 } else { |
| 398 set cx 0 |
| 399 } |
| 400 set allbyname($name) [list $type $arg $if $flags $cx] |
344 set name {} | 401 set name {} |
345 set type {} | 402 set type {} |
346 set if {} | 403 set if {} |
347 set flags {} | 404 set flags {} |
| 405 set cols {} |
348 set arg 0 | 406 set arg 0 |
349 } | 407 } |
350 foreach line [split $pragma_def \n] { | 408 foreach line [split $pragma_def \n] { |
351 set line [string trim $line] | 409 set line [string trim $line] |
352 if {$line==""} continue | 410 if {$line==""} continue |
353 foreach {id val} [split $line :] break | 411 foreach {id val} [split $line :] break |
354 set val [string trim $val] | 412 set val [string trim $val] |
355 if {$id=="NAME"} { | 413 if {$id=="NAME"} { |
356 record_one | 414 record_one |
357 set name $val | 415 set name $val |
358 set type [string toupper $val] | 416 set type [string toupper $val] |
359 } elseif {$id=="TYPE"} { | 417 } elseif {$id=="TYPE"} { |
360 set type $val | 418 set type $val |
| 419 if {$type=="FLAG"} { |
| 420 lappend flags Result0 NoColumns1 |
| 421 } |
361 } elseif {$id=="ARG"} { | 422 } elseif {$id=="ARG"} { |
362 set arg $val | 423 set arg $val |
| 424 } elseif {$id=="COLS"} { |
| 425 set cols $val |
363 } elseif {$id=="IF"} { | 426 } elseif {$id=="IF"} { |
364 lappend if $val | 427 lappend if $val |
365 } elseif {$id=="FLAG"} { | 428 } elseif {$id=="FLAG"} { |
366 foreach term [split $val] { | 429 foreach term [split $val] { |
367 lappend flags $term | 430 lappend flags $term |
368 set allflags($term) 1 | 431 set allflags($term) 1 |
369 } | 432 } |
370 } else { | 433 } else { |
371 error "bad pragma_def line: $line" | 434 error "bad pragma_def line: $line" |
372 } | 435 } |
373 } | 436 } |
374 record_one | 437 record_one |
375 set allnames [lsort [array names allbyname]] | 438 set allnames [lsort [array names allbyname]] |
376 | 439 |
377 # Generate #defines for all pragma type names. Group the pragmas that are | 440 # Generate #defines for all pragma type names. Group the pragmas that are |
378 # omit in default builds (defined(SQLITE_DEBUG) and defined(SQLITE_HAS_CODEC)) | 441 # omit in default builds (defined(SQLITE_DEBUG) and defined(SQLITE_HAS_CODEC)) |
379 # at the end. | 442 # at the end. |
380 # | 443 # |
| 444 puts $fd "\n/* The various pragma types */" |
381 set pnum 0 | 445 set pnum 0 |
382 foreach name $allnames { | 446 foreach name $allnames { |
383 set type [lindex $allbyname($name) 0] | 447 set type [lindex $allbyname($name) 0] |
384 if {[info exists seentype($type)]} continue | 448 if {[info exists seentype($type)]} continue |
385 set if [lindex $allbyname($name) 2] | 449 set if [lindex $allbyname($name) 2] |
386 if {[regexp SQLITE_DEBUG $if] || [regexp SQLITE_HAS_CODEC $if]} continue | 450 if {[regexp SQLITE_DEBUG $if] || [regexp SQLITE_HAS_CODEC $if]} continue |
387 set seentype($type) 1 | 451 set seentype($type) 1 |
388 puts $fd [format {#define %-35s %4d} PragTyp_$type $pnum] | 452 puts $fd [format {#define %-35s %4d} PragTyp_$type $pnum] |
389 incr pnum | 453 incr pnum |
390 } | 454 } |
391 foreach name $allnames { | 455 foreach name $allnames { |
392 set type [lindex $allbyname($name) 0] | 456 set type [lindex $allbyname($name) 0] |
393 if {[info exists seentype($type)]} continue | 457 if {[info exists seentype($type)]} continue |
394 set if [lindex $allbyname($name) 2] | 458 set if [lindex $allbyname($name) 2] |
395 if {[regexp SQLITE_DEBUG $if]} continue | 459 if {[regexp SQLITE_DEBUG $if]} continue |
396 set seentype($type) 1 | 460 set seentype($type) 1 |
397 puts $fd [format {#define %-35s %4d} PragTyp_$type $pnum] | 461 puts $fd [format {#define %-35s %4d} PragTyp_$type $pnum] |
398 incr pnum | 462 incr pnum |
399 } | 463 } |
400 foreach name $allnames { | 464 foreach name $allnames { |
401 set type [lindex $allbyname($name) 0] | 465 set type [lindex $allbyname($name) 0] |
402 if {[info exists seentype($type)]} continue | 466 if {[info exists seentype($type)]} continue |
403 set seentype($type) 1 | 467 set seentype($type) 1 |
404 puts $fd [format {#define %-35s %4d} PragTyp_$type $pnum] | 468 puts $fd [format {#define %-35s %4d} PragTyp_$type $pnum] |
405 incr pnum | 469 incr pnum |
406 } | 470 } |
407 | 471 |
408 # Generate #defines for flags | 472 # Generate #defines for flags |
409 # | 473 # |
| 474 puts $fd "\n/* Property flags associated with various pragma. */" |
410 set fv 1 | 475 set fv 1 |
411 foreach f [lsort [array names allflags]] { | 476 foreach f [lsort [array names allflags]] { |
412 puts $fd [format {#define PragFlag_%-20s 0x%02x} $f $fv] | 477 puts $fd [format {#define PragFlg_%-10s 0x%02x /* %s */} \ |
| 478 $f $fv $flagMeaning($f)] |
413 set fv [expr {$fv*2}] | 479 set fv [expr {$fv*2}] |
414 } | 480 } |
415 | 481 |
| 482 # Generate the array of column names used by pragmas that act like |
| 483 # queries. |
| 484 # |
| 485 puts $fd "\n/* Names of columns for pragmas that return multi-column result" |
| 486 puts $fd "** or that return single-column results where the name of the" |
| 487 puts $fd "** result column is different from the name of the pragma\n*/" |
| 488 puts $fd "static const char *const pragCName\[\] = {" |
| 489 set offset 0 |
| 490 foreach cols $cols_list { |
| 491 set cols_offset($allcols($cols)) $offset |
| 492 set ub " /* Used by: $colUsedBy($cols) */" |
| 493 foreach c $cols { |
| 494 puts $fd [format " /* %3d */ %-14s%s" $offset \"$c\", $ub] |
| 495 set ub "" |
| 496 incr offset |
| 497 } |
| 498 } |
| 499 puts $fd "\175;" |
| 500 |
416 # Generate the lookup table | 501 # Generate the lookup table |
417 # | 502 # |
418 puts $fd "static const struct sPragmaNames \173" | 503 puts $fd "\n/* Definitions of all built-in pragmas */" |
419 puts $fd " const char *const zName; /* Name of pragma */" | 504 puts $fd "typedef struct PragmaName \173" |
420 puts $fd " u8 ePragTyp; /* PragTyp_XXX value */" | 505 puts $fd " const char *const zName; /* Name of pragma */" |
421 puts $fd " u8 mPragFlag; /* Zero or more PragFlag_XXX values */" | 506 puts $fd " u8 ePragTyp; /* PragTyp_XXX value */" |
422 puts $fd " u32 iArg; /* Extra argument */" | 507 puts $fd " u8 mPragFlg; /* Zero or more PragFlg_XXX values */" |
423 puts $fd "\175 aPragmaNames\[\] = \173" | 508 puts $fd { u8 iPragCName; /* Start of column names in pragCName[] */} |
| 509 puts $fd " u8 nPragCName; \ |
| 510 /* Num of col names. 0 means use pragma name */" |
| 511 puts $fd " u32 iArg; /* Extra argument */" |
| 512 puts $fd "\175 PragmaName;" |
| 513 puts $fd "static const PragmaName aPragmaName\[\] = \173" |
424 | 514 |
425 set current_if {} | 515 set current_if {} |
426 set spacer [format { %26s } {}] | 516 set spacer [format { %26s } {}] |
427 foreach name $allnames { | 517 foreach name $allnames { |
428 foreach {type arg if flag} $allbyname($name) break | 518 foreach {type arg if flag cx} $allbyname($name) break |
| 519 if {$cx==0} { |
| 520 set cy 0 |
| 521 set nx 0 |
| 522 } else { |
| 523 set cy $cols_offset($cx) |
| 524 set nx [llength [lindex $cols_list [expr {$cx-1}]]] |
| 525 } |
429 if {$if!=$current_if} { | 526 if {$if!=$current_if} { |
430 if {$current_if!=""} { | 527 if {$current_if!=""} { |
431 foreach this_if $current_if { | 528 foreach this_if $current_if { |
432 puts $fd "#endif" | 529 puts $fd "#endif" |
433 } | 530 } |
434 } | 531 } |
435 set current_if $if | 532 set current_if $if |
436 if {$current_if!=""} { | 533 if {$current_if!=""} { |
437 foreach this_if $current_if { | 534 foreach this_if $current_if { |
438 puts $fd "#if $this_if" | 535 puts $fd "#if $this_if" |
439 } | 536 } |
440 } | 537 } |
441 } | 538 } |
442 set typex [format PragTyp_%-23s $type,] | 539 set typex [format PragTyp_%-23s $type,] |
443 if {$flag==""} { | 540 if {$flag==""} { |
444 set flagx "0" | 541 set flagx "0" |
445 } else { | 542 } else { |
446 set flagx PragFlag_[join $flag {|PragFlag_}] | 543 set flagx PragFlg_[join $flag {|PragFlg_}] |
447 } | 544 } |
448 puts $fd " \173 /* zName: */ \"$name\"," | 545 puts $fd " \173/* zName: */ \"$name\"," |
449 puts $fd " /* ePragTyp: */ PragTyp_$type," | 546 puts $fd " /* ePragTyp: */ PragTyp_$type," |
450 puts $fd " /* ePragFlag: */ $flagx," | 547 puts $fd " /* ePragFlg: */ $flagx," |
451 puts $fd " /* iArg: */ $arg \175," | 548 puts $fd " /* ColNames: */ $cy, $nx," |
| 549 puts $fd " /* iArg: */ $arg \175," |
452 } | 550 } |
453 if {$current_if!=""} { | 551 if {$current_if!=""} { |
454 foreach this_if $current_if { | 552 foreach this_if $current_if { |
455 puts $fd "#endif" | 553 puts $fd "#endif" |
456 } | 554 } |
457 } | 555 } |
458 puts $fd "\175;" | 556 puts $fd "\175;" |
459 | 557 |
460 # count the number of pragmas, for information purposes | 558 # count the number of pragmas, for information purposes |
461 # | 559 # |
462 set allcnt 0 | 560 set allcnt 0 |
463 set dfltcnt 0 | 561 set dfltcnt 0 |
464 foreach name $allnames { | 562 foreach name $allnames { |
465 incr allcnt | 563 incr allcnt |
466 set if [lindex $allbyname($name) 2] | 564 set if [lindex $allbyname($name) 2] |
467 if {[regexp {^defined} $if] || [regexp {[^!]defined} $if]} continue | 565 if {[regexp {^defined} $if] || [regexp {[^!]defined} $if]} continue |
468 incr dfltcnt | 566 incr dfltcnt |
469 } | 567 } |
470 puts $fd "/* Number of pragmas: $dfltcnt on by default, $allcnt total. */" | 568 puts $fd "/* Number of pragmas: $dfltcnt on by default, $allcnt total. */" |
OLD | NEW |