diff --git a/src/engine/server/databases/connection.h b/src/engine/server/databases/connection.h index 7824e2848..de58b02cf 100644 --- a/src/engine/server/databases/connection.h +++ b/src/engine/server/databases/connection.h @@ -58,6 +58,8 @@ public: virtual void BindInt(int Idx, int Value) = 0; virtual void BindFloat(int Idx, float Value) = 0; + // Print expanded sql statement + virtual void Print() = 0; // executes the query and returns if a result row exists and selects it // when called multiple times the next row is selected virtual bool Step() = 0; diff --git a/src/engine/server/databases/mysql.h b/src/engine/server/databases/mysql.h index 81416ce87..4e95dd735 100644 --- a/src/engine/server/databases/mysql.h +++ b/src/engine/server/databases/mysql.h @@ -48,6 +48,7 @@ public: virtual void BindInt(int Idx, int Value); virtual void BindFloat(int Idx, float Value); + virtual void Print() {} virtual bool Step(); virtual bool IsNull(int Col) const; diff --git a/src/engine/server/databases/sqlite.cpp b/src/engine/server/databases/sqlite.cpp index aac948983..94b3f57e4 100644 --- a/src/engine/server/databases/sqlite.cpp +++ b/src/engine/server/databases/sqlite.cpp @@ -26,7 +26,6 @@ CSqliteConnection::~CSqliteConnection() m_pDb = nullptr; } - void CSqliteConnection::Print(IConsole *pConsole, const char *Mode) { char aBuf[512]; @@ -36,7 +35,6 @@ void CSqliteConnection::Print(IConsole *pConsole, const char *Mode) pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); } - void CSqliteConnection::ToUnixTimestamp(const char *pTimestamp, char *aBuf, unsigned int BufferSize) { str_format(aBuf, BufferSize, "strftime('%%s', %s)", pTimestamp); @@ -156,6 +154,12 @@ void CSqliteConnection::BindFloat(int Idx, float Value) m_Done = false; } +void CSqliteConnection::Print() +{ + if(m_pStmt != nullptr) + dbg_msg("sql", "SQLite statement: %s", sqlite3_expanded_sql(m_pStmt)); +} + bool CSqliteConnection::Step() { if(m_Done) diff --git a/src/engine/server/databases/sqlite.h b/src/engine/server/databases/sqlite.h index 170288acd..21dbc2d39 100644 --- a/src/engine/server/databases/sqlite.h +++ b/src/engine/server/databases/sqlite.h @@ -35,6 +35,7 @@ public: virtual void BindInt(int Idx, int Value); virtual void BindFloat(int Idx, float Value); + virtual void Print(); virtual bool Step(); virtual bool IsNull(int Col) const; diff --git a/src/game/server/score.cpp b/src/game/server/score.cpp index db6bbb630..845d129a0 100644 --- a/src/game/server/score.cpp +++ b/src/game/server/score.cpp @@ -535,6 +535,7 @@ bool CScore::SaveScoreThread(IDbConnection *pSqlServer, const ISqlData *pGameDat pSqlServer->BindString(3, pData->m_aTimestamp); pSqlServer->BindString(4, g_Config.m_SvSqlServerName); pSqlServer->BindString(5, pData->m_GameUuid); + pSqlServer->Print(); pSqlServer->Step(); pData->m_pResult->m_Done = true; @@ -617,6 +618,7 @@ bool CScore::SaveTeamScoreThread(IDbConnection *pSqlServer, const ISqlData *pGam pSqlServer->BindString(1, pData->m_aTimestamp); pSqlServer->BindString(2, pData->m_GameUuid); pSqlServer->BindBlob(3, Teamrank.m_TeamID.m_aData, sizeof(Teamrank.m_TeamID.m_aData)); + pSqlServer->Print(); pSqlServer->Step(); } } @@ -637,6 +639,7 @@ bool CScore::SaveTeamScoreThread(IDbConnection *pSqlServer, const ISqlData *pGam pSqlServer->BindString(3, pData->m_aTimestamp); pSqlServer->BindBlob(4, GameID.m_aData, sizeof(GameID.m_aData)); pSqlServer->BindString(5, pData->m_GameUuid); + pSqlServer->Print(); pSqlServer->Step(); } } @@ -1324,6 +1327,7 @@ bool CScore::SaveTeamThread(IDbConnection *pSqlServer, const ISqlData *pGameData pSqlServer->BindString(3, Code); pSqlServer->BindString(4, pData->m_Server); pSqlServer->BindString(5, aSaveID); + pSqlServer->Print(); pSqlServer->Step(); if(!Failure) @@ -1498,6 +1502,7 @@ bool CScore::LoadTeamThread(IDbConnection *pSqlServer, const ISqlData *pGameData pSqlServer->PrepareStatement(aBuf); pSqlServer->BindString(1, pData->m_Code); pSqlServer->BindString(2, pData->m_Map); + pSqlServer->Print(); pSqlServer->Step(); pData->m_pResult->m_Status = CScoreSaveResult::LOAD_SUCCESS;