From 7c75160f590812f0c5d70fd9c68441068e2ded48 Mon Sep 17 00:00:00 2001 From: Shauren Date: Thu, 27 Aug 2015 00:54:49 +0200 Subject: Core/DBLayer: Added compile time validation for prepared statement indexes passed to DatabaseWorkerPool::GetPreparedStatement turning mistakes like the one fixed in 0327927fa61434d432f9749fd9242ae5dce9a5cd into compiler errors. --- .../Database/Implementation/CharacterDatabase.h | 28 ++++++++++++---------- .../Database/Implementation/HotfixDatabase.h | 28 ++++++++++++---------- .../Database/Implementation/LoginDatabase.h | 28 ++++++++++++---------- .../Database/Implementation/WorldDatabase.h | 28 ++++++++++++---------- 4 files changed, 60 insertions(+), 52 deletions(-) (limited to 'src/server/database/Database/Implementation') diff --git a/src/server/database/Database/Implementation/CharacterDatabase.h b/src/server/database/Database/Implementation/CharacterDatabase.h index 5fd73b6c494..2054bfa7ca5 100644 --- a/src/server/database/Database/Implementation/CharacterDatabase.h +++ b/src/server/database/Database/Implementation/CharacterDatabase.h @@ -21,19 +21,6 @@ #include "DatabaseWorkerPool.h" #include "MySQLConnection.h" -class CharacterDatabaseConnection : public MySQLConnection -{ - public: - //- Constructors for sync and async connections - CharacterDatabaseConnection(MySQLConnectionInfo& connInfo) : MySQLConnection(connInfo) { } - CharacterDatabaseConnection(ProducerConsumerQueue* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { } - - //- Loads database type specific prepared statements - void DoPrepareStatements() override; -}; - -typedef DatabaseWorkerPool CharacterDatabaseWorkerPool; - enum CharacterDatabaseStatements { /* Naming standard for defines: @@ -608,4 +595,19 @@ enum CharacterDatabaseStatements MAX_CHARACTERDATABASE_STATEMENTS }; +class CharacterDatabaseConnection : public MySQLConnection +{ +public: + typedef CharacterDatabaseStatements Statements; + + //- Constructors for sync and async connections + CharacterDatabaseConnection(MySQLConnectionInfo& connInfo) : MySQLConnection(connInfo) { } + CharacterDatabaseConnection(ProducerConsumerQueue* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { } + + //- Loads database type specific prepared statements + void DoPrepareStatements() override; +}; + +typedef DatabaseWorkerPool CharacterDatabaseWorkerPool; + #endif diff --git a/src/server/database/Database/Implementation/HotfixDatabase.h b/src/server/database/Database/Implementation/HotfixDatabase.h index 7740c78afc3..abc584a8b20 100644 --- a/src/server/database/Database/Implementation/HotfixDatabase.h +++ b/src/server/database/Database/Implementation/HotfixDatabase.h @@ -21,19 +21,6 @@ #include "DatabaseWorkerPool.h" #include "MySQLConnection.h" -class HotfixDatabaseConnection : public MySQLConnection -{ - public: - //- Constructors for sync and async connections - HotfixDatabaseConnection(MySQLConnectionInfo& connInfo) : MySQLConnection(connInfo) { } - HotfixDatabaseConnection(ProducerConsumerQueue* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { } - - //- Loads database type specific prepared statements - void DoPrepareStatements() override; -}; - -typedef DatabaseWorkerPool HotfixDatabaseWorkerPool; - enum HotfixDatabaseStatements { /* Naming standard for defines: @@ -263,4 +250,19 @@ enum HotfixDatabaseStatements MAX_HOTFIXDATABASE_STATEMENTS }; +class HotfixDatabaseConnection : public MySQLConnection +{ +public: + typedef HotfixDatabaseStatements Statements; + + //- Constructors for sync and async connections + HotfixDatabaseConnection(MySQLConnectionInfo& connInfo) : MySQLConnection(connInfo) { } + HotfixDatabaseConnection(ProducerConsumerQueue* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { } + + //- Loads database type specific prepared statements + void DoPrepareStatements() override; +}; + +typedef DatabaseWorkerPool HotfixDatabaseWorkerPool; + #endif diff --git a/src/server/database/Database/Implementation/LoginDatabase.h b/src/server/database/Database/Implementation/LoginDatabase.h index efef4e6ee36..cd66be205f5 100644 --- a/src/server/database/Database/Implementation/LoginDatabase.h +++ b/src/server/database/Database/Implementation/LoginDatabase.h @@ -21,19 +21,6 @@ #include "DatabaseWorkerPool.h" #include "MySQLConnection.h" -class LoginDatabaseConnection : public MySQLConnection -{ - public: - //- Constructors for sync and async connections - LoginDatabaseConnection(MySQLConnectionInfo& connInfo) : MySQLConnection(connInfo) { } - LoginDatabaseConnection(ProducerConsumerQueue* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { } - - //- Loads database type specific prepared statements - void DoPrepareStatements() override; -}; - -typedef DatabaseWorkerPool LoginDatabaseWorkerPool; - enum LoginDatabaseStatements { /* Naming standard for defines: @@ -149,4 +136,19 @@ enum LoginDatabaseStatements MAX_LOGINDATABASE_STATEMENTS }; +class LoginDatabaseConnection : public MySQLConnection +{ +public: + typedef LoginDatabaseStatements Statements; + + //- Constructors for sync and async connections + LoginDatabaseConnection(MySQLConnectionInfo& connInfo) : MySQLConnection(connInfo) { } + LoginDatabaseConnection(ProducerConsumerQueue* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { } + + //- Loads database type specific prepared statements + void DoPrepareStatements() override; +}; + +typedef DatabaseWorkerPool LoginDatabaseWorkerPool; + #endif diff --git a/src/server/database/Database/Implementation/WorldDatabase.h b/src/server/database/Database/Implementation/WorldDatabase.h index 46a43886d6b..9f41b305d43 100644 --- a/src/server/database/Database/Implementation/WorldDatabase.h +++ b/src/server/database/Database/Implementation/WorldDatabase.h @@ -21,19 +21,6 @@ #include "DatabaseWorkerPool.h" #include "MySQLConnection.h" -class WorldDatabaseConnection : public MySQLConnection -{ - public: - //- Constructors for sync and async connections - WorldDatabaseConnection(MySQLConnectionInfo& connInfo) : MySQLConnection(connInfo) { } - WorldDatabaseConnection(ProducerConsumerQueue* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { } - - //- Loads database type specific prepared statements - void DoPrepareStatements() override; -}; - -typedef DatabaseWorkerPool WorldDatabaseWorkerPool; - enum WorldDatabaseStatements { /* Naming standard for defines: @@ -116,4 +103,19 @@ enum WorldDatabaseStatements MAX_WORLDDATABASE_STATEMENTS }; +class WorldDatabaseConnection : public MySQLConnection +{ +public: + typedef WorldDatabaseStatements Statements; + + //- Constructors for sync and async connections + WorldDatabaseConnection(MySQLConnectionInfo& connInfo) : MySQLConnection(connInfo) { } + WorldDatabaseConnection(ProducerConsumerQueue* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { } + + //- Loads database type specific prepared statements + void DoPrepareStatements() override; +}; + +typedef DatabaseWorkerPool WorldDatabaseWorkerPool; + #endif -- cgit v1.2.3