ROLLBACK_PREPARED(7)

💅 ROLLBACK_PREPARED 💅

okay bestie, welcome to the ROLLBACK_PREPARED page — it's part of the PostgreSQL 18.6 docs and it's literally the "jk never mind" button for two-phase commit. let's get into it 🫶


✨ NAME ✨

ROLLBACK_PREPARED — cancel a transaction that was earlier prepared for two-phase commit 🚫💫


✨ SYNOPSIS ✨

ROLLBACK PREPARED transaction_id

✨ DESCRIPTION ✨

So here's the tea: ROLLBACK PREPARED rolls back a transaction that is in prepared state. that's it. that's the whole vibe. it takes that transaction that was all dressed up and ready for two-phase commit and goes "nvm girl, we're not doing this" 💀✨


✨ PARAMETERS ✨

  • transaction_id — the transaction identifier of the transaction that is to be rolled back. like, the name tag of the transaction you're un-inviting to the commit party 🎀

✨ NOTES ✨

okay important stuff, don't skip this part bestie, it's giving rules 😭

  • To roll back a prepared transaction, you must be either the same user that executed the transaction originally, or a superuser. but plot twist — you do not have to be in the same session that executed the transaction. different session, same energy, it's fine 💅
This command cannot be executed inside a transaction block. and the prepared transaction is rolled back immediately. no waiting, no queueing, it's instant fr fr.
  • All currently available prepared transactions are listed in the pg_prepared_xacts system view. that's your guest list, go check it 👑

✨ EXAMPLES ✨

Roll back the transaction identified by the transaction identifier foobar:

ROLLBACK PREPARED 'foobar';

slay. gone. bye felicia 🌸


✨ COMPATIBILITY ✨

ROLLBACK PREPARED is a PostgreSQL extension. it's intended for use by external transaction management systems, some of which are covered by standards (such as X/Open XA), but the SQL side of those systems is not standardized. so like, the vibes are standardized, the SQL is not. iykyk 🦋


✨ SEE ALSO ✨

the whole two-phase commit friend group fr fr 🫶


and that's the page!! this was PostgreSQL 18.6, dated 2026, page ROLLBACK PREPARED(7) — mwah, go forth and un-prepare responsibly bestie 💖✨🎀