xref: /sqlite-3.40.0/ext/fts5/test/fts5faultE.test (revision f46be6a1)
1# 2016 February 2
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 file is focused on OOM errors.
13#
14
15source [file join [file dirname [info script]] fts5_common.tcl]
16source $testdir/malloc_common.tcl
17set testprefix fts5faultE
18
19# If SQLITE_ENABLE_FTS5 is not defined, omit this file.
20ifcapable !fts5 {
21  finish_test
22  return
23}
24
25faultsim_save_and_close
26do_faultsim_test 1 -prep {
27  faultsim_restore_and_reopen
28} -body {
29  execsql { CREATE VIRTUAL TABLE t1 USING fts5(x, y, tokenize=trigram) }
30} -test {
31  faultsim_test_result {0 {}} {1 {vtable constructor failed: t1}}
32}
33
34reset_db
35do_execsql_test 2.0 {
36  CREATE VIRTUAL TABLE t1 USING fts5(x, y, tokenize=trigram);
37}
38
39faultsim_save_and_close
40do_faultsim_test 2 -prep {
41  faultsim_restore_and_reopen
42} -body {
43  execsql {
44    INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz', NULL);
45    SELECT count(*) FROM t1 WHERE x LIKE '%mnop%' AND t1 MATCH 'jkl';
46  }
47} -test {
48  faultsim_test_result {0 1} {1 {vtable constructor failed: t1}}
49}
50
51reset_db
52do_execsql_test 3.0 {
53  CREATE VIRTUAL TABLE t1 USING fts5(x, y, tokenize=trigram, detail=none);
54  INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz', NULL);
55}
56
57faultsim_save_and_close
58do_faultsim_test 3 -prep {
59  faultsim_restore_and_reopen
60} -body {
61  execsql {
62    SELECT count(*) FROM t1 WHERE x LIKE '%mnopqrs%' AND t1 MATCH 'abc'
63  }
64} -test {
65  faultsim_test_result {0 1} {1 {vtable constructor failed: t1}}
66}
67
68
69
70finish_test
71
72