|
|
@@ -25,7 +25,7 @@
|
|
|
#include "../../Database/DatabaseEvents.h"
|
|
|
#include "../../IO/Log.h"
|
|
|
|
|
|
-namespace Urho3D
|
|
|
+namespace Atomic
|
|
|
{
|
|
|
|
|
|
DbConnection::DbConnection(Context* context, const String& connectionString) :
|
|
|
@@ -35,7 +35,7 @@ DbConnection::DbConnection(Context* context, const String& connectionString) :
|
|
|
{
|
|
|
if (sqlite3_open(connectionString.CString(), &connectionImpl_) != SQLITE_OK)
|
|
|
{
|
|
|
- URHO3D_LOGERRORF("Could not connect: %s", sqlite3_errmsg(connectionImpl_));
|
|
|
+ ATOMIC_LOGERRORF("Could not connect: %s", sqlite3_errmsg(connectionImpl_));
|
|
|
sqlite3_close(connectionImpl_);
|
|
|
connectionImpl_ = 0;
|
|
|
}
|
|
|
@@ -47,7 +47,7 @@ DbConnection::~DbConnection()
|
|
|
if (sqlite3_close(connectionImpl_) != SQLITE_OK)
|
|
|
{
|
|
|
// This should not happen after finalizing the connection, log error in Release but assert in Debug
|
|
|
- URHO3D_LOGERRORF("Could not disconnect: %s", sqlite3_errmsg(connectionImpl_));
|
|
|
+ ATOMIC_LOGERRORF("Could not disconnect: %s", sqlite3_errmsg(connectionImpl_));
|
|
|
assert(false);
|
|
|
}
|
|
|
connectionImpl_ = 0;
|
|
|
@@ -64,16 +64,20 @@ DbResult DbConnection::Execute(const String& sql, bool useCursorEvent)
|
|
|
const char* zLeftover = 0;
|
|
|
sqlite3_stmt* pStmt = 0;
|
|
|
assert(connectionImpl_);
|
|
|
- int rc = sqlite3_prepare_v2(connectionImpl_, sql.Trimmed().CString(), -1, &pStmt, &zLeftover);
|
|
|
+
|
|
|
+ // 2016-10-09: Prevent string corruption when trimmed is returned.
|
|
|
+ String trimmedSqlStr = sql.Trimmed();
|
|
|
+
|
|
|
+ int rc = sqlite3_prepare_v2(connectionImpl_, trimmedSqlStr.CString(), -1, &pStmt, &zLeftover);
|
|
|
if (rc != SQLITE_OK)
|
|
|
{
|
|
|
- URHO3D_LOGERRORF("Could not execute: %s", sqlite3_errmsg(connectionImpl_));
|
|
|
+ ATOMIC_LOGERRORF("Could not execute: %s", sqlite3_errmsg(connectionImpl_));
|
|
|
assert(!pStmt);
|
|
|
return result;
|
|
|
}
|
|
|
if (*zLeftover)
|
|
|
{
|
|
|
- URHO3D_LOGERROR("Could not execute: only one SQL statement is allowed");
|
|
|
+ ATOMIC_LOGERROR("Could not execute: only one SQL statement is allowed");
|
|
|
sqlite3_finalize(pStmt);
|
|
|
return result;
|
|
|
}
|
|
|
@@ -147,7 +151,7 @@ DbResult DbConnection::Execute(const String& sql, bool useCursorEvent)
|
|
|
}
|
|
|
}
|
|
|
else if (rc != SQLITE_DONE)
|
|
|
- URHO3D_LOGERRORF("Could not execute: %s", sqlite3_errmsg(connectionImpl_));
|
|
|
+ ATOMIC_LOGERRORF("Could not execute: %s", sqlite3_errmsg(connectionImpl_));
|
|
|
if (rc != SQLITE_ROW)
|
|
|
{
|
|
|
sqlite3_finalize(pStmt);
|