/ Check-in [3fc566ac]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Cleanup/fix error handling when no arguments are supplied to the SQLite analyzer.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3fc566ac5dfce314ee414a3fb79daeeed6d0f179
User & Date: mistachkin 2011-09-15 00:40:11
Context
2011-09-16
01:38
Merge the [002caede898] fix into trunk. check-in: 95708ae2 user: drh tags: trunk
2011-09-15
19:39
Adding test case for ticket [002caede898] check-in: 62dfc51a user: drh tags: tkt-002caede898
00:40
Cleanup/fix error handling when no arguments are supplied to the SQLite analyzer. check-in: 3fc566ac user: mistachkin tags: trunk
2011-09-14
18:19
Remove 'const' from a variable that might actually be written when an OOM error occurs. Also, fix a couple MSVC/Win32 compiler warnings. check-in: 3035dc1c user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/spaceanal.tcl.

     1      1   # Run this TCL script using "testfixture" in order get a report that shows
     2      2   # how much disk space is used by a particular data to actually store data
     3      3   # versus how much space is unused.
     4      4   #
     5      5   
     6      6   if {[catch {
            7  +if {![info exists argv0]} {
            8  +  set argv0 [file rootname [file tail [info nameofexecutable]]]
            9  +}
     7     10   
     8     11   # Get the name of the database to analyze
     9     12   #
    10     13   #set argv $argv0
    11         -if {[llength $argv]!=1} {
           14  +if {![info exists argv] || [llength $argv]!=1} {
    12     15     puts stderr "Usage: $argv0 database-name"
    13     16     exit 1
    14     17   }
    15     18   set file_to_analyze [lindex $argv 0]
    16     19   if {![file exists $file_to_analyze]} {
    17     20     puts stderr "No such file: $file_to_analyze"
    18     21     exit 1
................................................................................
    24     27   if {[file size $file_to_analyze]<512} {
    25     28     puts stderr "Empty or malformed database: $file_to_analyze"
    26     29     exit 1
    27     30   }
    28     31   
    29     32   # Open the database
    30     33   #
    31         -sqlite3 db [lindex $argv 0]
           34  +sqlite3 db $file_to_analyze
    32     35   register_dbstat_vtab db
    33     36   
    34     37   set pageSize [db one {PRAGMA page_size}]
    35     38   
    36         -#set DB [btree_open [lindex $argv 0] 1000 0]
           39  +#set DB [btree_open $file_to_analyze 1000 0]
    37     40   
    38     41   # In-memory database for collecting statistics. This script loops through
    39     42   # the tables and indices in the database being analyzed, adding a row for each
    40     43   # to an in-memory database (for which the schema is shown below). It then
    41     44   # queries the in-memory db to produce the space-analysis report.
    42     45   #
    43     46   sqlite3 mem :memory: