Reset connection when a session is returned to the SessionPool

This commit is contained in:
Vojtěch Erben
2018-11-14 15:50:17 +01:00
parent 8d95644bad
commit 6e6ad28a1f
10 changed files with 41 additions and 0 deletions

View File

@@ -65,6 +65,9 @@ public:
void rollback();
/// Rollback transaction
void resetConnection();
/// Reset connection with dababase and clears session state, but without disconnecting
operator MYSQL* ();
private:

View File

@@ -66,6 +66,9 @@ public:
void close();
/// Closes the connection.
void resetConnection();
/// Reset connection with dababase and clears session state, but without disconnecting
bool isConnected() const;
/// Returns true if connected, false otherwise.

View File

@@ -176,4 +176,11 @@ void SessionHandle::rollback()
}
void SessionHandle::resetConnection()
{
if (mysql_reset_connection(_pHandle) != 0)
throw TransactionException("Reset connection failed.", _pHandle);
}
}}} // Poco::Data::MySQL

View File

@@ -257,6 +257,13 @@ bool SessionImpl::hasTransactionIsolation(Poco::UInt32 ti) const
}
void SessionImpl::resetConnection()
{
if (_connected)
_handle.resetConnection();
}
void SessionImpl::close()
{
if (_connected)