Skip to content

Commit

Permalink
Merge pull request azerothcore#5 from azerothcore/db-extra
Browse files Browse the repository at this point in the history
feat(Common/Database): correct impl Extra DB
  • Loading branch information
Yehonal authored Jun 29, 2021
2 parents 62cfe5d + 857ba1d commit 61770ea
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
19 changes: 12 additions & 7 deletions modules/mod-as-common/src/game/ExtraDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
#include "MySQLPreparedStatement.h"
#include "DatabaseLoader.h"

class DatabaseLoader;

template class AC_DATABASE_API DatabaseWorkerPool<ExtraDatabaseConnection>;
DatabaseWorkerPool<ExtraDatabaseConnection> ExtraDatabase;

void ExtraDatabaseConnection::DoPrepareStatements()
{
if (!m_reconnecting)
Expand All @@ -36,5 +31,15 @@ void ExtraDatabaseConnection::DoPrepareStatements()
PrepareStatement(EXTRA_DEL_EXTERNAL_MAIL, "DELETE FROM mail_external WHERE id = ?", CONNECTION_ASYNC);
}

// template AC_DATABASE_API
// DatabaseLoader& DatabaseLoader::AddDatabase<ExtraDatabaseConnection>(DatabaseWorkerPool<ExtraDatabaseConnection>&, std::string const&);
ExtraDatabaseConnection::ExtraDatabaseConnection(MySQLConnectionInfo& connInfo) :
MySQLConnection(connInfo) { }

ExtraDatabaseConnection::ExtraDatabaseConnection(ProducerConsumerQueue<SQLOperation*>* q, MySQLConnectionInfo& connInfo) :
MySQLConnection(q, connInfo) { }

ExtraDatabaseConnection::~ExtraDatabaseConnection() { }

DatabaseWorkerPool<ExtraDatabaseConnection> ExtraDatabase;

template AC_DATABASE_API
DatabaseLoader& DatabaseLoader::AddDatabase<ExtraDatabaseConnection>(DatabaseWorkerPool<ExtraDatabaseConnection>&, std::string const&);
22 changes: 14 additions & 8 deletions modules/mod-as-common/src/game/ExtraDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "MySQLConnection.h"
#include "DatabaseEnv.h"

enum ExtraDatabaseStatements
enum ExtraDatabaseStatements : uint32
{
/* Naming standard for defines:
{DB}_{SET/DEL/ADD/REP}_{Summary of data changed}
Expand All @@ -36,18 +36,24 @@ enum ExtraDatabaseStatements

class AC_DATABASE_API ExtraDatabaseConnection : public MySQLConnection
{
public:
typedef ExtraDatabaseStatements Statements;
public:
typedef ExtraDatabaseStatements Statements;

//- Constructors for sync and async connections
ExtraDatabaseConnection(MySQLConnectionInfo& connInfo) : MySQLConnection(connInfo) {}
ExtraDatabaseConnection(ProducerConsumerQueue<SQLOperation*>* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) {}
//- Constructors for sync and async connections
ExtraDatabaseConnection(MySQLConnectionInfo& connInfo);
ExtraDatabaseConnection(ProducerConsumerQueue<SQLOperation*>* q, MySQLConnectionInfo& connInfo);
~ExtraDatabaseConnection();


//- Loads databasetype specific prepared statements
void DoPrepareStatements();
//- Loads databasetype specific prepared statements
void DoPrepareStatements() override;
};

/// Accessor to the extra database
AC_DATABASE_API extern DatabaseWorkerPool<ExtraDatabaseConnection> ExtraDatabase;

using ExtraDatabasePreparedStatement = PreparedStatement<ExtraDatabaseConnection>;
using ExtraDatabaseTransaction = SQLTransaction<ExtraDatabaseConnection>;
using ExtraDatabaseQueryHolder = SQLQueryHolder<ExtraDatabaseConnection>;

#endif

0 comments on commit 61770ea

Please sign in to comment.