/ 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 Unified Diffs Ignore Whitespace Patch

Changes to tool/spaceanal.tcl.

1
2
3
4
5
6



7
8
9
10
11
12
13
14
15
16
17
18
..
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Run this TCL script using "testfixture" in order get a report that shows
# how much disk space is used by a particular data to actually store data
# versus how much space is unused.
#

if {[catch {




# Get the name of the database to analyze
#
#set argv $argv0
if {[llength $argv]!=1} {
  puts stderr "Usage: $argv0 database-name"
  exit 1
}
set file_to_analyze [lindex $argv 0]
if {![file exists $file_to_analyze]} {
  puts stderr "No such file: $file_to_analyze"
  exit 1
................................................................................
if {[file size $file_to_analyze]<512} {
  puts stderr "Empty or malformed database: $file_to_analyze"
  exit 1
}

# Open the database
#
sqlite3 db [lindex $argv 0]
register_dbstat_vtab db

set pageSize [db one {PRAGMA page_size}]

#set DB [btree_open [lindex $argv 0] 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.
#
sqlite3 mem :memory:






>
>
>




|







 







|




|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Run this TCL script using "testfixture" in order get a report that shows
# 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 {![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]} {
  puts stderr "No such file: $file_to_analyze"
  exit 1
................................................................................
if {[file size $file_to_analyze]<512} {
  puts stderr "Empty or malformed database: $file_to_analyze"
  exit 1
}

# Open the database
#
sqlite3 db $file_to_analyze
register_dbstat_vtab db

set pageSize [db one {PRAGMA page_size}]

#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.
#
sqlite3 mem :memory: