mco_trans_set_gc_policy

Set the garbage collection policy for the current connection.

Prototype

    MCO_GC_POLICY mco_trans_set_gc_policy( /*IN*/ mco_db_h db,
                                          /*IN*/ MCO_GC_POLICY new_policy );

Arguments

db
The database handle that was established by mco_db_connect().
new_policy
The policy to be set; it must be one of the following:
  • MCO_GC_DISABLED — garbage collection is disabled.
  • MCO_GC_SELF_VERSIONS — each session performs a cleanup of its own garbage only. This policy can be efficient when each session (connection) works with its own subset of classes (tables).
  • MCO_GC_ON_MODIFICATION — (default) read-write transactions in any session perform garbage collection in all sessions (connections).
  • MCO_GC_ALWAYS — like MCO_GC_ON_MODIFICATION, but READ_ONLY transactions trigger garbage collection as well.

Description

This function sets the garbage collection policy for the given session (connection). It should be called only once when a database session (connection) is created, and before any transactions are started. Furthermore, all sessions (connections) should explicitly set the same policy, unless the default is used (an exception is made for MCO_GC_DISABLED).

The MCO_GC_DISABLED policy is intended to be used to limit garbage collection to dedicated sessions (connections). In this scenario, the worker sessions will have this policy, whereas a dedicated session (or multiple sessions) with policy MCO_GC_ALWAYS will collect garbage in separate threads.

The default policy is MCO_GC_ON_MODIFICATION.

Return Codes

MCO_GC_POLICY
The previous garbage collection policy.

Example

    Application snippet:

    const char * dbname = "SimpleDb";

    int main(int argc, char* argv[])
    {
        mco_db_h db;
        MCO_RET rc;
        mco_device_t       dev;
        mco_db_params_t    db_params;

        ...
        rc = mco_db_open_dev( dbname, simple_get_dictionary(), &dev, 1, &db_params );
        if ( MCO_S_OK != rc )
        {
            rc = mco_db_connect(  dbname, &db );
            ...
            mco_trans_set_gc_policy( db, MCO_GC_SELF_VERSIONS );
            ...
        }
        ...
    }

Files

Header file:
mco.h
Source file:
mursiw.c
Library:
libmcotexcl.a
Header file:
mco.h
Source file:
mursiw.c
Library:
libmcotmursiw.a
Header file:
mco.h
Source file:
mvcc.c
Library:
libmcotmvcc.a
Header file:
mco.h
Source file:
mursiw.c
Library:
libmcotread.a