summaryrefslogtreecommitdiffstats
path: root/ext/fts5/test/fts5faultG.test
blob: 33a41dcb3813e7994c2e718b819df2e29680f96a (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
65
66
67
68
69
70
71
72
73
74
75
76
# 2010 June 15
#
# 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.
#
#***********************************************************************
#

source [file join [file dirname [info script]] fts5_common.tcl]
source $testdir/malloc_common.tcl
set testprefix fts5faultG

# If SQLITE_ENABLE_FTS5 is defined, omit this file.
ifcapable !fts5 {
  finish_test
  return
}

set ::testprefix fts5faultG


do_execsql_test 1.0 {
  CREATE VIRTUAL TABLE t1 USING fts5(a);
  INSERT INTO t1 VALUES('test renaming the table');
  INSERT INTO t1 VALUES(' after it has been written');
  INSERT INTO t1 VALUES(' actually other stuff instead');
}
faultsim_save_and_close
do_faultsim_test 1 -faults oom* -prep { 
  faultsim_restore_and_reopen
  execsql {
    BEGIN;
      DELETE FROM t1 WHERE rowid=2;
  }
} -body {
  execsql {
    DELETE FROM t1;
  }
} -test {
  catchsql { COMMIT }
  faultsim_integrity_check
  faultsim_test_result {0 {}}
}

reset_db
do_execsql_test 2.0 {
  CREATE VIRTUAL TABLE t1 USING fts5(a, content=, contentless_delete=1);
  BEGIN;
    INSERT INTO t1 VALUES('here''s some text');
    INSERT INTO t1 VALUES('useful stuff, text');
    INSERT INTO t1 VALUES('what would we do without text!'); 
  COMMIT;
}
faultsim_save_and_close
do_faultsim_test 2 -faults oom* -prep { 
  faultsim_restore_and_reopen
  execsql {
    BEGIN;
      DELETE FROM t1 WHERE rowid=2;
  }
} -body {
  execsql {
    INSERT INTO t1(t1) VALUES('optimize');
  }
} -test {
  faultsim_integrity_check
  faultsim_test_result {0 {}}
}



finish_test