38f9c7194d
FossilOrigin-Name: 8dcc1d89d955bf58c80a8c30a37960f0cf95719953951a92626cc332cc75ec60
89 lines
2.1 KiB
Plaintext
89 lines
2.1 KiB
Plaintext
# 2019 April 23
|
|
#
|
|
# The author disclaims copyright to this source code. In place of
|
|
# a legal notice, here is a blessing:
|
|
#
|
|
# May you do good and not evil.
|
|
# May you find forgiveness for yourself and forgive others.
|
|
# May you share freely, never taking more than you give.
|
|
#
|
|
#***********************************************************************
|
|
#
|
|
# Test the shell tool ".ar" command.
|
|
#
|
|
|
|
set testdir [file dirname $argv0]
|
|
source $testdir/tester.tcl
|
|
set testprefix recover
|
|
|
|
ifcapable !vtab {
|
|
finish_test; return
|
|
}
|
|
set CLI [test_find_cli]
|
|
|
|
proc compare_result {db1 db2 sql} {
|
|
set r1 [$db1 eval $sql]
|
|
set r2 [$db2 eval $sql]
|
|
if {$r1 != $r2} {
|
|
puts "r1: $r1"
|
|
puts "r2: $r2"
|
|
error "mismatch for $sql"
|
|
}
|
|
return ""
|
|
}
|
|
|
|
proc compare_dbs {db1 db2} {
|
|
compare_result $db1 $db2 "SELECT sql FROM sqlite_master ORDER BY 1"
|
|
foreach tbl [$db1 eval {SELECT name FROM sqlite_master WHERE type='table'}] {
|
|
compare_result $db1 $db2 "SELECT * FROM $tbl"
|
|
}
|
|
}
|
|
|
|
proc do_recover_test {tn} {
|
|
set fd [open "|$::CLI test.db .recover"]
|
|
fconfigure $fd -encoding binary
|
|
fconfigure $fd -translation binary
|
|
set sql [read $fd]
|
|
close $fd
|
|
|
|
forcedelete test.db2
|
|
sqlite3 db2 test.db2
|
|
breakpoint
|
|
execsql $sql db2
|
|
uplevel [list do_test $tn [list compare_dbs db db2] {}]
|
|
db2 close
|
|
}
|
|
|
|
set doc {
|
|
hello
|
|
world
|
|
}
|
|
do_execsql_test 1.1.1 {
|
|
CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
|
|
INSERT INTO t1 VALUES(1, 4, X'1234567800');
|
|
INSERT INTO t1 VALUES(2, 'test', 8.1);
|
|
INSERT INTO t1 VALUES(3, $doc, 8.4);
|
|
}
|
|
do_recover_test 1.1.2
|
|
|
|
do_execsql_test 1.2.1 "
|
|
DELETE FROM t1;
|
|
INSERT INTO t1 VALUES(13, 'hello\r\nworld', 13);
|
|
"
|
|
do_recover_test 1.2.2
|
|
|
|
do_execsql_test 1.3.1 "
|
|
CREATE TABLE t2(i INTEGER PRIMARY KEY AUTOINCREMENT, b, c);
|
|
INSERT INTO t2 VALUES(NULL, 1, 2);
|
|
INSERT INTO t2 VALUES(NULL, 3, 4);
|
|
INSERT INTO t2 VALUES(NULL, 5, 6);
|
|
CREATE TABLE t3(i INTEGER PRIMARY KEY AUTOINCREMENT, b, c);
|
|
INSERT INTO t3 VALUES(NULL, 1, 2);
|
|
INSERT INTO t3 VALUES(NULL, 3, 4);
|
|
INSERT INTO t3 VALUES(NULL, 5, 6);
|
|
DELETE FROM t2;
|
|
"
|
|
do_recover_test 1.3.2
|
|
|
|
finish_test
|