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 / rbu / rbu8.test

94 lines · 2283 bytes Raw Blame History
1# 2014 November 20
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# Test the rbu_delta() feature.
13#
14
15source [file join [file dirname [info script]] rbu_common.tcl]
16if_no_rbu_support { finish_test ; return }
17set ::testprefix rbu8
18
19do_execsql_test 1.0 {
20 CREATE TABLE t1(x, y PRIMARY KEY, z);
21 INSERT INTO t1 VALUES(NULL, 1, 'one');
22 INSERT INTO t1 VALUES(NULL, 2, 'two');
23 INSERT INTO t1 VALUES(NULL, 3, 'three');
24 CREATE INDEX i1z ON t1(z, x);
25}
26
27do_test 1.1 {
28 forcedelete rbu.db
29 sqlite3 db2 rbu.db
30 db2 eval {
31 CREATE TABLE data_t1(x, y, z, rbu_control);
32 INSERT INTO data_t1 VALUES('a', 1, '_i' , 'x.d');
33 INSERT INTO data_t1 VALUES('b', 2, 2 , '..x');
34 INSERT INTO data_t1 VALUES('_iii', 3, '-III' , 'd.d');
35 }
36 db2 close
37} {}
38
39do_test 1.2.1 {
40 sqlite3rbu rbu test.db rbu.db
41 rbu step
42} {SQLITE_ERROR}
43do_test 1.2.2 {
44 list [catch {rbu close} msg] $msg
45} {1 {SQLITE_ERROR - no such function: rbu_delta}}
46
47proc rbu_delta {orig new} {
48 return "${orig}${new}"
49}
50
51do_test 1.3.1 {
52 while 1 {
53 sqlite3rbu rbu test.db rbu.db
54 rbu create_rbu_delta
55 set rc [rbu step]
56 if {$rc != "SQLITE_OK"} break
57 rbu close
58 }
59 rbu close
60} {SQLITE_DONE}
61
62do_execsql_test 1.3.2 {
63 SELECT * FROM t1
64} {
65 a 1 one_i
66 {} 2 2
67 _iii 3 three-III
68}
69integrity_check 1.3.3
70
71#-------------------------------------------------------------------------
72# Test for a problem in rbuDeltaApply().
73# Bug report: https://sqlite.org/bugs/forumpost/8123aba97f
74reset_db
75forcedelete rbu.db
76
77do_execsql_test 2.0 {
78 CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB);
79 INSERT INTO t1 VALUES(10, X'0102030405');
80}
81db close
82sqlite3 db rbu.db
83do_execsql_test 2.1 {
84 CREATE TABLE data_t1(a INTEGER PRIMARY KEY, b BLOB, rbu_control);
85 INSERT INTO data_t1 VALUES(10, X'410A353A11223344553540302C3B', '.f');
86}
87
88do_test 2.2 {
89 sqlite3rbu rbu test.db rbu.db
90 while {[rbu step]=="SQLITE_OK"} {}
91 list [catch { rbu close } msg] $msg
92} {0 SQLITE_DONE}
93
94finish_test