1# 2016 October 21
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# This test file focuses on interactions between RBU and the feature
13# enabled by SQLITE_DIRECT_OVERFLOW_READ - Direct Overflow Read.
14#
15
16if {![info exists testdir]} {
17  set testdir [file join [file dirname [info script]] .. .. test]
18}
19source $testdir/tester.tcl
20set ::testprefix rbudor
21
22set bigA [string repeat a 5000]
23set bigB [string repeat b 5000]
24do_execsql_test 1.0 {
25  PRAGMA page_size = 1024;
26  CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB);
27  INSERT INTO t1 VALUES(1, $bigA);
28} {}
29
30do_test 1.1 {
31  forcedelete rbu.db
32  sqlite3 rbu rbu.db
33  rbu eval {
34    CREATE TABLE data_t1(a, b, rbu_control);
35    INSERT INTO data_t1 VALUES(2, $bigB, 0);
36  }
37  rbu close
38} {}
39
40do_test 1.2 {
41  sqlite3rbu rbu test.db rbu.db
42  while {[rbu state]!="checkpoint"} {
43    rbu step
44  }
45  rbu step
46  db eval { SELECT * FROM t1 }
47} [list 1 $bigA 2 $bigB]
48
49do_test 1.3 {
50  while {[rbu step]=="SQLITE_OK"} {}
51  rbu close
52} {SQLITE_DONE}
53
54do_execsql_test 1.4 {
55  SELECT * FROM t1
56} [list 1 $bigA 2 $bigB]
57
58finish_test
59