Core/Mysql: Multiple changes

- added support for setting NULL column values to MySQL wrapper in core
- replaced nonstandard strdup function and manual memory management with std::string
- fixed bug in MySQLPreparedStatement::getQueryString method, it failed when string parameter contained embedded '?' symbols
- fixed memory leak in MySQLPreparedStatement::setString method
This commit is contained in:
Spp
2013-01-02 12:22:50 +01:00
parent 5280a77fe1
commit ebd14b4f01
12 changed files with 736 additions and 671 deletions

View File

@@ -63,9 +63,6 @@ MySQLConnection::~MySQLConnection()
for (size_t i = 0; i < m_stmts.size(); ++i)
delete m_stmts[i];
for (PreparedStatementMap::const_iterator itr = m_queries.begin(); itr != m_queries.end(); ++itr)
free((void *)m_queries[itr->first].first);
mysql_close(m_Mysql);
}
@@ -150,8 +147,6 @@ bool MySQLConnection::Open()
bool MySQLConnection::PrepareStatements()
{
DoPrepareStatements();
for (PreparedStatementMap::const_iterator itr = m_queries.begin(); itr != m_queries.end(); ++itr)
PrepareStatement(itr->first, itr->second.first, itr->second.second);
return !m_prepareError;
}
@@ -424,6 +419,8 @@ MySQLPreparedStatement* MySQLConnection::GetPreparedStatement(uint32 index)
void MySQLConnection::PrepareStatement(uint32 index, const char* sql, ConnectionFlags flags)
{
m_queries.insert(PreparedStatementMap::value_type(index, std::make_pair(sql, flags)));
// For reconnection case
if (m_reconnecting)
delete m_stmts[index];