# mco_disk_read_file_open_params

> Retrieve parameters required to open a disk database from the disk database (.dbs) file.

### Prototype

       typedef struct mco_file_open_params
            {
                mco_uint2            mem_page_size;
                mco_uint4            disk_page_size;
                mco_uint4            n_classes;
                mco_uint4            max_classes;
                mco_uint4            max_indexes;
                MCO_LOG_TYPE         db_log_type;
                mco_bool             is_mvcc;
                mco_bool             is_mursiw;
                mco_uint4            dict_used_size;
                mco_bool             dict_compatible;
            } mco_file_open_params_t;

        MCO_RET mco_disk_read_file_open_params(
             /* IN */ const char *db_path,
             /* IN */ const char *log_path /* = NULL*/,
             /* IN */ const mco_dictionary_h check_dict /* == NULL */,
             /* OUT */ mco_file_open_params_t *out_params

        );

### Arguments

db_path | The path to the persistent database storage file (.dbs)
log_path | (Optional) The path to the persistent database log file (.log)
check_dict | (Optional) The database dictionary from schema_name`_get_dictionary()`
check_dict | (Optional) The database dictionary from schema_name`_get_dictionary()`
out_params | Retrieved persistent database parameters

### Description

> The function accepts a database file name (.dbs) and, optionally, the database log file name and the database dictionary generated by the schema_name`_get_dictionary()` function as input parameters.

> It returns the persistent database parameters retrieved from the database storage file. These parameters can be passed to mco_db_open_dev(), and allow opening a persistent database with unknown or lost configuration parameters correctly.

> If the dictionary is provided via the check_dict parameter, the function will also return a “compatibility indicator” — a flag `dict_compatible` indicating whether the dictionary read from the .dbs file matches the one passed to the function. Additionally, it will provide the size of the database dictionary read from the .dbs file (`dict_used_size`).

> If log_path is provided, the log type will be returned in `db_log_type`.

> Limitations

> When the "compatibility indicator” indicates that the database layout (schema) has changed, using the “new” generated API from the new application with the “old” schema read from the file can lead to various errors. In order to use the old database with a more recent application, the old database must first be converted to the new format. This conversion cannot be performed in place; it requires exporting the old database to an external format (e.g., XML or mco_db_save()/mco_db_load()) and then importing it into the new dictionary.

> The persistent database should be created on the same architecture and with the same data alignments as the application trying to open it.

> Multi-file persistent databases (MCO_MEMORY_MULTIFILE, MCO_MEMORY_RAID) are not supported.

### Return Codes

MCO_S_OK | out_params filled in successfully
MCO_E_DISK_OPEN | Error opening file on persistent storage device
MCO_E_DISK_READ | Error reading from persistent storage device
MCO_E_NOMEM | Out of dynamic memory

### Files

Header file:
mco.h
Source file:
mcodisk.c
Library:
libmcovtdsk.a
Header file:
mco.h
Source file:
mcovtmem.c
Library:
libmcovtmem.a