/ Check-in [b97aca12]
Login

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

Overview
Comment:Minor tweaks to restore_jrnl.tcl utility script.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b97aca1200d959a1e7c08dd4e9dbce4724342119
User & Date: shaneh 2010-01-07 22:02:35
Context
2010-01-08
04:50
Added option to restore_jrnl.tcl utility to hex dump journal pages. check-in: 08c545f0 user: shaneh tags: trunk
2010-01-07
22:02
Minor tweaks to restore_jrnl.tcl utility script. check-in: b97aca12 user: shaneh tags: trunk
21:49
Small tool that attempts to repair a journal header. check-in: 05b18b5f user: shaneh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tool/restore_jrnl.tcl.

72
73
74
75
76
77
78




79
80
81
82
83
84
85
86
87
...
103
104
105
106
107
108
109
110
111
112

set db_fsize [file size $db_name]
sqlite3 db $db_name
set db_pgsz [db eval {PRAGMA page_size}]
db close
set db_npage [expr {$db_fsize / $db_pgsz}]





# calculate checksum nonce
set pgno 1
set pg_offset [expr $sectsz+((4+$db_pgsz+4)*$pgno)]
set nonce [hexio_get_int [hexio_read $jrnl_name [expr $pg_offset+4+$db_pgsz] 4]]
for {set i [expr $db_pgsz-200]} {$i>0} {set i [expr $i-200]} {
  set byte [hexio_get_int [hexio_read $jrnl_name [expr $pg_offset+4+$i] 1]]
  set nonce [expr $nonce-$byte]
}

................................................................................
# write page size
hexio_write $jrnl_name 24 [format %08x $db_pgsz]

# check the integrity of the database.
sqlite3 db $db_name
do_test restore_jrnl-1.0 {
  catchsql {PRAGMA integrity_check}
} {0 {ok}}

db close







>
>
>
>

|







 







|


72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
...
107
108
109
110
111
112
113
114
115
116

set db_fsize [file size $db_name]
sqlite3 db $db_name
set db_pgsz [db eval {PRAGMA page_size}]
db close
set db_npage [expr {$db_fsize / $db_pgsz}]

# restore in case get the page_size above changed things
copy_file $db_name.org $db_name
copy_file $jrnl_name.org $jrnl_name

# calculate checksum nonce
set pgno 0
set pg_offset [expr $sectsz+((4+$db_pgsz+4)*$pgno)]
set nonce [hexio_get_int [hexio_read $jrnl_name [expr $pg_offset+4+$db_pgsz] 4]]
for {set i [expr $db_pgsz-200]} {$i>0} {set i [expr $i-200]} {
  set byte [hexio_get_int [hexio_read $jrnl_name [expr $pg_offset+4+$i] 1]]
  set nonce [expr $nonce-$byte]
}

................................................................................
# write page size
hexio_write $jrnl_name 24 [format %08x $db_pgsz]

# check the integrity of the database.
sqlite3 db $db_name
do_test restore_jrnl-1.0 {
  catchsql {PRAGMA integrity_check}
} {0 ok}

db close