Check whether a database transaction is currently active.
MCO_RET mco_trans_is_active(
/*IN*/ mco_trans_h t,
/*OUT*/ mco_bool *active
);
t
active
MCO_YES — the transaction is active,MCO_NO — the transaction is not active (committed, rolled back, or invalid).This function checks whether the specified transaction is currently active (i.e., it has been started but not yet committed or rolled back).
It is useful for debugging, logging, or conditional logic that depends on the transaction state. Note that an active transaction may still be in an error state (e.g., interrupted); this function only reports whether the transaction context exists and has not been finalized.
The function returns
MCO_S_OKon success, even if the transaction is not active — the actual state is returned via theactiveparameter.
MCO_S_OK
MCO_E_INVALID_HANDLE
mco_trans_h t;
mco_bool is_active;
MCO_RET rc;
...
rc = mco_trans_start(db, MCO_READ_WRITE, MCO_TRANS_FOREGROUND, &t);
if (rc == MCO_S_OK) {
...
rc = mco_trans_is_active(t, &is_active);
if (rc == MCO_S_OK && is_active == MCO_YES) {
printf("Transaction is still active\n");
}
// ... perform operations ...
mco_trans_commit(t);
}