patternsqlMinor
Does MySQL support querying for the current running transaction id
Viewed 0 times
thequeryingmysqlrunningfordoescurrenttransactionsupport
Problem
PostgreSQL supports retrieving the current running transaction id using a query like this:
Does MySQL have any such equivalent?
select txid_current();Does MySQL have any such equivalent?
Solution
Starting with MySQL 5.7, you can see the current transactions in the performance schema.
See http://dev.mysql.com/doc/refman/5.7/en/events-transactions-current-table.html
Now, to find out the
See http://dev.mysql.com/doc/refman/5.7/en/threads-table.html
See http://dev.mysql.com/doc/refman/5.7/en/events-transactions-current-table.html
Now, to find out the
THREAD_ID of the current connection, useSELECT THREAD_ID FROM performance_schema.threads
WHERE PROCESSLIST_ID = CONNECTION_ID()See http://dev.mysql.com/doc/refman/5.7/en/threads-table.html
Code Snippets
SELECT THREAD_ID FROM performance_schema.threads
WHERE PROCESSLIST_ID = CONNECTION_ID()Context
StackExchange Database Administrators Q#98954, answer score: 5
Revisions (0)
No revisions yet.