mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-25 16:13:42 +01:00
Merge pull request #4256 from pocoproject/4247-mysql-startTransaction
Implement MySQL::SessionHandle::startTransaction as submitting the SQL statement 'BEGIN'
This commit is contained in:
commit
940c9b48ff
@ -153,14 +153,14 @@ void SessionHandle::close()
|
|||||||
|
|
||||||
void SessionHandle::startTransaction()
|
void SessionHandle::startTransaction()
|
||||||
{
|
{
|
||||||
int rc = mysql_autocommit(_pHandle, false);
|
int rc = mysql_query(_pHandle, "BEGIN");
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
{
|
{
|
||||||
// retry if connection lost
|
// retry if connection lost
|
||||||
int err = mysql_errno(_pHandle);
|
int err = mysql_errno(_pHandle);
|
||||||
if (err == 2006 /* CR_SERVER_GONE_ERROR */ || err == 2013 /* CR_SERVER_LOST */)
|
if (err == 2006 /* CR_SERVER_GONE_ERROR */ || err == 2013 /* CR_SERVER_LOST */)
|
||||||
{
|
{
|
||||||
rc = mysql_autocommit(_pHandle, false);
|
rc = mysql_query(_pHandle, "BEGIN");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rc != 0) throw TransactionException("Start transaction failed.", _pHandle);
|
if (rc != 0) throw TransactionException("Start transaction failed.", _pHandle);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user