mco_stat_counter_get

Retrieve the current value of a registered runtime statistics counter.

Prototype

    MCO_RET mco_stat_counter_get(
        /*IN*/  mco_stat_hdl counter,
        /*OUT*/ mco_stat_counter_value *ret_value
    );

Arguments

counter
Handle of the statistics counter to query. Valid handles are in the range 0 to MCO_STATRT_TOTAL_COUNTERS - 1 or those returned by mco_statrt_register_counter().
ret_value
Pointer to a variable that will receive the current counter value.

Description

This function returns the current value of the specified runtime statistics counter. Counters track various database metrics such as transaction counts, error rates, timing data, and other performance indicators.

The counter must have been previously registered via mco_statrt_register_counter() (for custom counters) or be one of the built-in counters (e.g., MCO_STATRT_COMMIT_COUNT, MCO_STATRT_MAX_TRANS_TIME).

The value is aggregated across all active database connections. This function does not reset the counter — use mco_stat_get_conn_stats() with the reset flag if you need atomic read-and-clear behavior.

Note: The statistics subsystem must be initialized (i.e., a database with statistics support must be open) before calling this function.

Return Codes

MCO_S_OK
Counter value successfully retrieved.
MCO_E_INVALID_HANDLE
The specified counter handle is out of range or the statistics subsystem is not initialized.

Files

Header file:
mcostatrt.h
Source file:
mcostat.c
Library:
libmcolib.a