#include "../../include/db/sqlite3db.h"\r
\r
+#ifdef QUERY_LOG\r
+#include <Poco/Logger.h>\r
+#include <Poco/PatternFormatter.h>\r
+#include <Poco/FileChannel.h>\r
+#include "../../include/stringfunctions.h"\r
+#endif\r
+\r
#ifdef XMEM\r
#include <xmem.h>\r
#endif\r
{\r
if(IsOpen())\r
{\r
- Poco::ScopedLock<Poco::FastMutex> g(m_mutex);\r
+ sqlite3_stmt *st=0;\r
+ while((st=sqlite3_next_stmt(m_db,0))!=0)\r
+ {\r
+ sqlite3_finalize(st);\r
+ }\r
+\r
m_lastresult=sqlite3_close(m_db);\r
if(m_lastresult==SQLITE_OK)\r
{\r
{\r
if(IsOpen())\r
{\r
- Poco::ScopedLock<Poco::FastMutex> g(m_mutex);\r
m_lastresult=sqlite3_exec(m_db,sql.c_str(),NULL,NULL,NULL);\r
+#ifdef QUERY_LOG\r
+ Poco::Logger::get("querylog").information("Execute : "+sql);\r
+#endif\r
if(m_lastresult==SQLITE_OK)\r
{\r
return true;\r
{\r
if(IsOpen())\r
{\r
- Poco::ScopedLock<Poco::FastMutex> g(m_mutex);\r
m_lastresult=sqlite3_exec(m_db,sql.c_str(),NULL,NULL,NULL);\r
+#ifdef QUERY_LOG\r
+ Poco::Logger::get("querylog").information("Execute Insert : "+sql);\r
+#endif\r
if(m_lastresult==SQLITE_OK)\r
{\r
insertid=sqlite3_last_insert_rowid(m_db);\r
{\r
if(IsOpen())\r
{\r
- Poco::ScopedLock<Poco::FastMutex> g(m_mutex);\r
int errcode=sqlite3_errcode(m_db);\r
const char *errmsg=sqlite3_errmsg(m_db);\r
if(errmsg)\r
\r
const bool DB::IsOpen()\r
{\r
- Poco::ScopedLock<Poco::FastMutex> g(m_mutex);\r
return m_db ? true : false;\r
}\r
\r
}\r
if(IsOpen()==false)\r
{\r
- Poco::ScopedLock<Poco::FastMutex> g(m_mutex);\r
m_lastresult=sqlite3_open(filename.c_str(),&m_db);\r
if(m_lastresult==SQLITE_OK)\r
{\r
{\r
if(IsOpen())\r
{\r
- Poco::ScopedLock<Poco::FastMutex> g(m_mutex);\r
sqlite3_stmt *statement=NULL;\r
m_lastresult=sqlite3_prepare_v2(m_db,sql.c_str(),sql.size(),&statement,NULL);\r
+#ifdef QUERY_LOG\r
+ size_t temp=reinterpret_cast<size_t>(statement);\r
+ std::string tempstr("");\r
+ StringFunctions::Convert(temp,tempstr);\r
+ Poco::Logger::get("querylog").information("Prepare : "+sql+" "+tempstr);\r
+#endif\r
if(m_lastresult==SQLITE_OK)\r
{\r
return Statement(statement);\r
{\r
if(IsOpen())\r
{\r
- Poco::ScopedLock<Poco::FastMutex> g(m_mutex);\r
char **rs=NULL;\r
int rows,cols;\r
m_lastresult=sqlite3_get_table(m_db,sql.c_str(),&rs,&rows,&cols,NULL);\r
+#ifdef QUERY_LOG\r
+ Poco::Logger::get("querylog").information("Query : "+sql);\r
+#endif\r
if(m_lastresult==SQLITE_OK)\r
{\r
return Recordset(rs,rows,cols);\r
{\r
if(IsOpen())\r
{\r
- Poco::ScopedLock<Poco::FastMutex> g(m_mutex);\r
m_lastresult=sqlite3_busy_timeout(m_db,ms);\r
return m_lastresult;\r
}\r