バージョンごとのドキュメント一覧

47.4. トランザクション制御 #

SPI_commit — 現在のトランザクションをコミットします。
SPI_rollback — 現在のトランザクションを中断します。
SPI_start_transaction — 廃れた関数
<title>Transaction Management</title>

It is not possible to run transaction control commands such as <command>COMMIT</command> and <command>ROLLBACK</command> through SPI functions such as <function>SPI_execute</function>. There are, however, separate interface functions that allow transaction control through SPI. COMMITROLLBACKといったトランザクション制御コマンドをSPI_executeなどのSPI関数を通して実行することはできません。 しかしながら、SPIを通してトランザクション制御ができる別のインタフェース関数があります。

It is not generally safe and sensible to start and end transactions in arbitrary user-defined SQL-callable functions without taking into account the context in which they are called. For example, a transaction boundary in the middle of a function that is part of a complex SQL expression that is part of some SQL command will probably result in obscure internal errors or crashes. The interface functions presented here are primarily intended to be used by procedural language implementations to support transaction management in SQL-level procedures that are invoked by the <command>CALL</command> command, taking the context of the <command>CALL</command> invocation into account. SPI-using procedures implemented in C can implement the same logic, but the details of that are beyond the scope of this documentation. どこで呼び出されるかという文脈を考慮することなく、ユーザ定義された任意のSQL呼び出し可能な関数でトランザクションを開始・終了することは、一般的に安全でも思慮のあることではありません。 例えば、SQLコマンドの一部の複雑なSQL式の一部である関数中のトランザクションブロックは、おそらく不明瞭な内部エラーやクラッシュになります。 ここに示されるインタフェース関数は、CALL起動の文脈を考慮しており、主としてCALLコマンドから起動される手続き言語から使われることを意図しています。 SPIを使ったCで実装されたプロシージャは同じロジックを実装できますが、その詳細は本文書の範囲を超えます。

*********************************************** *********************************************** ***********************************************