0

While running MySQL queries with the intention to be inside a transaction control, I often forget to issue the statement - START TRANSACTION; and keep on creating multiple SAVEPOINT only in the end when I try to return to a particular SAVEPOINT I realize that I have not started the transaction in the first place. In this way I wasted last 1 hour.

So, while supposedly doing transactions and creating savepoints is it possoble to check whether I have started transaction or not?

Payel Senapati
  • 1,134
  • 1
  • 11
  • 27
  • Does this answer your question? https://stackoverflow.com/questions/26620966/getting-the-current-transaction-id-with-mysql – Bill Karwin Dec 17 '21 at 02:35
  • The answer by VladMihalcea return empty set and the answer by EliotChance is impractical as just to find whether I have started transaction or not, I have to create a function. @BillKarwin – Payel Senapati Dec 17 '21 at 02:50
  • 1
    Well, those are the options as I know them. There isn't another way in MySQL to check if you have an active transaction. – Bill Karwin Dec 17 '21 at 03:54

0 Answers0