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 15set testdir [file dirname $argv0] 16source $testdir/tester.tcl 17set testprefix unionvtabfault 18 19ifcapable !vtab { 20 finish_test 21 return 22} 23 24forcedelete test.db2 25do_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} 35faultsim_save_and_close 36 37do_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 54faultsim_restore_and_reopen 55load_static_extension db unionvtab 56execsql { ATTACH 'test.db2' AS aux; } 57execsql { CREATE TEMP TABLE xyz(x); } 58execsql { 59 CREATE VIRTUAL TABLE temp.uuu USING unionvtab( 60 "VALUES(NULL, 't1', 1, 9), ('main', 't2', 10, 19), ('aux', 't3', 20, 29)" 61 ); 62} 63do_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. 72do_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 83finish_test 84