| 1 |
# 2022 November 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 |
# |
| 13 |
|
| 14 |
source [file join [file dirname [info script]] rbu_common.tcl] |
| 15 |
if_no_rbu_support { finish_test ; return } |
| 16 |
set ::testprefix rburename |
| 17 |
|
| 18 |
|
| 19 |
do_execsql_test 1.0 { |
| 20 |
CREATE TABLE t1(a, b); |
| 21 |
INSERT INTO t1 VALUES(1, 2); |
| 22 |
INSERT INTO t1 VALUES(3, 4); |
| 23 |
INSERT INTO t1 VALUES(5, 6); |
| 24 |
} |
| 25 |
|
| 26 |
forcedelete test.db-vacuum |
| 27 |
|
| 28 |
proc my_rename {old new} { |
| 29 |
lappend ::my_rename_calls [list [file tail $old] [file tail $new]] |
| 30 |
file rename $old $new |
| 31 |
} |
| 32 |
|
| 33 |
do_test 1.1 { |
| 34 |
sqlite3rbu_vacuum rbu test.db |
| 35 |
rbu rename_handler my_rename |
| 36 |
while {[rbu step]=="SQLITE_OK"} {} |
| 37 |
rbu close |
| 38 |
} SQLITE_DONE |
| 39 |
|
| 40 |
do_test 1.2 { |
| 41 |
set ::my_rename_calls |
| 42 |
} {{test.db-oal test.db-wal}} |
| 43 |
|
| 44 |
proc my_rename {old new} { |
| 45 |
error "something went wrong" |
| 46 |
} |
| 47 |
|
| 48 |
do_test 1.3 { |
| 49 |
sqlite3rbu_vacuum rbu test.db |
| 50 |
rbu rename_handler my_rename |
| 51 |
while {[rbu step]=="SQLITE_OK"} {} |
| 52 |
list [catch { rbu close } msg] $msg |
| 53 |
} {1 SQLITE_IOERR} |
| 54 |
|
| 55 |
finish_test |