return Optional<String>(s);
}
-void SqlConnection::Connect(const std::string &address, Flag::Type flag)
+void SqlConnection::Connect(const std::string &address,
+ Flag::Type type,
+ Flag::Option flag)
{
- if (m_connection != NULL)
- {
+ if (m_connection != NULL) {
LogPedantic("Already connected.");
return;
}
-
LogPedantic("Connecting to DB: " << address << "...");
// Connect to database
int result;
-
- if (flag & Flag::UseLucene)
- {
+ if (type & Flag::UseLucene) {
result = db_util_open_with_options(
address.c_str(),
&m_connection,
- SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
+ flag,
NULL);
m_usingLucene = true;
LogPedantic("Lucene index enabled");
- }
- else
- {
+ } else {
result = sqlite3_open_v2(
address.c_str(),
&m_connection,
- SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
+ flag,
NULL);
m_usingLucene = false;
LogPedantic("Lucene index disabled");
}
- if (result == SQLITE_OK)
- {
+ if (result == SQLITE_OK) {
LogPedantic("Connected to DB");
- }
- else
- {
+ } else {
LogPedantic("Failed to connect to DB!");
ThrowMsg(Exception::ConnectionBroken, address);
}
SqlConnection::SqlConnection(const std::string &address,
Flag::Type flag,
+ Flag::Option option,
SynchronizationObject *synchronizationObject)
: m_connection(NULL),
m_usingLucene(false),
LogPedantic("Opening database connection to: " << address);
// Connect to DB
- SqlConnection::Connect(address, flag);
+ SqlConnection::Connect(address, flag, option);
if (!m_synchronizationObject)
{
return;
}
+ if (format == NULL)
+ {
+ LogPedantic("Null query!");
+ ThrowMsg(Exception::SyntaxError, "Null statement");
+ }
+
char *rawBuffer;
va_list args;