mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +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:
@@ -721,7 +721,7 @@ static int unionConnect(
|
|||||||
pStmt = 0;
|
pStmt = 0;
|
||||||
|
|
||||||
/* Capture the not-found callback UDF name */
|
/* Capture the not-found callback UDF name */
|
||||||
if( argc>=5 ){
|
if( rc==SQLITE_OK && argc>=5 ){
|
||||||
pTab->zNotFoundCallback = unionStrdup(&rc, argv[4]);
|
pTab->zNotFoundCallback = unionStrdup(&rc, argv[4]);
|
||||||
unionDequote(pTab->zNotFoundCallback);
|
unionDequote(pTab->zNotFoundCallback);
|
||||||
}
|
}
|
||||||
|
17
manifest
17
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Microoptimization\sin\spcache1.c\smakes\sthe\scode\sslightly\ssmaller\sand\sfaster.
|
C Fix\sa\ssegfault\sin\sswarmvtab\sthat\scould\soccur\sif\sthere\swas\san\serror\sin\sthe\sSQL\nstatement\spassed\sto\sthe\sconstructor.\sAdd\sother\stest\scases.
|
||||||
D 2017-08-05T15:49:03.201
|
D 2017-08-05T16:15:33.260
|
||||||
F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8
|
F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8
|
||||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||||
F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016
|
F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016
|
||||||
@@ -281,7 +281,7 @@ F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52
|
|||||||
F ext/misc/spellfix.c a4723b6aff748a417b5091b68a46443265c40f0d
|
F ext/misc/spellfix.c a4723b6aff748a417b5091b68a46443265c40f0d
|
||||||
F ext/misc/stmt.c 6f16443abb3551e3f5813bb13ba19a30e7032830015b0f92fe0c0453045c0a11
|
F ext/misc/stmt.c 6f16443abb3551e3f5813bb13ba19a30e7032830015b0f92fe0c0453045c0a11
|
||||||
F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512
|
F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512
|
||||||
F ext/misc/unionvtab.c c59e3518f2bd4ea490b12e20afc2fb6837d496fdebaff507e4969ad53c61f738
|
F ext/misc/unionvtab.c 1e0ebc5078e1a916db191bcd88f87e94ea7ba4aa563ee30ff706261cb4b39461
|
||||||
F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95
|
F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95
|
||||||
F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178
|
F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178
|
||||||
F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd
|
F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd
|
||||||
@@ -1231,8 +1231,9 @@ F test/subselect.test 0966aa8e720224dbd6a5e769a3ec2a723e332303
|
|||||||
F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a
|
F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a
|
||||||
F test/subtype1.test 7fe09496352f97053af1437150751be2d0a0cae8
|
F test/subtype1.test 7fe09496352f97053af1437150751be2d0a0cae8
|
||||||
F test/superlock.test ec94f0556b6488d97f71c79f9061ae08d9ab8f12
|
F test/superlock.test ec94f0556b6488d97f71c79f9061ae08d9ab8f12
|
||||||
F test/swarmvtab.test fbb2415797477588337a54e3bc0ff8e1981d325d22b9e75a527438e79d926a6a
|
F test/swarmvtab.test 5e75154e6488b1cca19910e2820786f12eea66c4d4120539f6f064381bef8a54
|
||||||
F test/swarmvtab2.test 038ef9bcad6fd2fb9e395196080cf23e223ddb1219015049a61540c161bc577d
|
F test/swarmvtab2.test 038ef9bcad6fd2fb9e395196080cf23e223ddb1219015049a61540c161bc577d
|
||||||
|
F test/swarmvtabfault.test 73563eefe3073c6fb3bb14475fb4ef5d4f2e3a67a02947ee0ca08980ea3dd7fe
|
||||||
F test/symlink.test c9ebe7330d228249e447038276bfc8a7b22f4849
|
F test/symlink.test c9ebe7330d228249e447038276bfc8a7b22f4849
|
||||||
F test/sync.test 2f84bdbc2b2df1fcb0220575b4b9f8cea94b7529
|
F test/sync.test 2f84bdbc2b2df1fcb0220575b4b9f8cea94b7529
|
||||||
F test/sync2.test 6be8ed007fa063b147773c1982b5bdba97a32badc536bdc6077eff5cf8710ece
|
F test/sync2.test 6be8ed007fa063b147773c1982b5bdba97a32badc536bdc6077eff5cf8710ece
|
||||||
@@ -1642,7 +1643,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 002a9c7baccf3417c56ec7d16755ea32fdd70a654ffc75f2fc4624fd2b688aed
|
P 422cd9f39403feeacd70133c7a147e23572c75d617ac564344f016ae6611162c
|
||||||
R dcb8fc9ec89330fec69c3eee54be505b
|
R dfa04873a550ce06576a091a701d0729
|
||||||
U drh
|
U dan
|
||||||
Z 2eca10fcc0a16cb9db9d08ac69a27abe
|
Z f26bc896b278db4548da6d42aa588fb6
|
||||||
|
@@ -1 +1 @@
|
|||||||
422cd9f39403feeacd70133c7a147e23572c75d617ac564344f016ae6611162c
|
6ce8b7ca62fcf97875395fc1a989179309e0abb48d4465658ef0d871434ea057
|
@@ -130,6 +130,7 @@ for {set i 0} {$i < 40} {incr i} { forcedelete "test.db$i" }
|
|||||||
# 2.1: Database file does not exist.
|
# 2.1: Database file does not exist.
|
||||||
# 2.2: Table does not exist.
|
# 2.2: Table does not exist.
|
||||||
# 2.3: Table schema does not match.
|
# 2.3: Table schema does not match.
|
||||||
|
# 2.4: Syntax error in SELECT statement.
|
||||||
#
|
#
|
||||||
reset_db
|
reset_db
|
||||||
load_static_extension db unionvtab
|
load_static_extension db unionvtab
|
||||||
@@ -184,5 +185,62 @@ do_catchsql_test 2.3 {
|
|||||||
SELECT * FROM s1 WHERE rowid BETWEEN 201 AND 300;
|
SELECT * FROM s1 WHERE rowid BETWEEN 201 AND 300;
|
||||||
} {1 {source table schema mismatch}}
|
} {1 {source table schema mismatch}}
|
||||||
|
|
||||||
|
do_catchsql_test 2.4 {
|
||||||
|
CREATE VIRTUAL TABLE temp.x1 USING swarmvtab('SELECT * FROMdir');
|
||||||
|
} {1 {sql error: near "FROMdir": syntax error}}
|
||||||
|
do_catchsql_test 2.5 {
|
||||||
|
CREATE VIRTUAL TABLE temp.x1 USING swarmvtab('SELECT * FROMdir', 'fetchdb');
|
||||||
|
} {1 {sql error: near "FROMdir": syntax error}}
|
||||||
|
|
||||||
|
for {set i 0} {$i < 40} {incr i} {
|
||||||
|
forcedelete "test.db$i"
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
# Test the outcome of the fetch function throwing an exception.
|
||||||
|
#
|
||||||
|
proc fetch_db {file} {
|
||||||
|
error "fetch_db error!"
|
||||||
|
}
|
||||||
|
|
||||||
|
db func fetch_db fetch_db
|
||||||
|
|
||||||
|
do_catchsql_test 3.1 {
|
||||||
|
CREATE VIRTUAL TABLE temp.xyz USING swarmvtab(
|
||||||
|
'VALUES
|
||||||
|
("test.db1", "t1", 1, 10),
|
||||||
|
("test.db2", "t1", 11, 20)
|
||||||
|
', 'fetch_db_no_such_function'
|
||||||
|
);
|
||||||
|
} {1 {no such function: fetch_db_no_such_function}}
|
||||||
|
|
||||||
|
do_catchsql_test 3.2 {
|
||||||
|
CREATE VIRTUAL TABLE temp.xyz USING swarmvtab(
|
||||||
|
'VALUES
|
||||||
|
("test.db1", "t1", 1, 10),
|
||||||
|
("test.db2", "t1", 11, 20)
|
||||||
|
', 'fetch_db'
|
||||||
|
);
|
||||||
|
} {1 {fetch_db error!}}
|
||||||
|
|
||||||
|
do_execsql_test 3.3.1 {
|
||||||
|
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;
|
||||||
|
CREATE VIRTUAL TABLE temp.xyz USING swarmvtab(
|
||||||
|
'VALUES
|
||||||
|
("test.db1", "t1", 1, 10),
|
||||||
|
("test.db2", "t1", 11, 20)
|
||||||
|
', 'fetch_db'
|
||||||
|
);
|
||||||
|
} {}
|
||||||
|
|
||||||
|
do_catchsql_test 3.3 { SELECT * FROM xyz } {1 {fetch_db error!}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
|
||||||
|
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