Debian Codegraph @

test/unionvtabfault.test

raw
1 # 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
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
17 set testprefix unionvtabfault
18
19 ifcapable !vtab {
20 finish_test
21 return
22 }
23
24 forcedelete test.db2
25 do_execsql_test 1.0 {
26 ATTACH 'test.db2' AS aux;
27 CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
28 CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT);
29 CREATE TABLE aux.t3(a INTEGER PRIMARY KEY, b TEXT);
30
31 INSERT INTO t1 VALUES(1, 'one'), (2, 'two'), (3, 'three');
32 INSERT INTO t2 VALUES(10, 'ten'), (11, 'eleven'), (12, 'twelve');
33 INSERT INTO t3 VALUES(20, 'twenty'), (21, 'twenty-one'), (22, 'twenty-two');
34 }
35 faultsim_save_and_close
36
37 do_faultsim_test 1.1 -faults * -prep {
38 faultsim_restore_and_reopen
39 load_static_extension db unionvtab
40 execsql { ATTACH 'test.db2' AS aux; }
41 execsql { CREATE TEMP TABLE xyz(x); }
42 } -body {
43 execsql {
44 CREATE VIRTUAL TABLE temp.uuu USING unionvtab(
45 "VALUES(NULL, 't1', 1, 9), ('main', 't2', 10, 19), ('aux', 't3', 20, 29)"
46 );
47 }
48 } -test {
49 faultsim_test_result {0 {}} \
50 {1 {vtable constructor failed: uuu}} \
51 {1 {sql error: interrupted}}
52 }
53
54 faultsim_restore_and_reopen
55 load_static_extension db unionvtab
56 execsql { ATTACH 'test.db2' AS aux; }
57 execsql { CREATE TEMP TABLE xyz(x); }
58 execsql {
59 CREATE VIRTUAL TABLE temp.uuu USING unionvtab(
60 "VALUES(NULL, 't1', 1, 9), ('main', 't2', 10, 19), ('aux', 't3', 20, 29)"
61 );
62 }
63 do_faultsim_test 1.2 -faults oom* -prep {
64 } -body {
65 execsql { SELECT * FROM uuu }
66 } -test {
67 faultsim_test_result {0 {1 one 2 two 3 three 10 ten 11 eleven 12 twelve 20 twenty 21 twenty-one 22 twenty-two}}
68 }
69
70 #-------------------------------------------------------------------------
71 # Error while registering the two vtab modules.
72 do_faultsim_test 2.0 -faults * -prep {
73 catch { db close }
74 sqlite3 db :memory:
75 } -body {
76 load_static_extension db unionvtab
77 } -test {
78 faultsim_test_result {0 {}} {1 {initialization of unionvtab failed: }}
79 }
80
81
82
83 finish_test