mirror of
https://github.com/mangosfour/server.git
synced 2025-12-26 16:37:06 +00:00
Various Cleanups (shared/Database/)
This commit is contained in:
parent
9753625fd1
commit
c334cd5ea4
25 changed files with 508 additions and 508 deletions
|
|
@ -29,7 +29,7 @@
|
|||
#define MAX_CONNECTION_POOL_SIZE 16
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
SqlPreparedStatement * SqlConnection::CreateStatement( const std::string& fmt )
|
||||
SqlPreparedStatement* SqlConnection::CreateStatement(const std::string& fmt)
|
||||
{
|
||||
return new SqlPlainPreparedStatement(fmt, *this);
|
||||
}
|
||||
|
|
@ -45,19 +45,19 @@ void SqlConnection::FreePreparedStatements()
|
|||
m_holder.clear();
|
||||
}
|
||||
|
||||
SqlPreparedStatement * SqlConnection::GetStmt( int nIndex )
|
||||
SqlPreparedStatement* SqlConnection::GetStmt(int nIndex)
|
||||
{
|
||||
if(nIndex < 0)
|
||||
if (nIndex < 0)
|
||||
return NULL;
|
||||
|
||||
//resize stmt container
|
||||
if(m_holder.size() <= nIndex)
|
||||
if (m_holder.size() <= nIndex)
|
||||
m_holder.resize(nIndex + 1, NULL);
|
||||
|
||||
SqlPreparedStatement * pStmt = NULL;
|
||||
SqlPreparedStatement* pStmt = NULL;
|
||||
|
||||
//create stmt if needed
|
||||
if(m_holder[nIndex] == NULL)
|
||||
if (m_holder[nIndex] == NULL)
|
||||
{
|
||||
//obtain SQL request string
|
||||
std::string fmt = m_db.GetStmtString(nIndex);
|
||||
|
|
@ -65,7 +65,7 @@ SqlPreparedStatement * SqlConnection::GetStmt( int nIndex )
|
|||
//allocate SQlPreparedStatement object
|
||||
pStmt = CreateStatement(fmt);
|
||||
//prepare statement
|
||||
if(!pStmt->prepare())
|
||||
if (!pStmt->prepare())
|
||||
{
|
||||
MANGOS_ASSERT(false && "Unable to prepare SQL statement");
|
||||
return NULL;
|
||||
|
|
@ -80,13 +80,13 @@ SqlPreparedStatement * SqlConnection::GetStmt( int nIndex )
|
|||
return pStmt;
|
||||
}
|
||||
|
||||
bool SqlConnection::ExecuteStmt(int nIndex, const SqlStmtParameters& id )
|
||||
bool SqlConnection::ExecuteStmt(int nIndex, const SqlStmtParameters& id)
|
||||
{
|
||||
if(nIndex == -1)
|
||||
if (nIndex == -1)
|
||||
return false;
|
||||
|
||||
//get prepared statement object
|
||||
SqlPreparedStatement * pStmt = GetStmt(nIndex);
|
||||
SqlPreparedStatement* pStmt = GetStmt(nIndex);
|
||||
//bind parameters
|
||||
pStmt->bind(id);
|
||||
//execute statement
|
||||
|
|
@ -99,26 +99,26 @@ Database::~Database()
|
|||
StopServer();
|
||||
}
|
||||
|
||||
bool Database::Initialize(const char * infoString, int nConns /*= 1*/)
|
||||
bool Database::Initialize(const char* infoString, int nConns /*= 1*/)
|
||||
{
|
||||
// Enable logging of SQL commands (usually only GM commands)
|
||||
// (See method: PExecuteLog)
|
||||
m_logSQL = sConfig.GetBoolDefault("LogSQL", false);
|
||||
m_logsDir = sConfig.GetStringDefault("LogsDir","");
|
||||
if(!m_logsDir.empty())
|
||||
if (!m_logsDir.empty())
|
||||
{
|
||||
if((m_logsDir.at(m_logsDir.length()-1)!='/') && (m_logsDir.at(m_logsDir.length()-1)!='\\'))
|
||||
if ((m_logsDir.at(m_logsDir.length()-1)!='/') && (m_logsDir.at(m_logsDir.length()-1)!='\\'))
|
||||
m_logsDir.append("/");
|
||||
}
|
||||
|
||||
m_pingIntervallms = sConfig.GetIntDefault ("MaxPingTime", 30) * (MINUTE * 1000);
|
||||
m_pingIntervallms = sConfig.GetIntDefault("MaxPingTime", 30) * (MINUTE * 1000);
|
||||
|
||||
//create DB connections
|
||||
|
||||
//setup connection pool size
|
||||
if(nConns < MIN_CONNECTION_POOL_SIZE)
|
||||
if (nConns < MIN_CONNECTION_POOL_SIZE)
|
||||
m_nQueryConnPoolSize = MIN_CONNECTION_POOL_SIZE;
|
||||
else if(nConns > MAX_CONNECTION_POOL_SIZE)
|
||||
else if (nConns > MAX_CONNECTION_POOL_SIZE)
|
||||
m_nQueryConnPoolSize = MAX_CONNECTION_POOL_SIZE;
|
||||
else
|
||||
m_nQueryConnPoolSize = nConns;
|
||||
|
|
@ -126,8 +126,8 @@ bool Database::Initialize(const char * infoString, int nConns /*= 1*/)
|
|||
//create connection pool for sync requests
|
||||
for (int i = 0; i < m_nQueryConnPoolSize; ++i)
|
||||
{
|
||||
SqlConnection * pConn = CreateConnection();
|
||||
if(!pConn->Initialize(infoString))
|
||||
SqlConnection* pConn = CreateConnection();
|
||||
if (!pConn->Initialize(infoString))
|
||||
{
|
||||
delete pConn;
|
||||
return false;
|
||||
|
|
@ -138,7 +138,7 @@ bool Database::Initialize(const char * infoString, int nConns /*= 1*/)
|
|||
|
||||
//create and initialize connection for async requests
|
||||
m_pAsyncConn = CreateConnection();
|
||||
if(!m_pAsyncConn->Initialize(infoString))
|
||||
if (!m_pAsyncConn->Initialize(infoString))
|
||||
return false;
|
||||
|
||||
m_pResultQueue = new SqlResultQueue;
|
||||
|
|
@ -151,13 +151,13 @@ void Database::StopServer()
|
|||
{
|
||||
HaltDelayThread();
|
||||
/*Delete objects*/
|
||||
if(m_pResultQueue)
|
||||
if (m_pResultQueue)
|
||||
{
|
||||
delete m_pResultQueue;
|
||||
m_pResultQueue = NULL;
|
||||
}
|
||||
|
||||
if(m_pAsyncConn)
|
||||
if (m_pAsyncConn)
|
||||
{
|
||||
delete m_pAsyncConn;
|
||||
m_pAsyncConn = NULL;
|
||||
|
|
@ -170,7 +170,7 @@ void Database::StopServer()
|
|||
|
||||
}
|
||||
|
||||
SqlDelayThread * Database::CreateDelayThread()
|
||||
SqlDelayThread* Database::CreateDelayThread()
|
||||
{
|
||||
assert(m_pAsyncConn);
|
||||
return new SqlDelayThread(this, m_pAsyncConn);
|
||||
|
|
@ -206,13 +206,13 @@ void Database::ThreadEnd()
|
|||
|
||||
void Database::ProcessResultQueue()
|
||||
{
|
||||
if(m_pResultQueue)
|
||||
if (m_pResultQueue)
|
||||
m_pResultQueue->Update();
|
||||
}
|
||||
|
||||
void Database::escape_string(std::string& str)
|
||||
{
|
||||
if(str.empty())
|
||||
if (str.empty())
|
||||
return;
|
||||
|
||||
char* buf = new char[str.size()*2+1];
|
||||
|
|
@ -222,11 +222,11 @@ void Database::escape_string(std::string& str)
|
|||
delete[] buf;
|
||||
}
|
||||
|
||||
SqlConnection * Database::getQueryConnection()
|
||||
SqlConnection* Database::getQueryConnection()
|
||||
{
|
||||
int nCount = 0;
|
||||
|
||||
if(m_nQueryCounter == long(1 << 31))
|
||||
if (m_nQueryCounter == long(1 << 31))
|
||||
m_nQueryCounter = 0;
|
||||
else
|
||||
nCount = ++m_nQueryCounter;
|
||||
|
|
@ -236,7 +236,7 @@ SqlConnection * Database::getQueryConnection()
|
|||
|
||||
void Database::Ping()
|
||||
{
|
||||
const char * sql = "SELECT 1";
|
||||
const char* sql = "SELECT 1";
|
||||
|
||||
{
|
||||
SqlConnection::Lock guard(m_pAsyncConn);
|
||||
|
|
@ -250,7 +250,7 @@ void Database::Ping()
|
|||
}
|
||||
}
|
||||
|
||||
bool Database::PExecuteLog(const char * format,...)
|
||||
bool Database::PExecuteLog(const char* format,...)
|
||||
{
|
||||
if (!format)
|
||||
return false;
|
||||
|
|
@ -258,23 +258,23 @@ bool Database::PExecuteLog(const char * format,...)
|
|||
va_list ap;
|
||||
char szQuery [MAX_QUERY_LEN];
|
||||
va_start(ap, format);
|
||||
int res = vsnprintf( szQuery, MAX_QUERY_LEN, format, ap );
|
||||
int res = vsnprintf(szQuery, MAX_QUERY_LEN, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if(res==-1)
|
||||
if (res==-1)
|
||||
{
|
||||
sLog.outError("SQL Query truncated (and not execute) for format: %s",format);
|
||||
return false;
|
||||
}
|
||||
|
||||
if( m_logSQL )
|
||||
if (m_logSQL)
|
||||
{
|
||||
time_t curr;
|
||||
tm local;
|
||||
time(&curr); // get current time_t value
|
||||
local=*(localtime(&curr)); // dereference and assign
|
||||
char fName[128];
|
||||
sprintf( fName, "%04d-%02d-%02d_logSQL.sql", local.tm_year+1900, local.tm_mon+1, local.tm_mday );
|
||||
sprintf(fName, "%04d-%02d-%02d_logSQL.sql", local.tm_year+1900, local.tm_mon+1, local.tm_mday);
|
||||
|
||||
FILE* log_file;
|
||||
std::string logsDir_fname = m_logsDir+fName;
|
||||
|
|
@ -294,17 +294,17 @@ bool Database::PExecuteLog(const char * format,...)
|
|||
return Execute(szQuery);
|
||||
}
|
||||
|
||||
QueryResult* Database::PQuery(const char *format,...)
|
||||
QueryResult* Database::PQuery(const char* format,...)
|
||||
{
|
||||
if(!format) return NULL;
|
||||
if (!format) return NULL;
|
||||
|
||||
va_list ap;
|
||||
char szQuery [MAX_QUERY_LEN];
|
||||
va_start(ap, format);
|
||||
int res = vsnprintf( szQuery, MAX_QUERY_LEN, format, ap );
|
||||
int res = vsnprintf(szQuery, MAX_QUERY_LEN, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if(res==-1)
|
||||
if (res==-1)
|
||||
{
|
||||
sLog.outError("SQL Query truncated (and not execute) for format: %s",format);
|
||||
return NULL;
|
||||
|
|
@ -313,17 +313,17 @@ QueryResult* Database::PQuery(const char *format,...)
|
|||
return Query(szQuery);
|
||||
}
|
||||
|
||||
QueryNamedResult* Database::PQueryNamed(const char *format,...)
|
||||
QueryNamedResult* Database::PQueryNamed(const char* format,...)
|
||||
{
|
||||
if(!format) return NULL;
|
||||
if (!format) return NULL;
|
||||
|
||||
va_list ap;
|
||||
char szQuery [MAX_QUERY_LEN];
|
||||
va_start(ap, format);
|
||||
int res = vsnprintf( szQuery, MAX_QUERY_LEN, format, ap );
|
||||
int res = vsnprintf(szQuery, MAX_QUERY_LEN, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if(res==-1)
|
||||
if (res==-1)
|
||||
{
|
||||
sLog.outError("SQL Query truncated (and not execute) for format: %s",format);
|
||||
return NULL;
|
||||
|
|
@ -332,13 +332,13 @@ QueryNamedResult* Database::PQueryNamed(const char *format,...)
|
|||
return QueryNamed(szQuery);
|
||||
}
|
||||
|
||||
bool Database::Execute(const char *sql)
|
||||
bool Database::Execute(const char* sql)
|
||||
{
|
||||
if (!m_pAsyncConn)
|
||||
return false;
|
||||
|
||||
SqlTransaction * pTrans = m_TransStorage->get();
|
||||
if(pTrans)
|
||||
SqlTransaction* pTrans = m_TransStorage->get();
|
||||
if (pTrans)
|
||||
{
|
||||
//add SQL request to trans queue
|
||||
pTrans->DelayExecute(new SqlPlainRequest(sql));
|
||||
|
|
@ -346,7 +346,7 @@ bool Database::Execute(const char *sql)
|
|||
else
|
||||
{
|
||||
//if async execution is not available
|
||||
if(!m_bAllowAsyncTransactions)
|
||||
if (!m_bAllowAsyncTransactions)
|
||||
return DirectExecute(sql);
|
||||
|
||||
// Simple sql statement
|
||||
|
|
@ -356,7 +356,7 @@ bool Database::Execute(const char *sql)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Database::PExecute(const char * format,...)
|
||||
bool Database::PExecute(const char* format,...)
|
||||
{
|
||||
if (!format)
|
||||
return false;
|
||||
|
|
@ -364,10 +364,10 @@ bool Database::PExecute(const char * format,...)
|
|||
va_list ap;
|
||||
char szQuery [MAX_QUERY_LEN];
|
||||
va_start(ap, format);
|
||||
int res = vsnprintf( szQuery, MAX_QUERY_LEN, format, ap );
|
||||
int res = vsnprintf(szQuery, MAX_QUERY_LEN, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if(res==-1)
|
||||
if (res==-1)
|
||||
{
|
||||
sLog.outError("SQL Query truncated (and not execute) for format: %s",format);
|
||||
return false;
|
||||
|
|
@ -376,7 +376,7 @@ bool Database::PExecute(const char * format,...)
|
|||
return Execute(szQuery);
|
||||
}
|
||||
|
||||
bool Database::DirectPExecute(const char * format,...)
|
||||
bool Database::DirectPExecute(const char* format,...)
|
||||
{
|
||||
if (!format)
|
||||
return false;
|
||||
|
|
@ -384,10 +384,10 @@ bool Database::DirectPExecute(const char * format,...)
|
|||
va_list ap;
|
||||
char szQuery [MAX_QUERY_LEN];
|
||||
va_start(ap, format);
|
||||
int res = vsnprintf( szQuery, MAX_QUERY_LEN, format, ap );
|
||||
int res = vsnprintf(szQuery, MAX_QUERY_LEN, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if(res==-1)
|
||||
if (res==-1)
|
||||
{
|
||||
sLog.outError("SQL Query truncated (and not execute) for format: %s",format);
|
||||
return false;
|
||||
|
|
@ -413,11 +413,11 @@ bool Database::CommitTransaction()
|
|||
return false;
|
||||
|
||||
//check if we have pending transaction
|
||||
if(!m_TransStorage->get())
|
||||
if (!m_TransStorage->get())
|
||||
return false;
|
||||
|
||||
//if async execution is not available
|
||||
if(!m_bAllowAsyncTransactions)
|
||||
if (!m_bAllowAsyncTransactions)
|
||||
return CommitTransactionDirect();
|
||||
|
||||
//add SqlTransaction to the async queue
|
||||
|
|
@ -431,11 +431,11 @@ bool Database::CommitTransactionDirect()
|
|||
return false;
|
||||
|
||||
//check if we have pending transaction
|
||||
if(!m_TransStorage->get())
|
||||
if (!m_TransStorage->get())
|
||||
return false;
|
||||
|
||||
//directly execute SqlTransaction
|
||||
SqlTransaction * pTrans = m_TransStorage->detach();
|
||||
SqlTransaction* pTrans = m_TransStorage->detach();
|
||||
pTrans->Execute(m_pAsyncConn);
|
||||
delete pTrans;
|
||||
|
||||
|
|
@ -447,7 +447,7 @@ bool Database::RollbackTransaction()
|
|||
if (!m_pAsyncConn)
|
||||
return false;
|
||||
|
||||
if(!m_TransStorage->get())
|
||||
if (!m_TransStorage->get())
|
||||
return false;
|
||||
|
||||
//remove scheduled transaction
|
||||
|
|
@ -456,11 +456,11 @@ bool Database::RollbackTransaction()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Database::CheckRequiredField( char const* table_name, char const* required_name )
|
||||
bool Database::CheckRequiredField(char const* table_name, char const* required_name)
|
||||
{
|
||||
// check required field
|
||||
QueryResult* result = PQuery("SELECT %s FROM %s LIMIT 1",required_name,table_name);
|
||||
if(result)
|
||||
if (result)
|
||||
{
|
||||
delete result;
|
||||
return true;
|
||||
|
|
@ -470,11 +470,11 @@ bool Database::CheckRequiredField( char const* table_name, char const* required_
|
|||
|
||||
// search current required_* field in DB
|
||||
const char* db_name;
|
||||
if(!strcmp(table_name, "db_version"))
|
||||
if (!strcmp(table_name, "db_version"))
|
||||
db_name = "WORLD";
|
||||
else if(!strcmp(table_name, "character_db_version"))
|
||||
else if (!strcmp(table_name, "character_db_version"))
|
||||
db_name = "CHARACTER";
|
||||
else if(!strcmp(table_name, "realmd_db_version"))
|
||||
else if (!strcmp(table_name, "realmd_db_version"))
|
||||
db_name = "REALMD";
|
||||
else
|
||||
db_name = "UNKNOWN";
|
||||
|
|
@ -482,13 +482,13 @@ bool Database::CheckRequiredField( char const* table_name, char const* required_
|
|||
char const* req_sql_update_name = required_name+strlen("required_");
|
||||
|
||||
QueryNamedResult* result2 = PQueryNamed("SELECT * FROM %s LIMIT 1",table_name);
|
||||
if(result2)
|
||||
if (result2)
|
||||
{
|
||||
QueryFieldNames const& namesMap = result2->GetFieldNames();
|
||||
std::string reqName;
|
||||
for(QueryFieldNames::const_iterator itr = namesMap.begin(); itr != namesMap.end(); ++itr)
|
||||
for (QueryFieldNames::const_iterator itr = namesMap.begin(); itr != namesMap.end(); ++itr)
|
||||
{
|
||||
if(itr->substr(0,9)=="required_")
|
||||
if (itr->substr(0,9)=="required_")
|
||||
{
|
||||
reqName = *itr;
|
||||
break;
|
||||
|
|
@ -499,7 +499,7 @@ bool Database::CheckRequiredField( char const* table_name, char const* required_
|
|||
|
||||
std::string cur_sql_update_name = reqName.substr(strlen("required_"),reqName.npos);
|
||||
|
||||
if(!reqName.empty())
|
||||
if (!reqName.empty())
|
||||
{
|
||||
sLog.outErrorDb("The table `%s` in your [%s] database indicates that this database is out of date!",table_name,db_name);
|
||||
sLog.outErrorDb();
|
||||
|
|
@ -520,7 +520,7 @@ bool Database::CheckRequiredField( char const* table_name, char const* required_
|
|||
sLog.outErrorDb("`%s.sql`",req_sql_update_name);
|
||||
sLog.outErrorDb();
|
||||
|
||||
if(!strcmp(db_name, "WORLD"))
|
||||
if (!strcmp(db_name, "WORLD"))
|
||||
sLog.outErrorDb("Post this error to your database provider forum or find a solution there.");
|
||||
else
|
||||
sLog.outErrorDb("Reinstall your [%s] database with the included sql file in the sql folder.",db_name);
|
||||
|
|
@ -535,7 +535,7 @@ bool Database::CheckRequiredField( char const* table_name, char const* required_
|
|||
sLog.outErrorDb("`%s.sql`",req_sql_update_name);
|
||||
sLog.outErrorDb();
|
||||
|
||||
if(!strcmp(db_name, "WORLD"))
|
||||
if (!strcmp(db_name, "WORLD"))
|
||||
sLog.outErrorDb("Post this error to your database provider forum or find a solution there.");
|
||||
else
|
||||
sLog.outErrorDb("Reinstall your [%s] database with the included sql file in the sql folder.",db_name);
|
||||
|
|
@ -544,13 +544,13 @@ bool Database::CheckRequiredField( char const* table_name, char const* required_
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Database::ExecuteStmt( const SqlStatementID& id, SqlStmtParameters * params )
|
||||
bool Database::ExecuteStmt(const SqlStatementID& id, SqlStmtParameters* params)
|
||||
{
|
||||
if (!m_pAsyncConn)
|
||||
return false;
|
||||
|
||||
SqlTransaction * pTrans = m_TransStorage->get();
|
||||
if(pTrans)
|
||||
SqlTransaction* pTrans = m_TransStorage->get();
|
||||
if (pTrans)
|
||||
{
|
||||
//add SQL request to trans queue
|
||||
pTrans->DelayExecute(new SqlPreparedRequest(id.ID(), params));
|
||||
|
|
@ -558,7 +558,7 @@ bool Database::ExecuteStmt( const SqlStatementID& id, SqlStmtParameters * params
|
|||
else
|
||||
{
|
||||
//if async execution is not available
|
||||
if(!m_bAllowAsyncTransactions)
|
||||
if (!m_bAllowAsyncTransactions)
|
||||
return DirectExecuteStmt(id, params);
|
||||
|
||||
// Simple sql statement
|
||||
|
|
@ -568,7 +568,7 @@ bool Database::ExecuteStmt( const SqlStatementID& id, SqlStmtParameters * params
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Database::DirectExecuteStmt( const SqlStatementID& id, SqlStmtParameters * params )
|
||||
bool Database::DirectExecuteStmt(const SqlStatementID& id, SqlStmtParameters* params)
|
||||
{
|
||||
MANGOS_ASSERT(params);
|
||||
std::auto_ptr<SqlStmtParameters> p(params);
|
||||
|
|
@ -577,11 +577,11 @@ bool Database::DirectExecuteStmt( const SqlStatementID& id, SqlStmtParameters *
|
|||
return _guard->ExecuteStmt(id.ID(), *params);
|
||||
}
|
||||
|
||||
SqlStatement Database::CreateStatement(SqlStatementID& index, const char * fmt )
|
||||
SqlStatement Database::CreateStatement(SqlStatementID& index, const char* fmt)
|
||||
{
|
||||
int nId = -1;
|
||||
//check if statement ID is initialized
|
||||
if(!index.initialized())
|
||||
if (!index.initialized())
|
||||
{
|
||||
//convert to lower register
|
||||
std::string szFmt(fmt);
|
||||
|
|
@ -590,7 +590,7 @@ SqlStatement Database::CreateStatement(SqlStatementID& index, const char * fmt )
|
|||
//find existing or add a new record in registry
|
||||
LOCK_GUARD _guard(m_stmtGuard);
|
||||
PreparedStmtRegistry::const_iterator iter = m_stmtRegistry.find(szFmt);
|
||||
if(iter == m_stmtRegistry.end())
|
||||
if (iter == m_stmtRegistry.end())
|
||||
{
|
||||
nId = ++m_iStmtIndex;
|
||||
m_stmtRegistry[szFmt] = nId;
|
||||
|
|
@ -609,13 +609,13 @@ std::string Database::GetStmtString(const int stmtId) const
|
|||
{
|
||||
LOCK_GUARD _guard(m_stmtGuard);
|
||||
|
||||
if(stmtId == -1 || stmtId > m_iStmtIndex)
|
||||
if (stmtId == -1 || stmtId > m_iStmtIndex)
|
||||
return std::string();
|
||||
|
||||
PreparedStmtRegistry::const_iterator iter_last = m_stmtRegistry.end();
|
||||
for(PreparedStmtRegistry::const_iterator iter = m_stmtRegistry.begin(); iter != iter_last; ++iter)
|
||||
for (PreparedStmtRegistry::const_iterator iter = m_stmtRegistry.begin(); iter != iter_last; ++iter)
|
||||
{
|
||||
if(iter->second == stmtId)
|
||||
if (iter->second == stmtId)
|
||||
return iter->first;
|
||||
}
|
||||
|
||||
|
|
@ -628,23 +628,23 @@ Database::TransHelper::~TransHelper()
|
|||
reset();
|
||||
}
|
||||
|
||||
SqlTransaction * Database::TransHelper::init()
|
||||
SqlTransaction* Database::TransHelper::init()
|
||||
{
|
||||
MANGOS_ASSERT(!m_pTrans); //if we will get a nested transaction request - we MUST fix code!!!
|
||||
m_pTrans = new SqlTransaction;
|
||||
return m_pTrans;
|
||||
}
|
||||
|
||||
SqlTransaction * Database::TransHelper::detach()
|
||||
SqlTransaction* Database::TransHelper::detach()
|
||||
{
|
||||
SqlTransaction * pRes = m_pTrans;
|
||||
SqlTransaction* pRes = m_pTrans;
|
||||
m_pTrans = NULL;
|
||||
return pRes;
|
||||
}
|
||||
|
||||
void Database::TransHelper::reset()
|
||||
{
|
||||
if(m_pTrans)
|
||||
if (m_pTrans)
|
||||
{
|
||||
delete m_pTrans;
|
||||
m_pTrans = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue