blob: 8c913c1066d13f4ccf08901e2c6ec8e12425e9f5 [file] [log] [blame]
dan226744d2017-08-05 16:15:33 +00001# 2017-07-15
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# This file implements regression tests for SQLite library. The
12# focus of this file is error handling in the swarmvtab extension.
13#
14
15set testdir [file dirname $argv0]
16source $testdir/tester.tcl
17set testprefix swarmvtabfault
18
19ifcapable !vtab {
20 finish_test
21 return
22}
23
24proc fetch_db {file} {
25 forcedelete $file
26 sqlite3 dbX $file
27 dbX eval { CREATE TABLE t1(a INTEGER PRIMARY KEY, b) }
28 dbX close
29}
30
31forcedelete test.db1
32do_execsql_test 1.0 {
33 ATTACH 'test.db1' AS aux;
34 CREATE TABLE aux.t1(a INTEGER PRIMARY KEY, b);
35 INSERT INTO aux.t1 VALUES(1, NULL);
36 INSERT INTO aux.t1 VALUES(2, NULL);
37 INSERT INTO aux.t1 VALUES(9, NULL);
38 DETACH aux;
39} {}
40
41faultsim_save_and_close
42do_faultsim_test 1.1 -faults oom* -prep {
43 faultsim_restore_and_reopen
44 db func fetch_db fetch_db
45 load_static_extension db unionvtab
46 db eval {
47 CREATE VIRTUAL TABLE temp.xyz USING swarmvtab(
48 'VALUES
49 ("test.db1", "t1", 1, 10),
50 ("test.db2", "t1", 11, 20)
51 ', 'fetch_db'
52 );
53 }
54} -body {
55 execsql { SELECT a FROM xyz }
56} -test {
57 faultsim_test_result {0 {1 2 9}} {1 {sql error: out of memory}}
58}
59
60finish_test
61