mco_uda_db_close
MCO_RET mco_uda_db_close( /*IN*/const mco_metadict_header_t * metadict,
/*IN*/ unsigned short dict_no );
此函数将关闭 specified index 引用的数据库 。数据将被丢弃。数据库的所有句柄都无效。但是,请注意,数据库内存不会释放,调用应用程序负责分配和释放数据库内存。dict_no
| |
---|
MCO_S_OK | 已成功关闭数据库 |
MCO_E_NOINSTANCE | 无效的数据库句柄 |
MCO_E_OPENED_SESSIONS | 数据库连接仍处于打开状态 |
/* 应用程序代码片段 */
const char * dbname = "SimpleDb";
int main(int argc, char* argv[])
{
MCO_RET rc;
mco_runtime_info_t info;
unsigned int dict_no = 0;
unsigned int count;
mco_metadict_header_t *header;
mco_uda_class_storge patches[2];
...
mco_runtime_start();
mco_get_runtime_info(&info);
...
header = (mco_metadict_header_t *) malloc(size);
mco_metadict_init(header, size); /* initialize the metadict */
...
/* change storage type */
patches[0].class_code = get_class_code("InMem");
patches[0].persistence = MCO_UDA_CLASS_TRANSIENT;
patches[1].class_code = get_class_code("OnDisk");
patches[1].persistence = ( info.mco_disk_supported) ?
MCO_UDA_CLASS_PERSISTENT :
MCO_UDA_CLASS_TRANSIENT;
/* open database */
rc = mco_uda_db_open(metadict, /* meta-dictionary header - must be initialized */
0, /* dictionary number */
dev, /* memory devices */
n_dev, /* num of memory devices */
&db_params, /* db parameters */
patches, /* class storage type overrides */
2); /* number of storage type overrides */
if (rc == MCO_S_OK) {
...
/* close the database */
mco_uda_db_close(metadict, 0);
}
...
}