sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
sqlite / ext / recover / recoversql.test
| 1 | # 2022 September 13 |
| 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]] recover_common.tcl] |
| 15 | set testprefix recoversql |
| 16 | |
| 17 | do_execsql_test 1.0 { |
| 18 | CREATE TABLE "x.1" (x, y); |
| 19 | INSERT INTO "x.1" VALUES(1, 1), (2, 2), (3, 3); |
| 20 | CREATE INDEX "i.1" ON "x.1"(y, x); |
| 21 | } |
| 22 | |
| 23 | proc sql_hook {sql} { |
| 24 | incr ::iSqlHook |
| 25 | if {$::iSqlHook==$::sql_hook_cnt} { return 4 } |
| 26 | return 0 |
| 27 | } |
| 28 | |
| 29 | do_test 1.1 { |
| 30 | set ::sql_hook_cnt -1 |
| 31 | set ::iSqlHook 0 |
| 32 | set R [sqlite3_recover_init_sql db main sql_hook] |
| 33 | $R run |
| 34 | $R finish |
| 35 | } {} |
| 36 | |
| 37 | set nSqlCall $iSqlHook |
| 38 | |
| 39 | for {set ii 1} {$ii<$nSqlCall} {incr ii} { |
| 40 | set iSqlHook 0 |
| 41 | set sql_hook_cnt $ii |
| 42 | do_test 1.$ii.a { |
| 43 | set R [sqlite3_recover_init_sql db main sql_hook] |
| 44 | $R run |
| 45 | } {1} |
| 46 | do_test 1.$ii.b { |
| 47 | list [catch { $R finish } msg] $msg |
| 48 | } {1 {callback returned an error - 4}} |
| 49 | } |
| 50 | |
| 51 | |
| 52 | finish_test |