Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/sqlite/src/tool/mkpragmatab.tcl

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/tool/mkopcodeh.tcl ('k') | third_party/sqlite/src/tool/mksqlite3c.tcl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 C-code for the lookup table and copy/paste the output 7 # to generate the ../src/pragma.h header file that contains macros and
8 # of this script into the appropriate spot in the pragma.c source file. 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. 10 # new pragma in ../src/pragma.c.
11 # 11 #
12 12
13 set pragma_def { 13 set pragma_def {
14 NAME: full_column_names 14 NAME: full_column_names
15 TYPE: FLAG 15 TYPE: FLAG
16 ARG: SQLITE_FullColNames 16 ARG: SQLITE_FullColNames
17 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) 17 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS)
18 18
19 NAME: short_column_names 19 NAME: short_column_names
20 TYPE: FLAG 20 TYPE: FLAG
(...skipping 19 matching lines...) Expand all
40 TYPE: FLAG 40 TYPE: FLAG
41 ARG: SQLITE_FullFSync 41 ARG: SQLITE_FullFSync
42 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) 42 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS)
43 43
44 NAME: checkpoint_fullfsync 44 NAME: checkpoint_fullfsync
45 TYPE: FLAG 45 TYPE: FLAG
46 ARG: SQLITE_CkptFullFSync 46 ARG: SQLITE_CkptFullFSync
47 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) 47 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS)
48 48
49 NAME: cache_spill 49 NAME: cache_spill
50 TYPE: FLAG
51 ARG: SQLITE_CacheSpill
52 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) 50 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS)
53 51
54 NAME: reverse_unordered_selects 52 NAME: reverse_unordered_selects
55 TYPE: FLAG 53 TYPE: FLAG
56 ARG: SQLITE_ReverseOrder 54 ARG: SQLITE_ReverseOrder
57 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) 55 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS)
58 56
59 NAME: query_only 57 NAME: query_only
60 TYPE: FLAG 58 TYPE: FLAG
61 ARG: SQLITE_QueryOnly 59 ARG: SQLITE_QueryOnly
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 ARG: SQLITE_ForeignKeys 127 ARG: SQLITE_ForeignKeys
130 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) 128 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS)
131 IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) 129 IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
132 130
133 NAME: defer_foreign_keys 131 NAME: defer_foreign_keys
134 TYPE: FLAG 132 TYPE: FLAG
135 ARG: SQLITE_DeferFKs 133 ARG: SQLITE_DeferFKs
136 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) 134 IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS)
137 IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) 135 IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
138 136
137 NAME: cell_size_check
138 TYPE: FLAG
139 ARG: SQLITE_CellSizeCk
140
139 NAME: default_cache_size 141 NAME: default_cache_size
140 FLAG: NeedSchema 142 FLAG: NeedSchema
141 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED) 143 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
142 144
143 NAME: page_size 145 NAME: page_size
144 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) 146 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
145 147
146 NAME: secure_delete 148 NAME: secure_delete
147 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) 149 IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
148 150
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 200
199 NAME: table_info 201 NAME: table_info
200 FLAG: NeedSchema 202 FLAG: NeedSchema
201 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) 203 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
202 204
203 NAME: stats 205 NAME: stats
204 FLAG: NeedSchema 206 FLAG: NeedSchema
205 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) 207 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
206 208
207 NAME: index_info 209 NAME: index_info
210 TYPE: INDEX_INFO
211 ARG: 0
208 FLAG: NeedSchema 212 FLAG: NeedSchema
209 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) 213 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
210 214
215 NAME: index_xinfo
216 TYPE: INDEX_INFO
217 ARG: 1
218 FLAG: NeedSchema
219 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
220
211 NAME: index_list 221 NAME: index_list
212 FLAG: NeedSchema 222 FLAG: NeedSchema
213 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) 223 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
214 224
215 NAME: database_list 225 NAME: database_list
216 FLAG: NeedSchema 226 FLAG: NeedSchema
217 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) 227 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
218 228
219 NAME: collation_list 229 NAME: collation_list
220 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) 230 IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
221 231
222 NAME: foreign_key_list 232 NAME: foreign_key_list
223 FLAG: NeedSchema 233 FLAG: NeedSchema
224 IF: !defined(SQLITE_OMIT_FOREIGN_KEY) 234 IF: !defined(SQLITE_OMIT_FOREIGN_KEY)
225 235
226 NAME: foreign_key_check 236 NAME: foreign_key_check
227 FLAG: NeedSchema 237 FLAG: NeedSchema
228 IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) 238 IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
229 239
230 NAME: parser_trace 240 NAME: parser_trace
231 IF: defined(SQLITE_DEBUG) 241 IF: defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_PARSER_TRACE)
232 242
233 NAME: case_sensitive_like 243 NAME: case_sensitive_like
234 244
235 NAME: integrity_check 245 NAME: integrity_check
236 FLAG: NeedSchema 246 FLAG: NeedSchema
237 IF: !defined(SQLITE_OMIT_INTEGRITY_CHECK) 247 IF: !defined(SQLITE_OMIT_INTEGRITY_CHECK)
238 248
239 NAME: quick_check 249 NAME: quick_check
240 TYPE: INTEGRITY_CHECK 250 TYPE: INTEGRITY_CHECK
241 FLAG: NeedSchema 251 FLAG: NeedSchema
242 IF: !defined(SQLITE_OMIT_INTEGRITY_CHECK) 252 IF: !defined(SQLITE_OMIT_INTEGRITY_CHECK)
243 253
244 NAME: encoding 254 NAME: encoding
245 IF: !defined(SQLITE_OMIT_UTF16) 255 IF: !defined(SQLITE_OMIT_UTF16)
246 256
247 NAME: schema_version 257 NAME: schema_version
248 TYPE: HEADER_VALUE 258 TYPE: HEADER_VALUE
259 ARG: BTREE_SCHEMA_VERSION
249 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) 260 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
250 261
251 NAME: user_version 262 NAME: user_version
252 TYPE: HEADER_VALUE 263 TYPE: HEADER_VALUE
264 ARG: BTREE_USER_VERSION
265 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
266
267 NAME: data_version
268 TYPE: HEADER_VALUE
269 ARG: BTREE_DATA_VERSION
270 FLAG: ReadOnly
253 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) 271 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
254 272
255 NAME: freelist_count 273 NAME: freelist_count
256 TYPE: HEADER_VALUE 274 TYPE: HEADER_VALUE
275 ARG: BTREE_FREE_PAGE_COUNT
276 FLAG: ReadOnly
257 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) 277 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
258 278
259 NAME: application_id 279 NAME: application_id
260 TYPE: HEADER_VALUE 280 TYPE: HEADER_VALUE
281 ARG: BTREE_APPLICATION_ID
261 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) 282 IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
262 283
263 NAME: compile_options 284 NAME: compile_options
264 IF: !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS) 285 IF: !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
265 286
266 NAME: wal_checkpoint 287 NAME: wal_checkpoint
267 FLAG: NeedSchema 288 FLAG: NeedSchema
268 IF: !defined(SQLITE_OMIT_WAL) 289 IF: !defined(SQLITE_OMIT_WAL)
269 290
270 NAME: wal_autocheckpoint 291 NAME: wal_autocheckpoint
(...skipping 19 matching lines...) Expand all
290 TYPE: HEXKEY 311 TYPE: HEXKEY
291 IF: defined(SQLITE_HAS_CODEC) 312 IF: defined(SQLITE_HAS_CODEC)
292 313
293 NAME: activate_extensions 314 NAME: activate_extensions
294 IF: defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD) 315 IF: defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)
295 316
296 NAME: soft_heap_limit 317 NAME: soft_heap_limit
297 318
298 NAME: threads 319 NAME: threads
299 } 320 }
300 fconfigure stdout -translation lf 321
322 # Open the output file
323 #
324 set destfile "[file dir [file dir [file normal $argv0]]]/src/pragma.h"
325 puts "Overwriting $destfile with new pragma table..."
326 set fd [open $destfile wb]
327 puts $fd {/* DO NOT EDIT!
328 ** This file is automatically generated by the script at
329 ** ../tool/mkpragmatab.tcl. To update the set of pragmas, edit
330 ** that script and rerun it.
331 */}
332
333 # Parse the PRAGMA table above.
334 #
301 set name {} 335 set name {}
302 set type {} 336 set type {}
303 set if {} 337 set if {}
304 set flags {} 338 set flags {}
305 set arg 0 339 set arg 0
306 proc record_one {} { 340 proc record_one {} {
307 global name type if arg allbyname typebyif flags 341 global name type if arg allbyname typebyif flags
308 if {$name==""} return 342 if {$name==""} return
309 set allbyname($name) [list $type $arg $if $flags] 343 set allbyname($name) [list $type $arg $if $flags]
310 set name {} 344 set name {}
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 # omit in default builds (defined(SQLITE_DEBUG) and defined(SQLITE_HAS_CODEC)) 378 # omit in default builds (defined(SQLITE_DEBUG) and defined(SQLITE_HAS_CODEC))
345 # at the end. 379 # at the end.
346 # 380 #
347 set pnum 0 381 set pnum 0
348 foreach name $allnames { 382 foreach name $allnames {
349 set type [lindex $allbyname($name) 0] 383 set type [lindex $allbyname($name) 0]
350 if {[info exists seentype($type)]} continue 384 if {[info exists seentype($type)]} continue
351 set if [lindex $allbyname($name) 2] 385 set if [lindex $allbyname($name) 2]
352 if {[regexp SQLITE_DEBUG $if] || [regexp SQLITE_HAS_CODEC $if]} continue 386 if {[regexp SQLITE_DEBUG $if] || [regexp SQLITE_HAS_CODEC $if]} continue
353 set seentype($type) 1 387 set seentype($type) 1
354 puts [format {#define %-35s %4d} PragTyp_$type $pnum] 388 puts $fd [format {#define %-35s %4d} PragTyp_$type $pnum]
355 incr pnum 389 incr pnum
356 } 390 }
357 foreach name $allnames { 391 foreach name $allnames {
358 set type [lindex $allbyname($name) 0] 392 set type [lindex $allbyname($name) 0]
359 if {[info exists seentype($type)]} continue 393 if {[info exists seentype($type)]} continue
360 set if [lindex $allbyname($name) 2] 394 set if [lindex $allbyname($name) 2]
361 if {[regexp SQLITE_DEBUG $if]} continue 395 if {[regexp SQLITE_DEBUG $if]} continue
362 set seentype($type) 1 396 set seentype($type) 1
363 puts [format {#define %-35s %4d} PragTyp_$type $pnum] 397 puts $fd [format {#define %-35s %4d} PragTyp_$type $pnum]
364 incr pnum 398 incr pnum
365 } 399 }
366 foreach name $allnames { 400 foreach name $allnames {
367 set type [lindex $allbyname($name) 0] 401 set type [lindex $allbyname($name) 0]
368 if {[info exists seentype($type)]} continue 402 if {[info exists seentype($type)]} continue
369 set seentype($type) 1 403 set seentype($type) 1
370 puts [format {#define %-35s %4d} PragTyp_$type $pnum] 404 puts $fd [format {#define %-35s %4d} PragTyp_$type $pnum]
371 incr pnum 405 incr pnum
372 } 406 }
373 407
374 # Generate #defines for flags 408 # Generate #defines for flags
375 # 409 #
376 set fv 1 410 set fv 1
377 foreach f [lsort [array names allflags]] { 411 foreach f [lsort [array names allflags]] {
378 puts [format {#define PragFlag_%-20s 0x%02x} $f $fv] 412 puts $fd [format {#define PragFlag_%-20s 0x%02x} $f $fv]
379 set fv [expr {$fv*2}] 413 set fv [expr {$fv*2}]
380 } 414 }
381 415
382 # Generate the lookup table 416 # Generate the lookup table
383 # 417 #
384 puts "static const struct sPragmaNames \173" 418 puts $fd "static const struct sPragmaNames \173"
385 puts " const char *const zName; /* Name of pragma */" 419 puts $fd " const char *const zName; /* Name of pragma */"
386 puts " u8 ePragTyp; /* PragTyp_XXX value */" 420 puts $fd " u8 ePragTyp; /* PragTyp_XXX value */"
387 puts " u8 mPragFlag; /* Zero or more PragFlag_XXX values */" 421 puts $fd " u8 mPragFlag; /* Zero or more PragFlag_XXX values */"
388 puts " u32 iArg; /* Extra argument */" 422 puts $fd " u32 iArg; /* Extra argument */"
389 puts "\175 aPragmaNames\[\] = \173" 423 puts $fd "\175 aPragmaNames\[\] = \173"
390 424
391 set current_if {} 425 set current_if {}
392 set spacer [format { %26s } {}] 426 set spacer [format { %26s } {}]
393 foreach name $allnames { 427 foreach name $allnames {
394 foreach {type arg if flag} $allbyname($name) break 428 foreach {type arg if flag} $allbyname($name) break
395 if {$if!=$current_if} { 429 if {$if!=$current_if} {
396 if {$current_if!=""} { 430 if {$current_if!=""} {
397 foreach this_if $current_if { 431 foreach this_if $current_if {
398 puts "#endif" 432 puts $fd "#endif"
399 } 433 }
400 } 434 }
401 set current_if $if 435 set current_if $if
402 if {$current_if!=""} { 436 if {$current_if!=""} {
403 foreach this_if $current_if { 437 foreach this_if $current_if {
404 puts "#if $this_if" 438 puts $fd "#if $this_if"
405 } 439 }
406 } 440 }
407 } 441 }
408 set typex [format PragTyp_%-23s $type,] 442 set typex [format PragTyp_%-23s $type,]
409 if {$flag==""} { 443 if {$flag==""} {
410 set flagx "0" 444 set flagx "0"
411 } else { 445 } else {
412 set flagx PragFlag_[join $flag {|PragFlag_}] 446 set flagx PragFlag_[join $flag {|PragFlag_}]
413 } 447 }
414 puts " \173 /* zName: */ \"$name\"," 448 puts $fd " \173 /* zName: */ \"$name\","
415 puts " /* ePragTyp: */ PragTyp_$type," 449 puts $fd " /* ePragTyp: */ PragTyp_$type,"
416 puts " /* ePragFlag: */ $flagx," 450 puts $fd " /* ePragFlag: */ $flagx,"
417 puts " /* iArg: */ $arg \175," 451 puts $fd " /* iArg: */ $arg \175,"
418 } 452 }
419 if {$current_if!=""} { 453 if {$current_if!=""} {
420 foreach this_if $current_if { 454 foreach this_if $current_if {
421 puts "#endif" 455 puts $fd "#endif"
422 } 456 }
423 } 457 }
424 puts "\175;" 458 puts $fd "\175;"
425 459
426 # count the number of pragmas, for information purposes 460 # count the number of pragmas, for information purposes
427 # 461 #
428 set allcnt 0 462 set allcnt 0
429 set dfltcnt 0 463 set dfltcnt 0
430 foreach name $allnames { 464 foreach name $allnames {
431 incr allcnt 465 incr allcnt
432 set if [lindex $allbyname($name) 2] 466 set if [lindex $allbyname($name) 2]
433 if {[regexp {^defined} $if] || [regexp {[^!]defined} $if]} continue 467 if {[regexp {^defined} $if] || [regexp {[^!]defined} $if]} continue
434 incr dfltcnt 468 incr dfltcnt
435 } 469 }
436 puts "/* Number of pragmas: $dfltcnt on by default, $allcnt total. */" 470 puts $fd "/* Number of pragmas: $dfltcnt on by default, $allcnt total. */"
OLDNEW
« no previous file with comments | « third_party/sqlite/src/tool/mkopcodeh.tcl ('k') | third_party/sqlite/src/tool/mksqlite3c.tcl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698