| 1 |
# 2022 September 07 |
| 2 |
# |
| 3 |
# The author disclaims copyright to this source code. In place of |
| 4 |
# a legal notice, here is a blessing: |
| 5 |
# |
| 6 |
# May you do good and not evil. |
| 7 |
# May you find forgiveness for yourself and forgive others. |
| 8 |
# May you share freely, never taking more than you give. |
| 9 |
# |
| 10 |
#*********************************************************************** |
| 11 |
# |
| 12 |
# Tests for the SQLITE_RECOVER_ROWIDS option. |
| 13 |
# |
| 14 |
|
| 15 |
source [file join [file dirname [info script]] recover_common.tcl] |
| 16 |
set testprefix recoverrowid |
| 17 |
|
| 18 |
proc recover {db bRowids output} { |
| 19 |
forcedelete $output |
| 20 |
|
| 21 |
set R [sqlite3_recover_init db main test.db2] |
| 22 |
$R config rowids $bRowids |
| 23 |
$R run |
| 24 |
$R finish |
| 25 |
} |
| 26 |
|
| 27 |
do_execsql_test 1.0 { |
| 28 |
CREATE TABLE t1(a, b); |
| 29 |
INSERT INTO t1 VALUES(1, 1), (2, 2), (3, 3), (4, 4); |
| 30 |
DELETE FROM t1 WHERE a IN (1, 3); |
| 31 |
} |
| 32 |
|
| 33 |
do_test 1.1 { |
| 34 |
recover db 0 test.db2 |
| 35 |
sqlite3 db2 test.db2 |
| 36 |
execsql { SELECT rowid, a, b FROM t1 ORDER BY rowid} db2 |
| 37 |
} {1 2 2 2 4 4} |
| 38 |
|
| 39 |
do_test 1.2 { |
| 40 |
db2 close |
| 41 |
recover db 1 test.db2 |
| 42 |
sqlite3 db2 test.db2 |
| 43 |
execsql { SELECT rowid, a, b FROM t1 ORDER BY rowid} db2 |
| 44 |
} {2 2 2 4 4 4} |
| 45 |
db2 close |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
finish_test |