mco_db_open

This function is deprecated in eXtremeDB version 4.0 and later. It is retained for backward compatibility with in-memory only database applications written for previous versions of the eXtremeDB runtime. For applications using eXtremeDB version 4.0 and later, the recommended database open API is mco_db_open_dev().

Prototype

    MCO_RET mco_db_open(/*IN*/ const char *dbname,
                 /*IN*/ mco_dictionary_h dict,
                 /*IN*/ void *mem,
                 /*IN*/ uint4 total_size,
                 /*IN*/ uint2 page_size);

Arguments

dbname
The name of the database to open. Taken from the declare database dbname DDL statement. Note that the maximum database name length is 16 characters.
dict
A handle to the dictionary that was created by the eXtremeDB schema compiler mcocomp. Normally, this handle is passed in by dbname_get_dictionary().
mem
Heap memory allocated to contain the database.
total_size
The amount of memory, in bytes, pointed to by mem.
page_size
Size of the discrete blocks of mem that will be managed by the page manager.

Description

This function creates the database dbname in the space referenced by mem with an initial size of total_size (the database size can be extended) and with a page size of page_size.

Return Codes

MCO_S_OK
The database was created successfully.
MCO_E_PAGESIZE
Illegal page size.
MCO_E_NOMEM
Not enough memory allocated.
MCO_E_INSTANCE_DUPLICATE
Duplicate database instance.
MCO_ERR_DB_VERS_MISMATCH
eXtremeDB version mismatch.
MCO_ERR_DB_NOMEM
Insufficient memory for database operation.
MCO_ERR_DB_NAMELONG
Database name longer than 16 characters.

Example

    Application snippet:

    const char *dbname = "SimpleDb";

    int main(int argc, char* argv[])
    {
        mco_db_h db;
        MCO_RET rc;
        char *mem = malloc(DBSIZE);

        if ((rc = mco_runtime_start()) != MCO_S_OK)
            exit(-1);

        rc = mco_db_open(dbname, simpledb_get_dictionary(), mem, DBSIZE, (uint2)PAGESIZE);

        ...
    }

Files

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