← Back to team overview

maria-developers team mailing list archive

Re: How to check for active transaction?

 

Hi, Kristian!

On Feb 29, Kristian Nielsen wrote:
> Hi Serg,
> 
> I'm merging MWL#234 into 5.5.
> 
> 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.
> 
> (The reason for this is that it changes whether changes are replicated or not
> - and so changing in the middle of statement or transaction could cause us to
> replicate only half of the event/transaction).
> 
> In my 5.2-based tree, I had this condition, but this seems to no longer work:
> 
>     thd->locked_tables || thd->active_transaction()
> 
> Can you help me find how to do this check in 5.5 code base?

Use thd->server_status & SERVER_STATUS_IN_TRANS

By the way, there's a server variable @@in_transaction, that allows to
check that from SQL, if you need to write tests or something.

Regards,
Sergei


References