interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / ext / recover / recoverslowidx.test

89 lines · 2305 bytes Raw Blame History
1# 2022 September 25
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_SLOWINDEXES option.
13#
14
15source [file join [file dirname [info script]] recover_common.tcl]
16set testprefix recoverslowidx
17
18do_execsql_test 1.0 {
19 PRAGMA auto_vacuum = 0;
20 CREATE TABLE t1(a, b);
21 CREATE INDEX i1 ON t1(a);
22 INSERT INTO t1 VALUES(1, 1), (2, 2), (3, 3), (4, 4);
23}
24
25proc my_sql_hook {sql} {
26 lappend ::lSql $sql
27 return 0
28}
29
30do_test 1.1 {
31 set lSql [list]
32 set R [sqlite3_recover_init_sql db main my_sql_hook]
33 while {[$R step]==0} { }
34 $R finish
35} {}
36
37do_test 1.2 {
38 set lSql
39} [list {*}{
40 {BEGIN}
41 {PRAGMA writable_schema = on}
42 {PRAGMA foreign_keys = off}
43 {PRAGMA encoding = 'UTF-8'}
44 {PRAGMA page_size = '1024'}
45 {PRAGMA auto_vacuum = '0'}
46 {PRAGMA user_version = '0'}
47 {PRAGMA application_id = '0'}
48 {CREATE TABLE t1(a, b)}
49 {INSERT OR IGNORE INTO 't1'(_rowid_, 'a', 'b') VALUES (1, 1, 1)}
50 {INSERT OR IGNORE INTO 't1'(_rowid_, 'a', 'b') VALUES (2, 2, 2)}
51 {INSERT OR IGNORE INTO 't1'(_rowid_, 'a', 'b') VALUES (3, 3, 3)}
52 {INSERT OR IGNORE INTO 't1'(_rowid_, 'a', 'b') VALUES (4, 4, 4)}
53 {CREATE INDEX i1 ON t1(a)}
54 {PRAGMA writable_schema = off}
55 {COMMIT}
56}]
57
58do_test 1.3 {
59 set lSql [list]
60 set R [sqlite3_recover_init_sql db main my_sql_hook]
61 $R config slowindexes 1
62 while {[$R step]==0} { }
63 $R finish
64} {}
65
66do_test 1.4 {
67 set lSql
68} [list {*}{
69 {BEGIN}
70 {PRAGMA writable_schema = on}
71 {PRAGMA foreign_keys = off}
72 {PRAGMA encoding = 'UTF-8'}
73 {PRAGMA page_size = '1024'}
74 {PRAGMA auto_vacuum = '0'}
75 {PRAGMA user_version = '0'}
76 {PRAGMA application_id = '0'}
77 {CREATE TABLE t1(a, b)}
78 {CREATE INDEX i1 ON t1(a)}
79 {INSERT OR IGNORE INTO 't1'(_rowid_, 'a', 'b') VALUES (1, 1, 1)}
80 {INSERT OR IGNORE INTO 't1'(_rowid_, 'a', 'b') VALUES (2, 2, 2)}
81 {INSERT OR IGNORE INTO 't1'(_rowid_, 'a', 'b') VALUES (3, 3, 3)}
82 {INSERT OR IGNORE INTO 't1'(_rowid_, 'a', 'b') VALUES (4, 4, 4)}
83 {PRAGMA writable_schema = off}
84 {COMMIT}
85}]
86
87
88finish_test
89