blob: 4449f2368e4295162a3daddd592ee25aedc14f5e [file] [log] [blame]
danff0a4ed2017-07-18 20:49:15 +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 percentile.c extension
13#
14
15set testdir [file dirname $argv0]
16source $testdir/tester.tcl
17set testprefix unionvtabfault
18
19
20forcedelete test.db2
21do_execsql_test 1.0 {
22 ATTACH 'test.db2' AS aux;
23 CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
24 CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT);
25 CREATE TABLE aux.t3(a INTEGER PRIMARY KEY, b TEXT);
26
27 INSERT INTO t1 VALUES(1, 'one'), (2, 'two'), (3, 'three');
28 INSERT INTO t2 VALUES(10, 'ten'), (11, 'eleven'), (12, 'twelve');
29 INSERT INTO t3 VALUES(20, 'twenty'), (21, 'twenty-one'), (22, 'twenty-two');
30}
31faultsim_save_and_close
32
33do_faultsim_test 1.1 -faults * -prep {
34 faultsim_restore_and_reopen
35 load_static_extension db unionvtab
36 execsql { ATTACH 'test.db2' AS aux; }
37 execsql { CREATE TEMP TABLE xyz(x); }
38} -body {
39 execsql {
40 CREATE VIRTUAL TABLE temp.uuu USING unionvtab(
41 "VALUES(NULL, 't1', 1, 9), ('main', 't2', 10, 19), ('aux', 't3', 20, 29)"
42 );
43 }
44} -test {
45 faultsim_test_result {0 {}} \
46 {1 {vtable constructor failed: uuu}} \
47 {1 {sql error: interrupted}}
48}
49
50faultsim_restore_and_reopen
51load_static_extension db unionvtab
52execsql { ATTACH 'test.db2' AS aux; }
53execsql { CREATE TEMP TABLE xyz(x); }
54execsql {
55 CREATE VIRTUAL TABLE temp.uuu USING unionvtab(
56 "VALUES(NULL, 't1', 1, 9), ('main', 't2', 10, 19), ('aux', 't3', 20, 29)"
57 );
58}
59do_faultsim_test 1.2 -faults oom* -prep {
60} -body {
61 execsql { SELECT * FROM uuu }
62} -test {
63 faultsim_test_result {0 {1 one 2 two 3 three 10 ten 11 eleven 12 twelve 20 twenty 21 twenty-one 22 twenty-two}}
64}
65
66
67finish_test
68