{"Entry":{"collection":"sql","key":"commit-prepared","name":"COMMIT PREPARED","aliases":["commit-prepared"],"metadata":{"aliases":["commit-prepared"],"changed_in":[],"changes":[{"from":"8.0","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"added","synopsis":null,"to":"8.1"},{"from":"9.1","purpose_changed":false,"renamed":null,"sections":{"added":["compatibility"],"changed":[],"removed":[]},"status":"changed","synopsis":null,"to":"9.2"}],"content_hash":"1f1829544140ae03d91a0419a186cd80c1528bb427d9d4dcbaf5ba0a06223f60","derived_content_hash":"a0502c5aa60691c932be7c94b908fafb55c3a61edda3bf3c42ee9f8bc8993a22","editorial":{},"first_version":"8.1","group":"transaction","imported_at":"2026-09-30T17:43:39.359832+08:00","last_version":"20","name":"COMMIT PREPARED","object":"PREPARED","position":13008,"present_in":["8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"purpose":"commit a transaction that was earlier prepared for two-phase commit","purpose_zh":"","related":["prepare-transaction","rollback-prepared"],"repair_provenance":{"original_source_revision":"wiki-repair-20261023:dcf402884af24125b43151487a6b553fd98b29426cde1fcbc4ee3e927a56c9ee","receipt_sha256":"5afd2b04bf40033573d0f6ac5e21a56ed64122f5132a06580b4896b5f9364ed2","repair":"wiki-repair-20261023"},"slug":"commit-prepared","source_rev":"wiki-repair-20261023:cf41beb98f5bc00faa3f48aaad9b5b8a0ccada6201728a930b4016988b0f4240","synopsis":"COMMIT PREPARED transaction_id","verb":"COMMIT"}},"Definition":{"Collection":"sql","Key":"commit-prepared","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"commit-prepared","SourceRevision":"wiki-repair-20261023:cf41beb98f5bc00faa3f48aaad9b5b8a0ccada6201728a930b4016988b0f4240","Facts":{"anchor":"SQL-COMMIT-PREPARED","description_zh":"提交一个先前为两阶段提交而预备的事务","description_zh_html":"\u003cpre\u003eCOMMIT PREPARED transaction_id\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003eCOMMIT PREPARED\u003c/code\u003e 提交一个处于预备状态的事务。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e参数\u003c/h2\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_id\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      要提交的事务的事务标识符。\n     \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e注解\u003c/h2\u003e\u003cp\u003e\n   要提交预备事务，执行者必须是最初执行该事务的同一用户，或者是超级用户；但不必处在执行该事务的同一会话中。\n  \u003c/p\u003e\u003cp\u003e\n   这个命令不能在事务块内执行。该预备事务会被立即提交。\n  \u003c/p\u003e\u003cp\u003e\n   当前所有处于预备状态的事务都列在\n   \u003ca class=\"link\" href=\"/zh/docs/18/view-pg-prepared-xacts.html\" title=\"53.17. pg_prepared_xacts\"\u003e\u003ccode class=\"structname\"\u003epg_prepared_xacts\u003c/code\u003e\u003c/a\u003e\n   系统视图中。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e\n   提交事务标识符为 \u003ccode class=\"literal\"\u003efoobar\u003c/code\u003e 的事务：\n\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e\nCOMMIT PREPARED 'foobar';\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003eCOMMIT PREPARED\u003c/code\u003e 是\n   \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 扩展。它旨在供外部事务管理系统使用，其中有些系统已被标准覆盖（例如 X/Open XA），但这些系统的 SQL 侧并未标准化。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e另见\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/zh/docs/18/sql-prepare-transaction.html\" title=\"PREPARE TRANSACTION\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE TRANSACTION\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/zh/docs/18/sql-rollback-prepared.html\" title=\"ROLLBACK PREPARED\"\u003e\u003cspan class=\"refentrytitle\"\u003eROLLBACK PREPARED\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","file":"sql-commit-prepared.html","lang":"en","name":"COMMIT PREPARED","purpose":"commit a transaction that was earlier prepared for two-phase commit","purpose_zh":"提交一个先前为两阶段提交而预备的事务","related":["prepare-transaction","rollback-prepared"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCOMMIT PREPARED\u003c/code\u003e commits a transaction that is in prepared state.\u003c/p\u003e","key":"description","title":"Description"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_id\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe transaction identifier of the transaction that is to be committed.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eTo commit a prepared transaction, you must be either the same user that executed the transaction originally, or a superuser. But you do not have to be in the same session that executed the transaction.\u003c/p\u003e\u003cp\u003eThis command cannot be executed inside a transaction block. The prepared transaction is committed immediately.\u003c/p\u003e\u003cp\u003eAll currently available prepared transactions are listed in the \u003ca href=\"/docs/18/view-pg-prepared-xacts.html\" title=\"53.17. pg_prepared_xacts\"\u003e\u003ccode class=\"structname\"\u003epg_prepared_xacts\u003c/code\u003e\u003c/a\u003e system view.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003eCommit the transaction identified by the transaction identifier \u003ccode class=\"literal\"\u003efoobar\u003c/code\u003e:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCOMMIT PREPARED 'foobar';\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCOMMIT PREPARED\u003c/code\u003e is a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extension. It is 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.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/prepare-transaction/?v=18\" title=\"PREPARE TRANSACTION\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE TRANSACTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/rollback-prepared/?v=18\" title=\"ROLLBACK PREPARED\"\u003e\u003cspan class=\"refentrytitle\"\u003eROLLBACK PREPARED\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"COMMIT PREPARED \u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_id\u003c/code\u003e\u003c/em\u003e","synopsis_text":"COMMIT PREPARED transaction_id","translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/sql-commit-prepared.html","sha256":"7810e3b8ce0924e31d4fb1edaeea34558d55514de79afd41cd80d0115a098a36"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"zh_from":"same-version-pgdoc"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"commit-prepared","SourceDatabase":"center","Version":"18","Locale":"en","Title":"COMMIT PREPARED","Summary":"commit a transaction that was earlier prepared for two-phase commit","BodyHTML":"\u003cpre\u003eCOMMIT PREPARED transaction_id\u003c/pre\u003e\u003csection\u003e\u003ch2\u003eDescription\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eCOMMIT PREPARED\u003c/code\u003e commits a transaction that is in prepared state.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eParameters\u003c/h2\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003etransaction_id\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe transaction identifier of the transaction that is to be committed.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eNotes\u003c/h2\u003e\u003cp\u003eTo commit a prepared transaction, you must be either the same user that executed the transaction originally, or a superuser. But you do not have to be in the same session that executed the transaction.\u003c/p\u003e\u003cp\u003eThis command cannot be executed inside a transaction block. The prepared transaction is committed immediately.\u003c/p\u003e\u003cp\u003eAll currently available prepared transactions are listed in the \u003ca href=\"/docs/18/view-pg-prepared-xacts.html\" rel=\"nofollow\"\u003e\u003ccode\u003epg_prepared_xacts\u003c/code\u003e\u003c/a\u003e system view.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eExamples\u003c/h2\u003e\u003cp\u003eCommit the transaction identified by the transaction identifier \u003ccode\u003efoobar\u003c/code\u003e:\u003c/p\u003e\u003cpre\u003eCOMMIT PREPARED \u0026#39;foobar\u0026#39;;\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eCompatibility\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eCOMMIT PREPARED\u003c/code\u003e is a \u003cspan\u003ePostgreSQL\u003c/span\u003e extension. It is 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.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/wiki/sql/prepare-transaction/?v=18\" title=\"PREPARE TRANSACTION\" rel=\"nofollow\"\u003e\u003cspan\u003ePREPARE TRANSACTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/rollback-prepared/?v=18\" title=\"ROLLBACK PREPARED\" rel=\"nofollow\"\u003e\u003cspan\u003eROLLBACK PREPARED\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","SourceRevision":"wiki-repair-20261023:cf41beb98f5bc00faa3f48aaad9b5b8a0ccada6201728a930b4016988b0f4240","ContentHash":"e3a9be63afee4d7ccea81d1bf1b6f5e712145b1d5344437d3605abab38dde075","Payload":{"related":["prepare-transaction","rollback-prepared"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCOMMIT PREPARED\u003c/code\u003e commits a transaction that is in prepared state.\u003c/p\u003e","key":"description","title":"Description"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_id\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe transaction identifier of the transaction that is to be committed.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eTo commit a prepared transaction, you must be either the same user that executed the transaction originally, or a superuser. But you do not have to be in the same session that executed the transaction.\u003c/p\u003e\u003cp\u003eThis command cannot be executed inside a transaction block. The prepared transaction is committed immediately.\u003c/p\u003e\u003cp\u003eAll currently available prepared transactions are listed in the \u003ca href=\"/docs/18/view-pg-prepared-xacts.html\" title=\"53.17. pg_prepared_xacts\"\u003e\u003ccode class=\"structname\"\u003epg_prepared_xacts\u003c/code\u003e\u003c/a\u003e system view.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003eCommit the transaction identified by the transaction identifier \u003ccode class=\"literal\"\u003efoobar\u003c/code\u003e:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCOMMIT PREPARED 'foobar';\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCOMMIT PREPARED\u003c/code\u003e is a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extension. It is 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.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/prepare-transaction/?v=18\" title=\"PREPARE TRANSACTION\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE TRANSACTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/rollback-prepared/?v=18\" title=\"ROLLBACK PREPARED\"\u003e\u003cspan class=\"refentrytitle\"\u003eROLLBACK PREPARED\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","synopsis_html":"COMMIT PREPARED \u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_id\u003c/code\u003e\u003c/em\u003e","synopsis_text":"COMMIT PREPARED transaction_id"}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
