Actually perform index checks when running sqlite3_checker
FossilOrigin-Name: 54530020260ea9e4cfd021f5ffccb74d78c469b717dce377d3df6eaf84b63719
This commit is contained in:
parent
4e8ad3bc14
commit
1fae37319e
@ -42,6 +42,37 @@ proc tclsh {} {
|
||||
}
|
||||
}
|
||||
|
||||
# Do an incremental integrity check of a single index
|
||||
#
|
||||
proc check_index {idxname batchsize} {
|
||||
set i 0
|
||||
set more 1
|
||||
set nerr 0
|
||||
puts -nonewline "$idxname: "
|
||||
while {$more} {
|
||||
set more 0
|
||||
db eval {SELECT errmsg, current_key AS key
|
||||
FROM incremental_index_check($idxname)
|
||||
WHERE after_key=$key
|
||||
LIMIT $batchsize} {
|
||||
set more 1
|
||||
if {$errmsg!=""} {
|
||||
if {$nerr>0} {
|
||||
puts -nonewline "$idxname: "
|
||||
}
|
||||
incr nerr
|
||||
puts "row $i: $errmsg"
|
||||
}
|
||||
incr i
|
||||
}
|
||||
}
|
||||
if {$nerr==0} {
|
||||
puts "$i entries, ok"
|
||||
} else {
|
||||
puts "$idxname: $nerr errors out of $i entries"
|
||||
}
|
||||
}
|
||||
|
||||
# Print a usage message on standard error, then quit.
|
||||
#
|
||||
proc usage {} {
|
||||
@ -53,9 +84,17 @@ Do sanity checking on a live SQLite3 database file specified by the
|
||||
|
||||
Options:
|
||||
|
||||
--batchsize N Number of rows to check per transaction
|
||||
|
||||
--freelist Perform a freelist check
|
||||
|
||||
--tclsh Run the built-in TCL interpreter interactively (for debugging)
|
||||
--index NAME Run a check of the index NAME
|
||||
|
||||
--summary Print summary information about the database
|
||||
|
||||
--table NAME Run a check of all indexes for table NAME
|
||||
|
||||
--tclsh Run the built-in TCL interpreter (for debugging)
|
||||
|
||||
--version Show the version number of SQLite
|
||||
}
|
||||
@ -65,8 +104,14 @@ Options:
|
||||
set file_to_analyze {}
|
||||
append argv {}
|
||||
set bFreelistCheck 0
|
||||
set bSummary 1
|
||||
foreach arg $argv {
|
||||
set bSummary 0
|
||||
set zIndex {}
|
||||
set zTable {}
|
||||
set batchsize 100
|
||||
set bAll 1
|
||||
set argc [llength $argv]
|
||||
for {set i 0} {$i<$argc} {incr i} {
|
||||
set arg [lindex $argv $i]
|
||||
if {[regexp {^-+tclsh$} $arg]} {
|
||||
tclsh
|
||||
exit 0
|
||||
@ -79,7 +124,41 @@ foreach arg $argv {
|
||||
}
|
||||
if {[regexp {^-+freelist$} $arg]} {
|
||||
set bFreelistCheck 1
|
||||
set bSummary 0
|
||||
set bAll 0
|
||||
continue
|
||||
}
|
||||
if {[regexp {^-+summary$} $arg]} {
|
||||
set bSummary 1
|
||||
set bAll 0
|
||||
continue
|
||||
}
|
||||
if {[regexp {^-+batchsize$} $arg]} {
|
||||
incr i
|
||||
if {$i>=$argc} {
|
||||
puts stderr "missing argument on $arg"
|
||||
exit 1
|
||||
}
|
||||
set batchsize [lindex $argv $i]
|
||||
continue
|
||||
}
|
||||
if {[regexp {^-+index$} $arg]} {
|
||||
incr i
|
||||
if {$i>=$argc} {
|
||||
puts stderr "missing argument on $arg"
|
||||
exit 1
|
||||
}
|
||||
set zIndex [lindex $argv $i]
|
||||
set bAll 0
|
||||
continue
|
||||
}
|
||||
if {[regexp {^-+table$} $arg]} {
|
||||
incr i
|
||||
if {$i>=$argc} {
|
||||
puts stderr "missing argument on $arg"
|
||||
exit 1
|
||||
}
|
||||
set zTable [lindex $argv $i]
|
||||
set bAll 0
|
||||
continue
|
||||
}
|
||||
if {[regexp {^-} $arg]} {
|
||||
@ -118,8 +197,8 @@ if {[catch {sqlite3 db $file_to_analyze} res]} {
|
||||
exit 1
|
||||
}
|
||||
|
||||
if {$bFreelistCheck} {
|
||||
puts "freelist-check:"
|
||||
if {$bFreelistCheck || $bAll} {
|
||||
puts -nonewline "freelist-check: "
|
||||
flush stdout
|
||||
puts [db one {SELECT checkfreelist('main')}]
|
||||
}
|
||||
@ -143,3 +222,21 @@ if {$bSummary} {
|
||||
[expr {$sz/$scale}] $unit $name $tbl_name]
|
||||
}
|
||||
}
|
||||
if {$zIndex!=""} {
|
||||
check_index $zIndex $batchsize
|
||||
}
|
||||
if {$zTable!=""} {
|
||||
foreach idx [db eval {SELECT name FROM sqlite_master
|
||||
WHERE type='index' AND rootpage>0
|
||||
AND tbl_name=$zTable}] {
|
||||
check_index $idx $batchsize
|
||||
}
|
||||
}
|
||||
if {$bAll} {
|
||||
set allidx [db eval {SELECT name FROM sqlite_btreeinfo('main')
|
||||
WHERE type='index' AND rootpage>0
|
||||
ORDER BY nEntry}]
|
||||
foreach idx $allidx {
|
||||
check_index $idx $batchsize
|
||||
}
|
||||
}
|
||||
|
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Begin\sputting\sfunctionality\sinto\sthe\ssqlite3_checker\sbinary.
|
||||
D 2017-11-01T00:10:34.144
|
||||
C Actually\sperform\sindex\schecks\swhen\srunning\ssqlite3_checker
|
||||
D 2017-11-01T01:01:20.360
|
||||
F Makefile.in b142eb20482922153ebc77b261cdfd0a560ed05a81e9f6d9a2b0e8192922a1d2
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc a55372a22454e742ba7c8f6edf05b83213ec01125166ad7dcee0567e2f7fc81b
|
||||
@ -330,7 +330,7 @@ F ext/repair/README.md 92f5e8aae749a4dae14f02eea8e1bb42d4db2b6ce5e83dbcdd6b14469
|
||||
F ext/repair/checkfreelist.c 0abb84b4545016d57ba1a2aa8884c72c73ed838968909858c03bc1f38fb6b054
|
||||
F ext/repair/checkindex.c f33d90ed6a556ad03511f7932891c2fd47ad93ddc998a4ab8bb56f4adf6fb206
|
||||
F ext/repair/sqlite3_checker.c.in 16d62615dfce1ff3eeac83d1a77fe376a7b660afa9db07e1fdd8b964dcc41510
|
||||
F ext/repair/sqlite3_checker.tcl cc94d391dae61c5076cadd4789caa8a0cf19701a5f5cd19d329b77d2fe47a967
|
||||
F ext/repair/sqlite3_checker.tcl c7f68b0d2d2832d90a591c5cad936264c0d54cb2a06bee55d7e391d385fc7a1e
|
||||
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
|
||||
F ext/rtree/rtree.c cc91b6905bf55512c6ebc7dfdd37ac81c86f1753db8cfa6d62f0ee864464044f
|
||||
F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e
|
||||
@ -1671,7 +1671,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 24adf90ffb3ce9ff3c26efef0357f3a47312e8d11dc391ef2cc7e6873ef25895
|
||||
R f819f4cdc6b92e91586a5e2d567aa2dc
|
||||
P e82e883b93128e4d1105a82abe8d1860c0a15505b6ca421e187b9bbbc2fdc659
|
||||
R 6f23f39130aeaf4ea9f27fe6626dd3eb
|
||||
U drh
|
||||
Z e7d1ee3ba646c59ecaada1f36dfcbcb9
|
||||
Z cc97ad1013bf49d4724282a689bb05ce
|
||||
|
@ -1 +1 @@
|
||||
e82e883b93128e4d1105a82abe8d1860c0a15505b6ca421e187b9bbbc2fdc659
|
||||
54530020260ea9e4cfd021f5ffccb74d78c469b717dce377d3df6eaf84b63719
|
Loading…
Reference in New Issue
Block a user