Instead of throw exception, return enum value which means not exist when
get schema version in Db::Manager ctor.
And don't throw exception in Db::Statement dtor. it's useless and
uncatchable.
Change-Id: I0f93df10d21d8d0685c3b9a25b0aa5fc4406b0aa
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
stmt.bind(DB_VERSION_STR);
- if (!stmt.step())
- ThrowExc(DbFailed, "schema version row isn't exist!");
-
- return stmt.getInt();
+ return stmt.step() ? stmt.getInt() : SchemaVersion::NOT_EXIST;
}
void Manager::setSchemaVersion(int sv)
Manager(const std::string &dbfile, const std::string &scriptsDir);
virtual ~Manager();
+ Manager(const Manager &) = delete;
+ Manager &operator=(const Manager &) = delete;
+ Manager(Manager &&) = delete;
+ Manager &operator=(Manager &&) = delete;
+
// SCHEMA_INFO. it's public only for testing for now...
int getSchemaVersion();
Statement::~Statement()
{
if (SQLITE_OK != ::sqlite3_finalize(m_stmt))
- ThrowExc(DbFailed, getErrorMessage());
+ ERROR("Failed to sqlite3_finalize: " << getErrorMessage());
}
void Statement::reset()
int Statement::exec()
{
if (::sqlite3_step(m_stmt) != SQLITE_DONE)
- ThrowExc(DbFailed, getErrorMessage());
+ ThrowExc(DbFailed, "exec() failed. query: " << m_query <<
+ " msg: " << getErrorMessage());
// column cannot be 'get' after sqlite done, so make index overflow.
m_columnIndex = m_columnCount + 1;