Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transaction ID in MySQL Trigger

Tags:

mysql

triggers

Is there a way to retrieve a transaction ID inside a MySQL trigger?

like image 434
Brian Fisher Avatar asked Aug 14 '09 15:08

Brian Fisher


People also ask

Can we use transaction in 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.

Is a trigger a transaction?

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.

How can I see MySQL transactions?

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.

What is global transaction ID MySQL?

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.


1 Answers

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.

like image 178
Eric Avatar answered Nov 04 '22 19:11

Eric