mco_trans_checkpoint

Checkpoint a transaction.

Prototype

 
    MCO_RET	mco_trans_checkpoint(	/*IN*/ mco_trans_h t );
 

Arguments

t

The mco_trans_h transaction handle returned by mco_trans_start()

Description

This function inserts updated objects into indexes. It behaves differently depending on the transaction manager in use. With the pessimistic transaction manager, MURSIW, updated objects are removed from the indexes and it is not possible to locate them using the old key until the checkpoint (or commit) is called. With the optimistic transaction manager, MVCC, the working copy of the object is created, but the old version is not removed and it is possible to access this copy using the original value of the key (or iterating through the index). After the checkpoint, only the new key can be used to locate the object.

Return Codes

MCO_S_OK The transaction was committed successfully

MCO_E_TRANSACT

The transaction was in an error state

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;
        mco_trans_h t;
         
        ...
        rc = mco_db_open_dev( dbname, simple_get_dictionary(), &dev, 1, &db_params );
        if ( MCO_S_OK != rc )
        {
            rc = mco_db_connect(  dbname, &db );
            ...
            rc = mco_trans_start(db, MCO_READ_ONLY, MCO_TRANS_FOREGROUND, &t);
            if ( MCO_S_OK == rc )
            {
                ...
                rc = mco_trans_checkpoint( t );

                ...
                rc = mco_trans_commit( t );
                ...
            }
        }
        ...
    }
     
 

Files

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