mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-04 07:27:23 +01:00
fix(SQLite): SQLite::Connector::open() crashes on db file with non existing directory #2285
This commit is contained in:
parent
3ca26804e2
commit
4b4be21816
@ -176,6 +176,8 @@ void SessionImpl::open(const std::string& connect)
|
||||
rc = sqlite3_open_v2(connectionString().c_str(), &_pDB,
|
||||
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_URI, NULL);
|
||||
if (rc == SQLITE_OK) break;
|
||||
if (!_pDB)
|
||||
throw ConnectionFailedException(std::string(sqlite3_errstr(rc)));
|
||||
if (sw.elapsedSeconds() >= tout)
|
||||
{
|
||||
Utility::throwException(_pDB, rc);
|
||||
|
@ -1376,6 +1376,21 @@ void SQLiteTest::testEmptyDB()
|
||||
}
|
||||
|
||||
|
||||
void SQLiteTest::testNonexistingDB()
|
||||
{
|
||||
try
|
||||
{
|
||||
Session tmp (Poco::Data::SQLite::Connector::KEY, "foo/bar/nonexisting.db", 1);
|
||||
fail("non-existing DB must throw");
|
||||
}
|
||||
catch(ConnectionFailedException& ex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
fail("non-existing DB must throw ConnectionFailedException");
|
||||
}
|
||||
|
||||
|
||||
void SQLiteTest::testCLOB()
|
||||
{
|
||||
std::string lastName("lastname");
|
||||
@ -3506,6 +3521,7 @@ CppUnit::Test* SQLiteTest::suite()
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testIllegalRange);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testSingleSelect);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testEmptyDB);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testNonexistingDB);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testCLOB);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testBLOB);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testTuple10);
|
||||
|
@ -74,6 +74,7 @@ public:
|
||||
void testIllegalRange();
|
||||
void testSingleSelect();
|
||||
void testEmptyDB();
|
||||
void testNonexistingDB();
|
||||
|
||||
void testCLOB();
|
||||
void testBLOB();
|
||||
|
Loading…
x
Reference in New Issue
Block a user