mirror of
https://github.com/sqlite/sqlite.git
synced 2024-11-28 16:09:31 +01:00
6ab91a7a7a
so that they work with DEFENSIVE enabled. FossilOrigin-Name: 3212733cb6d1a59516d67a86df7c7b1d2456a1b2e5d7080c26b0e87b2609c65d
84 lines
2.3 KiB
Plaintext
84 lines
2.3 KiB
Plaintext
# 2017-07-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.
|
|
#
|
|
#***********************************************************************
|
|
# This file implements regression tests for SQLite library. The
|
|
# focus of this file is percentile.c extension
|
|
#
|
|
|
|
set testdir [file dirname $argv0]
|
|
source $testdir/tester.tcl
|
|
set testprefix unionvtabfault
|
|
|
|
ifcapable !vtab {
|
|
finish_test
|
|
return
|
|
}
|
|
|
|
forcedelete test.db2
|
|
do_execsql_test 1.0 {
|
|
ATTACH 'test.db2' AS aux;
|
|
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
|
|
CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT);
|
|
CREATE TABLE aux.t3(a INTEGER PRIMARY KEY, b TEXT);
|
|
|
|
INSERT INTO t1 VALUES(1, 'one'), (2, 'two'), (3, 'three');
|
|
INSERT INTO t2 VALUES(10, 'ten'), (11, 'eleven'), (12, 'twelve');
|
|
INSERT INTO t3 VALUES(20, 'twenty'), (21, 'twenty-one'), (22, 'twenty-two');
|
|
}
|
|
faultsim_save_and_close
|
|
|
|
do_faultsim_test 1.1 -faults * -prep {
|
|
faultsim_restore_and_reopen
|
|
load_static_extension db unionvtab
|
|
execsql { ATTACH 'test.db2' AS aux; }
|
|
execsql { CREATE TEMP TABLE xyz(x); }
|
|
} -body {
|
|
execsql {
|
|
CREATE VIRTUAL TABLE temp.uuu USING unionvtab(
|
|
"VALUES(NULL, 't1', 1, 9), ('main', 't2', 10, 19), ('aux', 't3', 20, 29)"
|
|
);
|
|
}
|
|
} -test {
|
|
faultsim_test_result {0 {}} \
|
|
{1 {vtable constructor failed: uuu}} \
|
|
{1 {sql error: interrupted}}
|
|
}
|
|
|
|
faultsim_restore_and_reopen
|
|
load_static_extension db unionvtab
|
|
execsql { ATTACH 'test.db2' AS aux; }
|
|
execsql { CREATE TEMP TABLE xyz(x); }
|
|
execsql {
|
|
CREATE VIRTUAL TABLE temp.uuu USING unionvtab(
|
|
"VALUES(NULL, 't1', 1, 9), ('main', 't2', 10, 19), ('aux', 't3', 20, 29)"
|
|
);
|
|
}
|
|
do_faultsim_test 1.2 -faults oom* -prep {
|
|
} -body {
|
|
execsql { SELECT * FROM uuu }
|
|
} -test {
|
|
faultsim_test_result {0 {1 one 2 two 3 three 10 ten 11 eleven 12 twelve 20 twenty 21 twenty-one 22 twenty-two}}
|
|
}
|
|
|
|
#-------------------------------------------------------------------------
|
|
# Error while registering the two vtab modules.
|
|
do_faultsim_test 2.0 -faults * -prep {
|
|
catch { db close }
|
|
sqlite3 db :memory:
|
|
} -body {
|
|
load_static_extension db unionvtab
|
|
} -test {
|
|
faultsim_test_result {0 {}} {1 {initialization of unionvtab failed: }}
|
|
}
|
|
|
|
|
|
|
|
finish_test
|