ROLLBACK_PREPARED(7pg18)

๐Ÿ“ฆ version 18.6, in opensuse-leap 16.0

๐Ÿ’… 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 ๐Ÿ’–โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from