mco_trans_commit_phase1

Commit phase 1 of a two-phase transaction.

Prototype

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

Arguments

t
The mco_trans_h transaction handle returned by mco_trans_start().

Description

This function “pre-commits” a transaction, writing the data into the database, updating indexes and checking index restrictions (uniqueness). Control is returned to the application prior to the final commit (see mco_trans_commit_phase2()). Any object handles scoped to the transaction become invalid. However, calling mco_trans_commit_phase1() when the transaction is in an error state will not cause a rollback.

Return Codes

MCO_S_OK
The transaction was committed successfully.
MCO_S_NOTFOUND
Index not found when trying to remove object’s entries from index.
MCO_E_NOMEM
Out of memory, possibly during an attempt to create an index.
MCO_S_DUPLICATE
Duplicate value in a unique index (or duplicate OID).
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_commit_phase1( t );

                ...
            }
        }
        ...
    }

Files

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