Notice
Transaction-related functions are available only in OceanBase Database V2.2.76 and later versions.
OCITransCommit
Purpose : You can call this function to commit transactions that are associated with specified service context.
Function syntax :
sword OCITransCommit (
OCISvcCtx *svchp,
OCIError *errhp,
ub4 flags );
Parameters :
| Parameter | Description |
|---|---|
| svchp(IN) | A context handle. |
| errhp(IN/OUT) | An error handle. |
| flags(IN) | A flag used for one-phase commit optimization in global transactions. The value can be OCI_DEFAULT or OCI_TRANS_TWOPHASE. |
Return value : OCI_SUCCESS is returned if the function call succeeded, or OCI_ERROR is returned if the function call failed.
OCITransRollback
Purpose : You can call this function to roll back the current transaction.
Notice
The current transaction rolled back by this function is defined as the set of statements executed since the last OCITransCommit() call or since the OCISessionBegin() call. If the application is running in object mode, the modified or updated objects in the object cache of this transaction are also rolled back. Do not roll back a global transaction that is not active. Otherwise, an error will be reported.
Function syntax :
sword OCITransRollback (
dvoid *svchp,
OCIError *errhp,
ub4 flags );
Parameters :
| Parameter | Description |
|---|---|
| svchp(IN) | A context handle. |
| errhp(IN/OUT) | An error handle. |
| flags(IN) | A reserved parameter. The value can only be OCI_DEFAULT. |
Return value : OCI_SUCCESS is returned if the function call succeeded, or OCI_ERROR is returned if the function call failed.
OCITransStart
Purpose : You can call this function to start a transaction. This function sets the beginning of a global or serializable transaction. If the flags parameter indicates to start a new transaction, the transaction context associated with the service context handle is initialized in this function.
Function syntax :
sword OCITransStart (
OCISvcCtx *svchp,
OCIError *errhp,
uword timeout,
ub4 flags );
Parameters :
| Parameter | Description |
|---|---|
| svchp (IN/OUT) | A context handle. |
| errhp (IN/OUT) | An error handle. |
| timeout(IN) | The transaction timeout value. This parameter is not supported and is ignored. |
| flags(IN) | The flag of a transaction attribute. The values can be OCI_TRANS_NEW, OCI_TRANS_TIGHT, OCI_TRANS_LOOSE, OCI_TRANS_RESUME, OCI_TRANS_READONLY, and OCI_TRANS_SERIALIZABLE. You can specify multiple values. |
Return value : OCI_SUCCESS is returned if the function call succeeded, or OCI_ERROR is returned if the function call failed.
The following data structures can be extended and added in the OCITransStart() function:
struct OCISvcCtx
{
HANDLE_HEADER;
OraText *username;
OraText *password;
OraText *database;
struct OCIServer *p_server;
struct OCISession *p_session;
struct OCITrans *p_trans;
ub1 in_v8_mode;
sb1 use_stmt_cache;
MYSQL *mysql;
HashMap_t* stmt_cache_map;
};
struct OCITrans {
HANDLE_HEADER;
OraText **trans_name;
ub4 trans_timeout;
XID *trans_id;
};
XID *trans_id is set by using an OCIAttrSet call:
OCIAttrSet((void *)svchp, OCI_HTYPE_SVCCTX, (void *)txnhp2, 0, OCI_ATTR_TRANS, errhp);
gxid.formatID = 1000; /* format id = 1000 */
gxid.gtrid_length = 3; /* gtrid = 123 */
gxid.data[0] = 1; gxid.data[1] = 2; gxid.data[2] = 3;
gxid.bqual_length = 1; /* bqual = 2 */
gxid.data[3] = 2;
OCIAttrSet((void *)txnhp2, OCI_HTYPE_TRANS, (void *)&gxid, sizeof(XID), OCI_ATTR_XID, errhp);
OCITransDetach
Purpose : You can call this function to detach a global transaction.
Function syntax :
sword OCITransDetach (
OCISvcCtx *svchp,
OCIError *errhp,
ub4 flags );
Parameters :
| Parameter | Description |
|---|---|
| svchp (IN/OUT) | A context handle. |
| errhp (IN/OUT) | An error handle. |
| flags(IN) | A reserved parameter. The value can only be OCI_DEFAULT. |
Return value : OCI_SUCCESS is returned if the function call succeeded, or OCI_ERROR is returned if the function call failed.
OCITransPrepare
Purpose : You can call this function to prepare a global transaction for commit.
Notice
This function is valid only for global transactions. The function returns OCI_SUCCESS_WITH_INFO if the transaction has not made any modifications. The error handle indicates that the transaction is read-only. The
flagsparameter has not been used.
Function syntax :
sword OCITransPrepare (
OCISvcCtx *svchp,
OCIError *errhp,
ub4 flags );
Parameters :
| Parameter | Description |
|---|---|
| svchp (IN/OUT) | A context handle. |
| errhp (IN/OUT) | An error handle. |
| flags(IN) | A reserved parameter. The value can only be OCI_DEFAULT. |
Return value : OCI_SUCCESS is returned if the function call succeeded, or OCI_ERROR is returned if the function call failed.
OCITransForget
Purpose : You can call this function to cause the server to forget a heuristically completed global transaction. That is, the server deletes the status of the transaction from the pending transaction table of the system.
Function syntax :
sword OCITransForget (
OCISvcCtx *svchp,
OCIError *errhp,
ub4 flags );
Parameters :
| Parameter | Description |
|---|---|
| svchp (IN/OUT) | A context handle. |
| errhp (IN/OUT) | An error handle. |
| flags(IN) | A reserved parameter. The value can only be OCI_DEFAULT. |
Return value : OCI_SUCCESS is returned if the function call succeeded, or OCI_ERROR is returned if the function call failed.