X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fdb%2Fsqlite3db.cpp;h=86a4f87f3a6e84d0eb8113a87e1d5fd2ac0c0dae;hb=e7848d3900faf539dddfa6c7b3aac13ddc099e15;hp=809fc681946c42200928a6c6472c157e6bb2a679;hpb=d8f51eac91f86a1e00a05a5058a8fa9eb8732464;p=fms.git diff --git a/src/db/sqlite3db.cpp b/src/db/sqlite3db.cpp index 809fc68..86a4f87 100644 --- a/src/db/sqlite3db.cpp +++ b/src/db/sqlite3db.cpp @@ -30,7 +30,7 @@ const bool DB::Close() { if(IsOpen()) { - ZThread::Guard g(m_mutex); + Poco::ScopedLock g(m_mutex); m_lastresult=sqlite3_close(m_db); if(m_lastresult==SQLITE_OK) { @@ -52,7 +52,7 @@ const bool DB::Execute(const std::string &sql) { if(IsOpen()) { - ZThread::Guard g(m_mutex); + Poco::ScopedLock g(m_mutex); m_lastresult=sqlite3_exec(m_db,sql.c_str(),NULL,NULL,NULL); if(m_lastresult==SQLITE_OK) { @@ -73,7 +73,7 @@ const bool DB::ExecuteInsert(const std::string &sql, long &insertid) { if(IsOpen()) { - ZThread::Guard g(m_mutex); + Poco::ScopedLock g(m_mutex); m_lastresult=sqlite3_exec(m_db,sql.c_str(),NULL,NULL,NULL); if(m_lastresult==SQLITE_OK) { @@ -95,7 +95,7 @@ const int DB::GetLastError(std::string &errormessage) { if(IsOpen()) { - ZThread::Guard g(m_mutex); + Poco::ScopedLock g(m_mutex); int errcode=sqlite3_errcode(m_db); const char *errmsg=sqlite3_errmsg(m_db); if(errmsg) @@ -118,19 +118,19 @@ void DB::Initialize() const bool DB::IsOpen() { - ZThread::Guard g(m_mutex); + Poco::ScopedLock g(m_mutex); return m_db ? true : false; } const bool DB::Open(const std::string &filename) { - if(IsOpen()==false) + if(IsOpen()==true) { Close(); } if(IsOpen()==false) { - ZThread::Guard g(m_mutex); + Poco::ScopedLock g(m_mutex); m_lastresult=sqlite3_open(filename.c_str(),&m_db); if(m_lastresult==SQLITE_OK) { @@ -151,7 +151,7 @@ Statement DB::Prepare(const std::string &sql) { if(IsOpen()) { - ZThread::Guard g(m_mutex); + Poco::ScopedLock g(m_mutex); sqlite3_stmt *statement=NULL; m_lastresult=sqlite3_prepare_v2(m_db,sql.c_str(),sql.size(),&statement,NULL); if(m_lastresult==SQLITE_OK) @@ -173,7 +173,7 @@ Recordset DB::Query(const std::string &sql) { if(IsOpen()) { - ZThread::Guard g(m_mutex); + Poco::ScopedLock g(m_mutex); char **rs=NULL; int rows,cols; m_lastresult=sqlite3_get_table(m_db,sql.c_str(),&rs,&rows,&cols,NULL); @@ -197,10 +197,14 @@ const int DB::SetBusyTimeout(const int ms) { if(IsOpen()) { - ZThread::Guard g(m_mutex); + Poco::ScopedLock g(m_mutex); m_lastresult=sqlite3_busy_timeout(m_db,ms); return m_lastresult; } + else + { + return SQLITE_ERROR; + } } } // namespace