ROLLBACK_PREPARED(7pg15)

πŸ“¦ version 15.19, in opensuse-leap 16.0

Hiii bestie! πŸ’– You're reading ROLLBACK PREPARED(7), straight outta the PostgreSQL 15.19 Documentation, and this page is lowkey iconic: it's the command that cancels a transaction that was earlier prepared for two-phase commit. Main character energy? In a transaction log? Yes. 🫢

πŸ’… NAME πŸ’…

ROLLBACK_PREPARED β€” the page for ROLLBACK PREPARED, and its whole deal is: cancel a transaction that was earlier prepared for two-phase commit. It's the undo button for the two-phase commit girlies, and yes, it ate. ✨

🌸 SYNOPSIS 🌸

ROLLBACK PREPARED transaction_id

That's the whole vibe: command, then the transaction_id you want gone.

πŸ¦‹ DESCRIPTION πŸ¦‹

ROLLBACK PREPARED rolls back a transaction that is in prepared state. That's it, that's the tweet β€” except it's a whole PostgreSQL statement, so bestie, respect the tiny syntax. πŸ’…

πŸŽ€ PARAMETERS πŸŽ€

  • transaction_id β€” the transaction identifier of the transaction that is to be rolled back. Ngl, it's literally the handle for the transaction you're sending back to the group chat as "not it." 😭

πŸ”₯ NOTES πŸ”₯

  • To roll back a prepared transaction, you must be either the same user that executed the transaction originally, or a superuser. No random bestie access!
  • But you do not have to be in the same session that executed the transaction. Bestie can be in a whole different session and still handle it. 🫢
  • All currently available prepared transactions are listed in the pg_prepared_xacts system view. That's your guest list, iykyk. πŸ‘‘
⚠️ This command cannot be executed inside a transaction block. The prepared transaction is rolled back immediately. "Cannot" is doing a lot of heavy lifting here β€” do not try to tuck it inside a transaction block, fr fr. πŸ’€

⭐ EXAMPLES ⭐

Roll back the transaction identified by the transaction identifier foobar β€” yes, foobar, the most iconic test string of all time:

ROLLBACK PREPARED 'foobar';

🌈 COMPATIBILITY 🌈

ROLLBACK PREPARED is a PostgreSQL extension. It is intended for use by external transaction management systems β€” some of those are covered by standards (such as X/Open XA), but the SQL side of those systems is not standardized. So like, standards-adjacent, not standards-committed. πŸ™ˆ

🧚 SEE ALSO 🧚

xoxo, PostgreSQL 15.19 β€’ 2026 β€’ ROLLBACK PREPARED(7) πŸ’–

πŸ“¦ where this page comes from