mco_db_detach_dev_ctx

Reduce database memory by detaching a memory device.

Prototype

    MCO_RET mco_db_detach_dev_ctx(
        /*IN*/ const char *db_name,
        /*IN*/ mco_device_t *dev,
        /*IN*/ const void *context
    );

Arguments

db_name
Name of the open database from which to detach the device.
dev
Pointer to a mco_device_t structure describing the memory device to detach. Only devices with assignment = MCO_MEMORY_ASSIGN_PIPE_BUF are supported.
context
Optional context pointer (e.g., thread-local or session data) used during internal database connection.

Description

This function reduces the available memory of an opened database by detaching a previously added memory device. It is typically used to release unused memory segments when system resources need to be reclaimed.

The function:

Important: Only devices assigned as MCO_MEMORY_ASSIGN_PIPE_BUF can be detached. Attempting to detach other device types will result in MCO_E_UNSUPPORTED.

If the device contains active allocations, the detachment may be deferred until those objects are freed (indicated by return code MCO_S_DEFERRED_DELETE).

Return Codes

MCO_S_OK
Device successfully detached and memory released.
MCO_S_DEFERRED_DELETE
Device detachment has been scheduled but cannot complete immediately (e.g., due to active allocations). The actual cleanup will occur later.
MCO_E_UNSUPPORTED
The device assignment type is not MCO_MEMORY_ASSIGN_PIPE_BUF.
Other error codes
May include connection errors, lock failures, or internal system errors.

Files

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