Is there a way to retrieve a transaction ID inside a MySQL trigger?
Triggers are often used to roll back an entire transaction if an error is detected, or they can be used to roll back the effects of a specific data modification: When the trigger contains the rollback transaction command, the rollback aborts the entire batch, and any subsequent statements in the batch are not executed.
Transactions are for grouping actions into one unit of work which either succeeds or fails in its entirety! Triggers are (normally) for performing (procdural/business logic) code when an event (normally an INSERT , UPDATE or DELETE on a particular table) occurs in the database.
You can use show innodb status (or show engine innodb status for newer versions of mysql) to get a list of all the actions currently pending inside the InnoDB engine. Buried in the wall of output will be the transactions, and what internal process ID they're running under.
A global transaction identifier (GTID) is a unique identifier created and associated with each transaction committed on the server of origin (source). This identifier is unique not only to the server on which it originated, but is unique across all servers in a given replication setup.
Currently, no. It's been an open request for four years. However, you can use connection_id()
which will give the connection session, so you can group things by that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With