mco_cursor_close

Close the cursor.

Prototype

 
    MCO_RET	mco_cursor_close(	/*IN*/ mco_trans_h t, /*INOUT*/ mco_cursor_h c);
 

Arguments

t

The mco_trans_h transaction handle returned by mco_trans_start()

c

A cursor handle returned from a cursor or index search function

Description

This function allows applications to explicitly close a cursor. High priority transactions (those set with priority MCO_TRANS_HIGH and higher) optimize access to the index (if of type B-Tree) using a technique that we refer to as “smart locking”. Normally, we lock the page with a spinlock before getting access to a page and release the spinlock (unlock) before leaving the page. When smart locking is used, the database runtime does not release the lock while traversing (searching through) the B-Tree until we either reach the end of the result set, or the function mco_cursor_close() is called.

Return Codes

MCO_S_OK Cursor closed successfully

MCO_E_CURSOR_CLOSED

Cursor already closed

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;
        mco_cursor_t c;
        MCO_CURSOR_TYPE ctype;
         
        ...
        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 )
            {
                ...
                A_list_cursor( t, &c);
                ...
                rc = mco_cursor_close( t, &c );

                ...
            }
        }
        ...
    }
     
 

Files

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