maria-developers team mailing list archive
-
maria-developers team
-
Mailing list archive
-
Message #05169
Re: Help with running a transaction inside the server
Hi, Kristian!
On Feb 13, Kristian Nielsen wrote:
> Hi Serg,
>
> Can you give me a tip for doing the following (for MDEV-26, global
> transaction ID):
>
> I need to run a transaction inside the server. This is in the slave
> I/O thread, when it connects to the master it receives the current
> replication position as a GTID, and I want to store it in the
> mysql.rpl_slave_state so that next reconnect of the slave can use the
> GTID automatically.
>
> So I basically need to run the equivalent of something like this:
>
> BEGIN;
> INSERT INTO mysql.rpl_slave_state VALUES (...);
> DELETE FROM mysql.rpl_slave_state WHERE id=...;
You could do all that in a single statement, and you won't need a
multi-statement transaction.
> COMMIT;
>
> I think I already have everything except the "BEGIN" part (if you
> want, you can check the code in rpl_slave_state::record_gtid() in my
> branch lp:~maria-captains/maria/10.0-mdev26/ on Launchpad).
What file is it in? I didn't find it in sql_repl.cc
> So how do I do the equivalent of BEGIN inside the server code? Can you
> think of any existing code I could use as example?
See case SQLCOM_BEGIN in sql_parse.cc. You'll see that all what it does
is one function call: trans_begin()
But see above - I don't understand why would you need an explicit
multi-statement transaction.
Regards,
Sergei
Follow ups
References