prepare_transaction.7
来自「PostgreSQL 8.2中增加了很多企业用户所需要的功能和性能上的提高,其开」· 7 代码 · 共 90 行
7
90 行
.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $.TH "PREPARE TRANSACTION" "" "2008-01-03" "SQL - Language Statements" "SQL Commands".SH NAMEPREPARE TRANSACTION \- prepare the current transaction for two-phase commit.SH SYNOPSIS.sp.nfPREPARE TRANSACTION \fItransaction_id\fR.sp.fi.SH "DESCRIPTION".PP\fBPREPARE TRANSACTION\fR prepares the current transactionfor two-phase commit. After this command, the transaction is no longer associated with the current session; instead, its state is fully stored ondisk, and there is a very high probability that it can be committedsuccessfully, even if a database crash occurs before the commit isrequested..PPOnce prepared, a transaction can later be committed or rolled backwith COMMIT PREPARED [\fBcommit_prepared\fR(7)]or ROLLBACK PREPARED [\fBrollback_prepared\fR(7)],respectively. Those commands can be issued from any session, notonly the one that executed the original transaction..PPFrom the point of view of the issuing session, \fBPREPARETRANSACTION\fR is not unlike a \fBROLLBACK\fR command:after executing it, there is no active current transaction, and theeffects of the prepared transaction are no longer visible. (The effectswill become visible again if the transaction is committed.).PPIf the \fBPREPARE TRANSACTION\fR command fails for anyreason, it becomes a \fBROLLBACK\fR: the current transactionis canceled..SH "PARAMETERS".TP\fB\fItransaction_id\fB\fRAn arbitrary identifier that later identifies this transaction for\fBCOMMIT PREPARED\fR or \fBROLLBACK PREPARED\fR.The identifier must be written as a string literal, and must beless than 200 bytes long. It must not be the same as the identifierused for any currently prepared transaction..SH "NOTES".PPThis command must be used inside a transaction block. Use BEGIN [\fBbegin\fR(7)] to start one..PPIt is not currently allowed to \fBPREPARE\fR a transaction thathas executed any operations involving temporary tables orcreated any cursors WITH HOLD. Those features are too tightlytied to the current session to be useful in a transaction to be prepared..PPIf the transaction modified any run-time parameters with \fBSET\fR,those effects persist after \fBPREPARE TRANSACTION\fR, and will notbe affected by any later \fBCOMMIT PREPARED\fR or \fBROLLBACK PREPARED\fR. Thus, in this one respect\fBPREPARE TRANSACTION\fR acts more like \fBCOMMIT\fR than\fBROLLBACK\fR..PPAll currently available prepared transactions are listed in the\fBpg_prepared_xacts\fRsystem view..PPFrom a performance standpoint, it is unwise to leave transactions inthe prepared state for a long time: this will for instance interfere withthe ability of \fBVACUUM\fR to reclaim storage. Keep in mind alsothat the transaction continues to hold whatever locks it held.The intendedusage of the feature is that a prepared transaction will normally becommitted or rolled back as soon as an external transaction managerhas verified that other databases are also prepared to commit..PPIf you make any serious use of prepared transactions, you will probablywant to increase the value of max_prepared_transactions, as the default setting isquite small (to avoid wasting resources for those who don't use it).It is recommendable to make it at least equal tomax_connections, so that every session can havea prepared transaction pending..SH "EXAMPLES".PPPrepare the current transaction for two-phase commit, usingfoobar as the transaction identifier:.sp.nfPREPARE TRANSACTION 'foobar';.sp.fi.SH "SEE ALSO"COMMIT PREPARED [\fBcommit_prepared\fR(7)], ROLLBACK PREPARED [\fBrollback_prepared\fR(l)]
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?