-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Poco::Data:;Transaction changes commit mode of a mysql session ,but when commit or rollback, the commit mode does't restore. so if we use Transaction with SessionPool, this design is bad...........
File: poco-1.7.9-all\Data\MySQL\src\SessionHandle.cpp
void SessionHandle::startTransaction()
{
//here changes the commit mode
int rc = mysql_autocommit(_pHandle, false);
if (rc != 0)
{
// retry if connection lost
int err = mysql_errno(_pHandle);
if (err == 2006 /* CR_SERVER_GONE_ERROR / || err == 2013 / CR_SERVER_LOST */)
{
rc = mysql_autocommit(_pHandle, false);
}
}
if (rc != 0) throw TransactionException("Start transaction failed.", _pHandle);
}
void SessionHandle::commit()
{
//should restore the commit mode
if (mysql_commit(_pHandle) != 0)
{
throw TransactionException("Commit failed.", _pHandle);
}
}
void SessionHandle::rollback()
{
//should restore the commit mode
if (mysql_rollback(_pHandle) != 0)
{
throw TransactionException("Rollback failed.", _pHandle);
}
}