mco_trans_is_active

Check whether a database transaction is currently active.

Prototype

    MCO_RET mco_trans_is_active(
        /*IN*/  mco_trans_h t,
        /*OUT*/ mco_bool *active
    );

Arguments

t
Transaction handle to check.
active
Pointer to a variable that will receive the transaction state:
  • MCO_YES — the transaction is active,
  • MCO_NO — the transaction is not active (committed, rolled back, or invalid).

Description

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_OK on success, even if the transaction is not active — the actual state is returned via the active parameter.

Return Codes

MCO_S_OK
Transaction state successfully retrieved.
MCO_E_INVALID_HANDLE
The provided transaction handle is invalid or null.

Example

    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);
    }

Files

Header file:
mco.h
Source file:
mcoabst.c
Library:
libmcolib.a