workaround for GH #578

This commit is contained in:
Guenter Obiltschnig
2014-12-17 09:20:52 +01:00
parent c85ad9f73d
commit c49a954a8d
5 changed files with 43 additions and 21 deletions

View File

@@ -24,7 +24,11 @@
#include "Poco/String.h"
#include "Poco/Mutex.h"
#include "Poco/Data/DataException.h"
#if defined(POCO_UNBUNDLED)
#include <sqlite3.h>
#else
#include "sqlite3.h"
#endif
#include <cstdlib>
@@ -52,7 +56,7 @@ SessionImpl::SessionImpl(const std::string& fileName, std::size_t loginTimeout):
{
open();
setConnectionTimeout(CONNECTION_TIMEOUT_DEFAULT);
setProperty("handle", static_cast<void*>(_pDB));
setProperty("handle", _pDB);
addFeature("autoCommit",
&SessionImpl::autoCommit,
&SessionImpl::isAutoCommit);
@@ -255,4 +259,14 @@ bool SessionImpl::isAutoCommit(const std::string&)
}
// NOTE: Utility::dbHandle() has been moved here from Utility.cpp
// as a workaround for a failing AnyCast with Clang.
// See <https://github.com/pocoproject/poco/issues/578>
// for a discussion.
sqlite3* Utility::dbHandle(const Session& session)
{
return AnyCast<sqlite3*>(session.getProperty("handle"));
}
} } } // namespace Poco::Data::SQLite

View File

@@ -63,8 +63,6 @@ Poco::Mutex Utility::_mutex;
Utility::Utility()
{
Poco::Mutex::ScopedLock l(_mutex);
if (_types.empty())
{
_types.insert(TypeMap::value_type("", MetaColumn::FDT_STRING));
@@ -135,7 +133,11 @@ MetaColumn::ColumnDataType Utility::getColumnType(sqlite3_stmt* pStmt, std::size
{
poco_assert_dbg (pStmt);
static Utility u;
// Ensure statics are initialized
{
Poco::Mutex::ScopedLock lock(_mutex);
static Utility u;
}
const char* pc = sqlite3_column_decltype(pStmt, (int) pos);
std::string sqliteType = pc ? pc : "";
@@ -314,4 +316,10 @@ void* Utility::eventHookRegister(sqlite3* pDB, RollbackCallbackType callbackFn,
}
// NOTE: Utility::dbHandle() has been moved to SessionImpl.cpp,
// as a workaround for a failing AnyCast with Clang.
// See <https://github.com/pocoproject/poco/issues/578>
// for a discussion.
} } } // namespace Poco::Data::SQLite