mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-01 06:27:03 +03:00
Fix a segfault in swarmvtab that could occur if there was an error in the SQL
statement passed to the constructor. Add other test cases. FossilOrigin-Name: 6ce8b7ca62fcf97875395fc1a989179309e0abb48d4465658ef0d871434ea057
This commit is contained in:
61
test/swarmvtabfault.test
Normal file
61
test/swarmvtabfault.test
Normal file
@ -0,0 +1,61 @@
|
||||
# 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 error handling in the swarmvtab extension.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix swarmvtabfault
|
||||
|
||||
ifcapable !vtab {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
proc fetch_db {file} {
|
||||
forcedelete $file
|
||||
sqlite3 dbX $file
|
||||
dbX eval { CREATE TABLE t1(a INTEGER PRIMARY KEY, b) }
|
||||
dbX close
|
||||
}
|
||||
|
||||
forcedelete test.db1
|
||||
do_execsql_test 1.0 {
|
||||
ATTACH 'test.db1' AS aux;
|
||||
CREATE TABLE aux.t1(a INTEGER PRIMARY KEY, b);
|
||||
INSERT INTO aux.t1 VALUES(1, NULL);
|
||||
INSERT INTO aux.t1 VALUES(2, NULL);
|
||||
INSERT INTO aux.t1 VALUES(9, NULL);
|
||||
DETACH aux;
|
||||
} {}
|
||||
|
||||
faultsim_save_and_close
|
||||
do_faultsim_test 1.1 -faults oom* -prep {
|
||||
faultsim_restore_and_reopen
|
||||
db func fetch_db fetch_db
|
||||
load_static_extension db unionvtab
|
||||
db eval {
|
||||
CREATE VIRTUAL TABLE temp.xyz USING swarmvtab(
|
||||
'VALUES
|
||||
("test.db1", "t1", 1, 10),
|
||||
("test.db2", "t1", 11, 20)
|
||||
', 'fetch_db'
|
||||
);
|
||||
}
|
||||
} -body {
|
||||
execsql { SELECT a FROM xyz }
|
||||
} -test {
|
||||
faultsim_test_result {0 {1 2 9}} {1 {sql error: out of memory}}
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user