summaryrefslogtreecommitdiffstats
path: root/ext/rbu/rbuvacuum3.test
blob: d70c094f2fff41e15130bf6431522d76426bf67d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# 2019 Jan 3
#
# 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.
#
#***********************************************************************
#
# This file contains tests for the RBU module. More specifically, it
# contains tests to ensure that the sqlite3rbu_vacuum() API works as
# expected.
#

source [file join [file dirname [info script]] rbu_common.tcl]
if_no_rbu_support { finish_test ; return }
set testprefix rbuvacuum3

do_execsql_test 1.0 {
  CREATE TABLE t1(a PRIMARY KEY, b, c);
  CREATE INDEX i1b ON t1(b);
  CREATE INDEX i1c ON t1(c);
  
  WITH s(i) AS (
    VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100
  )
  INSERT INTO t1 SELECT i, randomblob(100), randomblob(100) FROM s;
}

forcedelete state.db
do_test 1.1 {
  sqlite3rbu_vacuum rbu test.db state.db
  while {1} {
    set rc [rbu step]
    if {$rc!="SQLITE_OK"} break
    rbu savestate
  }
  rbu close
} {SQLITE_DONE}

do_test 1.2 {
  sqlite3rbu_vacuum rbu test.db state.db
  while {1} {
    set rc [rbu step]
    if {$rc!="SQLITE_OK"} break
    rbu savestate
  }
  rbu close
} {SQLITE_DONE}

do_test 1.3 {
  while {1} {
    sqlite3rbu_vacuum rbu test.db state.db
    set rc [rbu step]
    if {$rc!="SQLITE_OK"} break
    rbu savestate
    rbu close
  }
  rbu close
} {SQLITE_DONE}

finish_test