aboutsummaryrefslogtreecommitdiff
path: root/src/sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/Sql.cpp17
-rw-r--r--src/sql/SqlExec.cpp11
-rw-r--r--src/sql/SqlQuery.cpp11
3 files changed, 39 insertions, 0 deletions
diff --git a/src/sql/Sql.cpp b/src/sql/Sql.cpp
index 4e65ddb..0bfbbe6 100644
--- a/src/sql/Sql.cpp
+++ b/src/sql/Sql.cpp
@@ -21,6 +21,23 @@ namespace odhtdb
return SQLITE_OK;
}
+ std::string SqlArg::toString() const
+ {
+ switch(type)
+ {
+ case Type::DATA_VIEW:
+ return std::string((const char*)dataView.data, dataView.size);
+ case Type::INT:
+ return std::to_string(integer);
+ case Type::INT64:
+ return std::to_string(integer64);
+ case Type::UINT64: // TODO: Find a way to use u64 in sqlite
+ return std::to_string(uinteger64);
+ default:
+ return "";
+ }
+ }
+
SqlTransaction::SqlTransaction(sqlite3 *_db) :
db(_db)
{
diff --git a/src/sql/SqlExec.cpp b/src/sql/SqlExec.cpp
index bdb0fbd..52d953f 100644
--- a/src/sql/SqlExec.cpp
+++ b/src/sql/SqlExec.cpp
@@ -1,4 +1,5 @@
#include "../../include/odhtdb/sql/SqlExec.hpp"
+#include "../../include/odhtdb/Log.hpp"
#include <sqlite3.h>
namespace odhtdb
@@ -39,6 +40,16 @@ namespace odhtdb
throw SqlExecException(errMsg);
}
+#ifdef ODHTDB_SQL_DEBUG
+ Log::debug("Executing sql exec: %s; args(%u): ", sqlite3_sql(stmt), args.size());
+ usize i = 0;
+ for(const SqlArg &arg : args)
+ {
+ Log::debug("arg(%u): %s", i, arg.toString().c_str());
+ ++i;
+ }
+#endif
+
int paramIndex = 1;
for(const SqlArg &arg : args)
{
diff --git a/src/sql/SqlQuery.cpp b/src/sql/SqlQuery.cpp
index 6201332..24694db 100644
--- a/src/sql/SqlQuery.cpp
+++ b/src/sql/SqlQuery.cpp
@@ -1,4 +1,5 @@
#include "../../include/odhtdb/sql/SqlQuery.hpp"
+#include "../../include/odhtdb/Log.hpp"
#include <sqlite3.h>
namespace odhtdb
@@ -29,6 +30,16 @@ namespace odhtdb
throw SqlQueryException(errMsg);
}
+#ifdef ODHTDB_SQL_DEBUG
+ Log::debug("Executing sql query: %s; args(%u): ", sql, args.size());
+ usize i = 0;
+ for(const SqlArg &arg : args)
+ {
+ Log::debug("arg(%u): %s", i, arg.toString().c_str());
+ ++i;
+ }
+#endif
+
int paramIndex = 1;
for(const SqlArg &arg : args)
{