COMMIT_PREPARED(7pg18)

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

๐Ÿ’– COMMIT PREPARED(7) ๐Ÿ’–

okay bestie, welcome to the PostgreSQL 18.6 Documentation for COMMIT PREPARED โ€” it's the manual page, she's a whole queen, and she's about to explain how to actually finish a two-phase commit situation. no cap. let's go ๐Ÿซถ


โœจ NAME โœจ

COMMIT_PREPARED โ€” commit a transaction that was earlier prepared for two-phase commit


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

COMMIT PREPARED transaction_id

๐ŸŒธ DESCRIPTION ๐ŸŒธ

so like, COMMIT PREPARED commits a transaction that is in prepared state. that's it. that's the whole vibe. you prepared it earlier, and now you're saying "okay bestie, we're actually doing this" ๐Ÿ’…


๐Ÿฆ‹ PARAMETERS ๐Ÿฆ‹

  • transaction_id โ€” the transaction identifier of the transaction that is to be committed. that's the little name-tag your transaction is wearing. you need it. you can't just be like "commit the thing" and hope for the best ๐Ÿ™ˆ

๐Ÿ’œ NOTES ๐Ÿ’œ

listen up, because this part matters fr fr:

  • To commit 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. so you can slide in from a whole different session and still handle it. main character energy โœจ
  • This command cannot be executed inside a transaction block. nope. not allowed. the prepared transaction is committed immediately โ€” no waiting, no queueing, it just happens โšก
  • All currently available prepared transactions are listed in the pg_prepared_xacts system view. that's your guest list, bestie โ€” go check who's still waiting to be committed ๐Ÿ‘‘

๐ŸŒˆ EXAMPLES ๐ŸŒˆ

Commit the transaction identified by the transaction identifier foobar:

COMMIT PREPARED 'foobar';

look at her go. iconic. ๐ŸŽ€


โญ COMPATIBILITY โญ

COMMIT 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โ€ฆ don't go expecting other databases to understand this. she's built different and she's proud of it ๐Ÿ’…


๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘


๐Ÿ’€ quick reminder bestie: the "must be the same user or a superuser" rule is not a suggestion. it's the law. respect it.

and that's the page!! this whole thing came from PostgreSQL 18.6, dated 2026 โ€” thanks for reading, ily, go commit responsibly ๐Ÿซถโœจ

๐Ÿ“ฆ where this page comes from