Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Changes to sqlite3_analyzer to try to avoid integer overflow problems when linking against older versions of TCL. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
8c846311a0cd510bbf9361213bb60764 |
User & Date: | drh 2011-09-27 13:40:26.197 |
Context
2011-09-28
| ||
00:50 | Enhance the stat VFS to report out the total size of all pages used by a table, even if the ZIPVFS compression backend is in play. Update the sqlite3_analyzer logic to use these new outputs. (check-in: 19b8eaaf70 user: drh tags: trunk) | |
2011-09-27
| ||
13:40 | Changes to sqlite3_analyzer to try to avoid integer overflow problems when linking against older versions of TCL. (check-in: 8c846311a0 user: drh tags: trunk) | |
2011-09-26
| ||
19:32 | Changes to the analyzer script to make it work with zipvfs databases. (check-in: d82cffab6a user: dan tags: trunk) | |
Changes
Changes to tool/spaceanal.tcl.
︙ | ︙ | |||
31 32 33 34 35 36 37 | # Open the database # sqlite3 db $file_to_analyze register_dbstat_vtab db db eval {SELECT count(*) FROM sqlite_master} | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # Open the database # sqlite3 db $file_to_analyze register_dbstat_vtab db db eval {SELECT count(*) FROM sqlite_master} set pageSize [expr {wide([db one {PRAGMA page_size}])}] # In-memory database for collecting statistics. This script loops through # the tables and indices in the database being analyzed, adding a row for each # to an in-memory database (for which the schema is shown below). It then # queries the in-memory db to produce the space-analysis report. # sqlite3 mem :memory: |
︙ | ︙ | |||
141 142 143 144 145 146 147 | $gap_cnt ); } } proc integerify {real} { if {[string is double -strict $real]} { | | | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | $gap_cnt ); } } proc integerify {real} { if {[string is double -strict $real]} { return [expr {wide($real)}] } else { return 0 } } mem function int integerify # Quote a string for use in an SQL query. Examples: |
︙ | ︙ | |||
326 327 328 329 330 331 332 | # The number of entries on each pointer map page. The layout of the # database file is one pointer-map page, followed by $ptrsPerPage other # pages, followed by a pointer-map page etc. The first pointer-map page # is the second page of the file overall. set ptrsPerPage [expr double($pageSize/5)] # Return the number of pointer map pages in the database. | | | 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | # The number of entries on each pointer map page. The layout of the # database file is one pointer-map page, followed by $ptrsPerPage other # pages, followed by a pointer-map page etc. The first pointer-map page # is the second page of the file overall. set ptrsPerPage [expr double($pageSize/5)] # Return the number of pointer map pages in the database. return [expr wide(ceil( ($filePages-1.0)/($ptrsPerPage+1.0) ))] } # Calculate the summary statistics for the database and store the results # in TCL variables. They are output below. Variables are as follows: # # pageSize: Size of each page in bytes. |
︙ | ︙ | |||
361 362 363 364 365 366 367 | ### on disk, causes this tool to choke on zipvfs databases. So set it based ### on the return of [PRAGMA page_count] instead. if 0 { set file_bytes [file size $file_to_analyze] set file_pgcnt [expr {$file_bytes/$pageSize}] } set file_pgcnt [db one {PRAGMA page_count}] | | | | | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | ### on disk, causes this tool to choke on zipvfs databases. So set it based ### on the return of [PRAGMA page_count] instead. if 0 { set file_bytes [file size $file_to_analyze] set file_pgcnt [expr {$file_bytes/$pageSize}] } set file_pgcnt [db one {PRAGMA page_count}] set file_bytes [expr {$file_pgcnt * $pageSize}] set av_pgcnt [autovacuum_overhead $file_pgcnt $pageSize] set av_percent [percent $av_pgcnt $file_pgcnt] set sql {SELECT sum(leaf_pages+int_pages+ovfl_pages) FROM space_used} set inuse_pgcnt [expr wide([mem eval $sql])] set inuse_percent [percent $inuse_pgcnt $file_pgcnt] set free_pgcnt [expr {$file_pgcnt-$inuse_pgcnt-$av_pgcnt}] set free_percent [percent $free_pgcnt $file_pgcnt] set free_pgcnt2 [db one {PRAGMA freelist_count}] set free_percent2 [percent $free_pgcnt2 $file_pgcnt] set file_pgcnt2 [expr {$inuse_pgcnt+$free_pgcnt2+$av_pgcnt}] set ntable [db eval {SELECT count(*)+1 FROM sqlite_master WHERE type='table'}] |
︙ | ︙ |