← Back to team overview

maria-developers team mailing list archive

Re: How to check for active transaction?

 

Davi Arnaut <davi@xxxxxxxxxxx> writes:

>>> I have a session variable @@skip_replication. I want to ensure that this
>>> variable is not modified in the middle of a statement or while a transaction
>>> is active.

> Copy and paste fail. I meant THD::in_multi_stmt_transaction_mode. Try
> to avoid using the flag directly, in the 5.5 cycle we cleaned up some
> of this stuff.

Thanks Davi!

I also need to check if one is in the middle of a statement, ie to prevent
this:

CREATE FUNCTION foo (x INT) RETURNS INT BEGIN SET SESSION skip_replication=x; RETURN x; END
UPDATE t1 SET b=foo(0);

It seems to work with this:

  if (thd->locked_tables_mode || thd->in_active_multi_stmt_transaction())
    ...

but I am not sure if this is the correct way?

 - Kristian.


References