ROLLBACK_PREPARED(7pg15)
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_xactssystem 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 π§
PREPARE TRANSACTION(PREPARE_TRANSACTION(7))COMMIT PREPARED(COMMIT_PREPARED(7))
xoxo, PostgreSQL 15.19 β’ 2026 β’ ROLLBACK PREPARED(7) π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms