ROLLBACK_PREPARED(7pg18)
๐ 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_xactssystem 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 โจ
PREPARE TRANSACTION(PREPARE_TRANSACTION(7))COMMIT PREPARED(COMMIT_PREPARED(7))
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
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms