diff options
author | Shauren <shauren.trinity@gmail.com> | 2015-08-27 00:54:49 +0200 |
---|---|---|
committer | jackpoz <giacomopoz@gmail.com> | 2015-09-27 17:08:50 +0200 |
commit | 25c03039768fefa79dd75d491997c28e451a09a7 (patch) | |
tree | e6066aa550a2f5564bc235f1696113b133a03b29 /src | |
parent | d2076ef8b09f6a59aaa634cc754b805d637ffc8a (diff) |
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.
(cherry picked from commit 7c75160f590812f0c5d70fd9c68441068e2ded48)
Conflicts:
src/server/database/Database/Implementation/HotfixDatabase.h
src/server/shared/DataStores/DB2StorageLoader.cpp
src/server/shared/DataStores/DB2StorageLoader.h
src/server/shared/DataStores/DB2Store.h
Diffstat (limited to 'src')
5 files changed, 50 insertions, 40 deletions
diff --git a/src/server/database/Database/DatabaseWorkerPool.h b/src/server/database/Database/DatabaseWorkerPool.h index 6a0cf71cca6..32837daf5da 100644 --- a/src/server/database/Database/DatabaseWorkerPool.h +++ b/src/server/database/Database/DatabaseWorkerPool.h @@ -428,10 +428,12 @@ class DatabaseWorkerPool Other */ + typedef typename T::Statements PreparedStatementIndex; + //! Automanaged (internally) pointer to a prepared statement object for usage in upper level code. //! Pointer is deleted in this->DirectExecute(PreparedStatement*), this->Query(PreparedStatement*) or PreparedStatementTask::~PreparedStatementTask. //! This object is not tied to the prepared statement on the MySQL context yet until execution. - PreparedStatement* GetPreparedStatement(uint32 index) + PreparedStatement* GetPreparedStatement(PreparedStatementIndex index) { return new PreparedStatement(index); } diff --git a/src/server/database/Database/Implementation/CharacterDatabase.h b/src/server/database/Database/Implementation/CharacterDatabase.h index a7ab5d00cb3..5ebafe0d0f8 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<SQLOperation*>* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { } - - //- Loads database type specific prepared statements - void DoPrepareStatements() override; -}; - -typedef DatabaseWorkerPool<CharacterDatabaseConnection> CharacterDatabaseWorkerPool; - enum CharacterDatabaseStatements { /* Naming standard for defines: @@ -546,4 +533,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<SQLOperation*>* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { } + + //- Loads database type specific prepared statements + void DoPrepareStatements() override; +}; + +typedef DatabaseWorkerPool<CharacterDatabaseConnection> CharacterDatabaseWorkerPool; + #endif diff --git a/src/server/database/Database/Implementation/LoginDatabase.h b/src/server/database/Database/Implementation/LoginDatabase.h index 7f6cffa520f..79b7a53cb6e 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<SQLOperation*>* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { } - - //- Loads database type specific prepared statements - void DoPrepareStatements() override; -}; - -typedef DatabaseWorkerPool<LoginDatabaseConnection> LoginDatabaseWorkerPool; - enum LoginDatabaseStatements { /* Naming standard for defines: @@ -133,4 +120,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<SQLOperation*>* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { } + + //- Loads database type specific prepared statements + void DoPrepareStatements() override; +}; + +typedef DatabaseWorkerPool<LoginDatabaseConnection> LoginDatabaseWorkerPool; + #endif diff --git a/src/server/database/Database/Implementation/WorldDatabase.h b/src/server/database/Database/Implementation/WorldDatabase.h index 36fd6fbb186..c5475835fbd 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<SQLOperation*>* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { } - - //- Loads database type specific prepared statements - void DoPrepareStatements() override; -}; - -typedef DatabaseWorkerPool<WorldDatabaseConnection> 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<SQLOperation*>* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { } + + //- Loads database type specific prepared statements + void DoPrepareStatements() override; +}; + +typedef DatabaseWorkerPool<WorldDatabaseConnection> WorldDatabaseWorkerPool; + #endif diff --git a/src/server/database/Database/QueryResult.cpp b/src/server/database/Database/QueryResult.cpp index 563e18b5230..6afc949d6a9 100644 --- a/src/server/database/Database/QueryResult.cpp +++ b/src/server/database/Database/QueryResult.cpp @@ -123,6 +123,8 @@ m_length(NULL) if (fetched_length < buffer_length) *((char*)buffer + fetched_length) = '\0'; break; + default: + break; } m_rows[uint32(m_rowPosition) * m_fieldCount + fIndex].SetByteValue( |