OpenTP1 Version 7 Programming Reference C Language
tx_rollback - Roll back a global transaction
Format
ANSI C, C++
#include <tx.h> int tx_rollback (void) |
K&R C
#include <tx.h> int tx_rollback() |
Description
The function tx_rollback() is used to roll back the work of the transaction active in the caller's thread of control.
If the transaction_control characteristic (see tx_set_transaction_control()) is TX_UNCHAINED, when tx_rollback() returns, the caller is no longer in transaction mode. However, if the transaction_control characteristic is TX_CHAINED, when tx_rollback() returns, the caller remains in transaction mode on behalf of a new transaction (see the Return value and Errors sections below).
<<The values set by the following functions affect the processing of tx_rollback().>>
Optional set-up
Return value
Upon successful completion, tx_rollback() returns TX_OK, a non-negative return value.
<<If the transaction_control characteristic is TX_CHAINED, a new global transaction begins.>> <<If the SPP which issued tx_rollback() is not root transaction branch, actual rollback processing is not performed, and it is only recorded that the transaction branch is in rollback_only state. The transaction mode is kept until rollback is directed in the synchronization point processing of the root transaction branch.>>
Errors
Under the following conditions, tx_rollback() fails and returns one of these negative values.
Return value | Return value (numeric) | Explanation |
---|---|---|
TX_NO_BEGIN | -100 | The transaction rolled back; however, a new transaction could not be started and the caller is no longer in transaction mode. This return value occurs only when the transaction_control characteristic is TX_CHAINED. |
TX_MIXED | -3 | The transaction was partially committed and partially rolled back. In addition, if the transaction_control characteristic is TX_CHAINED, a new transaction is started. |
TX_MIXED_NO_BEGIN | -103 | The transaction was partially committed and partially rolled back. In addition, a new transaction could not be started and the caller is no longer in transaction mode. This return value can occur only when the transaction_control characteristic is TX_CHAINED. |
TX_HAZARD | -4 | Due to a failure, the transaction may have been partially committed and partially rolled back. In addition, if the transaction_control characteristic is TX_CHAINED, a new transaction is started. |
TX_HAZARD_NO_BEGIN | -104 | Due to a failure, the transaction may have been partially committed and partially rolled back. In addition, a new transaction could not be started and the caller is no longer in transaction mode. This return value can occur only when the transaction_control characteristic is TX_CHAINED. |
TX_COMMITTED | -9 | The transaction was heuristically committed. In addition, if the transaction_control characteristic is TX_CHAINED, a new transaction is started. |
TX_COMMITTED_NO_BEGIN | -109 | The transaction was heuristically committed. In addition, a new transaction could not be started and the caller is no longer in transaction mode. This return value can occur only when the transaction_control characteristic is TX_CHAINED. |
TX_PROTOCOL_ERROR | -5 | The function was called in an improper context (for example, the caller is not in transaction mode). |
TX_FAIL | -7 | Either the transaction manager or one or more of the resource managers encountered a fatal error. The nature of the error is such that the transaction manager and/or one or more of the resource managers can no longer perform work on behalf of the application. The caller's state with respect to the transaction is unknown. |
See also
tx_begin(), tx_set_transaction_control(), tx_set_transaction_timeout()
<<Example>>
<<if (tx_info (NULL) == 1 && tx_rollback() < 0) fputs ("cannot rollback transaction\n", stderr);>> |
<<Note on use with OpenTP1>>
All Rights Reserved. Copyright (C) 2006, 2010, Hitachi, Ltd.