Index: tool/spaceanal.tcl ================================================================== --- tool/spaceanal.tcl +++ tool/spaceanal.tcl @@ -2,15 +2,18 @@ # how much disk space is used by a particular data to actually store data # versus how much space is unused. # if {[catch { +if {![info exists argv0]} { + set argv0 [file rootname [file tail [info nameofexecutable]]] +} # Get the name of the database to analyze # #set argv $argv0 -if {[llength $argv]!=1} { +if {![info exists argv] || [llength $argv]!=1} { puts stderr "Usage: $argv0 database-name" exit 1 } set file_to_analyze [lindex $argv 0] if {![file exists $file_to_analyze]} { @@ -26,16 +29,16 @@ exit 1 } # Open the database # -sqlite3 db [lindex $argv 0] +sqlite3 db $file_to_analyze register_dbstat_vtab db set pageSize [db one {PRAGMA page_size}] -#set DB [btree_open [lindex $argv 0] 1000 0] +#set DB [btree_open $file_to_analyze 1000 0] # 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.