2014-11-20 20:19:02 +01:00
|
|
|
# 2014 November 20
|
|
|
|
#
|
|
|
|
# The author disclaims copyright to this source code. In place of
|
|
|
|
# a legal notice, here is a blessing:
|
|
|
|
#
|
|
|
|
# May you do good and not evil.
|
|
|
|
# May you find forgiveness for yourself and forgive others.
|
|
|
|
# May you share freely, never taking more than you give.
|
|
|
|
#
|
|
|
|
#***********************************************************************
|
|
|
|
#
|
2015-07-23 22:44:49 +02:00
|
|
|
# Test the rbu_delta() feature.
|
2014-11-20 20:19:02 +01:00
|
|
|
#
|
|
|
|
|
2023-01-27 20:59:46 +01:00
|
|
|
source [file join [file dirname [info script]] rbu_common.tcl]
|
2023-02-04 22:25:17 +01:00
|
|
|
if_no_rbu_support { finish_test ; return }
|
2015-07-23 22:44:49 +02:00
|
|
|
set ::testprefix rbu8
|
2014-11-20 20:19:02 +01:00
|
|
|
|
|
|
|
do_execsql_test 1.0 {
|
|
|
|
CREATE TABLE t1(x, y PRIMARY KEY, z);
|
|
|
|
INSERT INTO t1 VALUES(NULL, 1, 'one');
|
|
|
|
INSERT INTO t1 VALUES(NULL, 2, 'two');
|
|
|
|
INSERT INTO t1 VALUES(NULL, 3, 'three');
|
|
|
|
CREATE INDEX i1z ON t1(z, x);
|
|
|
|
}
|
|
|
|
|
|
|
|
do_test 1.1 {
|
2015-07-23 22:44:49 +02:00
|
|
|
forcedelete rbu.db
|
|
|
|
sqlite3 db2 rbu.db
|
2014-11-20 20:19:02 +01:00
|
|
|
db2 eval {
|
2015-07-23 22:44:49 +02:00
|
|
|
CREATE TABLE data_t1(x, y, z, rbu_control);
|
2014-11-20 20:19:02 +01:00
|
|
|
INSERT INTO data_t1 VALUES('a', 1, '_i' , 'x.d');
|
|
|
|
INSERT INTO data_t1 VALUES('b', 2, 2 , '..x');
|
|
|
|
INSERT INTO data_t1 VALUES('_iii', 3, '-III' , 'd.d');
|
|
|
|
}
|
|
|
|
db2 close
|
|
|
|
} {}
|
|
|
|
|
|
|
|
do_test 1.2.1 {
|
2015-07-23 22:44:49 +02:00
|
|
|
sqlite3rbu rbu test.db rbu.db
|
|
|
|
rbu step
|
2014-11-20 20:19:02 +01:00
|
|
|
} {SQLITE_ERROR}
|
|
|
|
do_test 1.2.2 {
|
2015-07-23 22:44:49 +02:00
|
|
|
list [catch {rbu close} msg] $msg
|
|
|
|
} {1 {SQLITE_ERROR - no such function: rbu_delta}}
|
2014-11-20 20:19:02 +01:00
|
|
|
|
2015-07-23 22:44:49 +02:00
|
|
|
proc rbu_delta {orig new} {
|
2014-11-20 20:19:02 +01:00
|
|
|
return "${orig}${new}"
|
|
|
|
}
|
|
|
|
|
|
|
|
do_test 1.3.1 {
|
|
|
|
while 1 {
|
2015-07-23 22:44:49 +02:00
|
|
|
sqlite3rbu rbu test.db rbu.db
|
|
|
|
rbu create_rbu_delta
|
|
|
|
set rc [rbu step]
|
2014-11-20 20:19:02 +01:00
|
|
|
if {$rc != "SQLITE_OK"} break
|
2015-07-23 22:44:49 +02:00
|
|
|
rbu close
|
2014-11-20 20:19:02 +01:00
|
|
|
}
|
2015-07-23 22:44:49 +02:00
|
|
|
rbu close
|
2014-11-20 20:19:02 +01:00
|
|
|
} {SQLITE_DONE}
|
|
|
|
|
|
|
|
do_execsql_test 1.3.2 {
|
|
|
|
SELECT * FROM t1
|
|
|
|
} {
|
|
|
|
a 1 one_i
|
|
|
|
{} 2 2
|
|
|
|
_iii 3 three-III
|
|
|
|
}
|
|
|
|
integrity_check 1.3.3
|
|
|
|
|
|
|
|
|
|
|
|
finish_test
|