/ Check-in [6dc987d3]
Login

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

Overview
Comment:Add support for URI filenames in sqlite3_analyzer.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6dc987d32ba4d09b811ef281cdae09be17ac936c
User & Date: drh 2012-10-10 10:52:46
Context
2012-10-10
12:14
Define the sqlite3PagerWalFramesize() function even if SQLITE_OMIT_WAL is used. check-in: 96247853 user: drh tags: trunk
10:52
Add support for URI filenames in sqlite3_analyzer. check-in: 6dc987d3 user: drh tags: trunk
09:46
Move a couple of WAL-related function declarations in sqliteInt.h and pager.h into "#ifndef SQLITE_OMIT_WAL" blocks. Otherwise, the amalgamation fails to build using some compilers with SQLITE_OMIT_WAL (static function declared but not defined). check-in: f7437153 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/spaceanal.tcl.

    26     26     } elseif {$file_to_analyze!=""} {
    27     27       usage
    28     28     } else {
    29     29       set file_to_analyze $arg
    30     30     }
    31     31   }
    32     32   if {$file_to_analyze==""} usage
    33         -if {![file exists $file_to_analyze]} {
    34         -  puts stderr "No such file: $file_to_analyze"
           33  +set root_filename $file_to_analyze
           34  +regexp {^file:(//)?([^?]*)} $file_to_analyze all x1 root_filename
           35  +if {![file exists $root_filename]} {
           36  +  puts stderr "No such file: $root_filename"
    35     37     exit 1
    36     38   }
    37         -if {![file readable $file_to_analyze]} {
    38         -  puts stderr "File is not readable: $file_to_analyze"
           39  +if {![file readable $root_filename]} {
           40  +  puts stderr "File is not readable: $root_filename"
    39     41     exit 1
    40     42   }
    41         -set true_file_size [file size $file_to_analyze]
           43  +set true_file_size [file size $root_filename]
    42     44   if {$true_file_size<512} {
    43         -  puts stderr "Empty or malformed database: $file_to_analyze"
           45  +  puts stderr "Empty or malformed database: $root_filename"
    44     46     exit 1
    45     47   }
    46     48   
    47     49   # Compute the total file size assuming test_multiplexor is being used.
    48     50   # Assume that SQLITE_ENABLE_8_3_NAMES might be enabled
    49     51   #
    50         -set extension [file extension $file_to_analyze]
    51         -set pattern $file_to_analyze
           52  +set extension [file extension $root_filename]
           53  +set pattern $root_filename
    52     54   append pattern {[0-3][0-9][0-9]}
    53     55   foreach f [glob -nocomplain $pattern] {
    54     56     incr true_file_size [file size $f]
    55     57     set extension {}
    56     58   }
    57     59   if {[string length $extension]>=2 && [string length $extension]<=4} {
    58         -  set pattern [file rootname $file_to_analyze]
           60  +  set pattern [file rootname $root_filename]
    59     61     append pattern {.[0-3][0-9][0-9]}
    60     62     foreach f [glob -nocomplain $pattern] {
    61     63       incr true_file_size [file size $f]
    62     64     }
    63     65   }
    64     66   
    65     67   # Open the database
    66     68   #
    67         -sqlite3 db $file_to_analyze
           69  +if {[catch {sqlite3 db $file_to_analyze -uri 1} msg]} {
           70  +  puts stderr "error trying to open $file_to_analyze: $msg"
           71  +  exit 1
           72  +}
    68     73   register_dbstat_vtab db
    69     74   
    70     75   db eval {SELECT count(*) FROM sqlite_master}
    71     76   set pageSize [expr {wide([db one {PRAGMA page_size}])}]
    72     77   
    73     78   if {$flags(-pageinfo)} {
    74     79     db eval {CREATE VIRTUAL TABLE temp.stat USING dbstat}
................................................................................
   480    485   # set total_payload [mem eval "SELECT sum(payload) FROM space_used"]
   481    486   set user_payload [mem one {SELECT int(sum(payload)) FROM space_used
   482    487        WHERE NOT is_index AND name NOT LIKE 'sqlite_master'}]
   483    488   set user_percent [percent $user_payload $file_bytes]
   484    489   
   485    490   # Output the summary statistics calculated above.
   486    491   #
   487         -puts "/** Disk-Space Utilization Report For $file_to_analyze"
          492  +puts "/** Disk-Space Utilization Report For $root_filename"
   488    493   catch {
   489    494     puts "*** As of [clock format [clock seconds] -format {%Y-%b-%d %H:%M:%S}]"
   490    495   }
   491    496   puts ""
   492    497   statline {Page size in bytes} $pageSize
   493    498   statline {Pages in the whole file (measured)} $file_pgcnt
   494    499   statline {Pages in the whole file (calculated)} $file_pgcnt2