Improve transaction tracking fix
The previous fix can be implemented with less changes to actual code.
This commit is contained in:
parent
6f7f8cae39
commit
8d539d9afb
@ -261,7 +261,7 @@ session_trx_state_t session_get_trx_state(const SESSION* ses);
|
||||
session_trx_state_t session_set_trx_state(SESSION* ses, session_trx_state_t new_state);
|
||||
|
||||
/**
|
||||
* Tells whether an explicit transaction is active.
|
||||
* Tells whether a transaction is active.
|
||||
*
|
||||
* @see session_get_trx_state
|
||||
*
|
||||
@ -272,7 +272,7 @@ session_trx_state_t session_set_trx_state(SESSION* ses, session_trx_state_t new_
|
||||
*/
|
||||
static inline bool session_trx_is_active(const SESSION* ses)
|
||||
{
|
||||
return ses->trx_state & SESSION_TRX_ACTIVE_BIT;
|
||||
return !session_is_autocommit(ses) || (ses->trx_state & SESSION_TRX_ACTIVE_BIT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1450,10 +1450,8 @@ static int route_by_statement(SESSION* session, uint64_t capabilities, GWBUF** p
|
||||
{
|
||||
if (type & QUERY_TYPE_DISABLE_AUTOCOMMIT)
|
||||
{
|
||||
/** Autocommit is disabled, a transaction will
|
||||
* always be open */
|
||||
session_set_autocommit(session, false);
|
||||
session_set_trx_state(session, SESSION_TRX_ACTIVE);
|
||||
session_set_trx_state(session, SESSION_TRX_INACTIVE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1476,13 +1474,7 @@ static int route_by_statement(SESSION* session, uint64_t capabilities, GWBUF** p
|
||||
}
|
||||
else if ((type & QUERY_TYPE_COMMIT) || (type & QUERY_TYPE_ROLLBACK))
|
||||
{
|
||||
if (session_is_autocommit(session) ||
|
||||
(type & QUERY_TYPE_ENABLE_AUTOCOMMIT))
|
||||
{
|
||||
/** Autocommit is either on or being enabled
|
||||
* and both of these cause an implicit commit */
|
||||
session_set_trx_state(session, SESSION_TRX_INACTIVE);
|
||||
}
|
||||
session_set_trx_state(session, SESSION_TRX_INACTIVE);
|
||||
|
||||
if (type & QUERY_TYPE_ENABLE_AUTOCOMMIT)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user