📄 mco.h
字号:
/******************************************************************* * * * mco.h * * * * This file is a part of the eXtremeDB source code * * Copyright (c) 2001-2006 McObject LLC * * All Rights Reserved * * * * eXtremeDB runtime public definitions and static API * * * ***************************************************************** */#ifndef MCO_MCO_H__#define MCO_MCO_H__#ifdef __cplusplusextern "C" { #endif//#define MCO_CFG_CHECKLEVEL_1#include "mcospec.h"typedef enum MCO_RET_E_ /* return codes */{ MCO_S_OK = 0, /* success */ MCO_S_BUSY = 1, /* the instance is busy */ MCO_S_NOTFOUND = 10, /* search operation failed */ MCO_S_CURSOR_END = 11, /* cursor cannot be moved */ MCO_S_CURSOR_EMPTY = 12, /* no objects in index */ MCO_S_DUPLICATE = 13, /* index restriction violated */ MCO_S_EVENT_RELEASED = 14, /* waiting thread was released */ MCO_E_INVALID_HANDLE = 51, /* normally invalid handle produces fatal error. This code returned by special checks. */ MCO_E_NOMEM = 52, /* no memory */ MCO_E_ACCESS = 53, /* trying to use read only transaction for write */ MCO_E_TRANSACT = 54, /* transaction is in error state */ MCO_E_INDEXLIMIT = 55, /* vector index out of bounds */ MCO_E_EMPTYVECTOREL = 56, /* vector element was not set (at given index) */ MCO_E_UNSUPPORTED = 57, /* resize vector, blob update etc. */ MCO_E_EMPTYOPTIONAL = 58, /* optional was not set */ MCO_E_EMPTYBLOB = 59, /* trying to read blob, which was not written */ MCO_E_CURSOR_INVALID = 60, /* cursor is not valid */ MCO_E_ILLEGAL_TYPE = 61, /* search by oid: type is not that was expected */ MCO_E_ILLEGAL_PARAM = 62, /* e.g. illegal search operation code */ MCO_E_CURSOR_MISMATCH = 63, /* cursor type and object type are incompatible */ MCO_E_DELETED = 65, /* trying to update object, deleted in current transaction */ MCO_E_LONG_TRANSACTON = 66, /* transaction length is more then MCO_TRN_MAXLENGTH */ MCO_E_INSTANCE_DUPLICATE = 67, /* attempt to create db instance with duplicate name */ MCO_E_UPGRADE_FAILED = 68, /* simultaneous upgrades may not be not possible */ MCO_E_NOINSTANCE = 69, /* db instance not found */ MCO_E_OPENED_SESSIONS = 70, /* failed to close db: have opened sessions */ MCO_E_PAGESIZE = 71, /* page size is not acceptable */ MCO_E_WRITE_STREAM = 75, /* write stream failure */ MCO_E_READ_STREAM = 76, /* read stream failure */ MCO_E_LOAD_DICT = 77, /* db load: dictionary differs */ MCO_E_LOAD_DATA = 78, /* error data when loading db */ MCO_E_VERS_MISMATCH = 79, /* version mismatch */ MCO_E_VOLUNTARY_NOT_EXIST= 80, /* voluntary index is not created */ MCO_E_EXCLUSIVE_MODE = 81, /* db is in the exclusive mode; try later */ MCO_E_MAXEXTENDS = 82, /* maximum number of extends reached */ MCO_E_HIST_OBJECT = 83, /* operation is illegal for old version of the object */ MCO_E_SHM_ERROR = 84, /* failed to create/attach to shared memory */ MCO_E_NOTINIT = 85, /* runtime was not initialized */ MCO_E_SESLIMIT = 86, /* sessions number limit reached */ MCO_E_INSTANCES_LIMIT = 87, /* too many instances */ MCO_E_MAXTRANSSIZE_LOCKED= 88, /* the maximum size of transaction cannot be changed */ MCO_E_2PHASECOMMIT = 89, /* 2-phase commit is in progress */ MCO_E_EVAL = 100, /* evaluation version limitaion */ MCO_E_HA = 200, /* HA base error code */ MCO_E_HAFRAMEWORK = 250, /* HAFRAMEWORK base error code */ MCO_E_LOG = 300 /* LOG base error code */} MCO_RET; /* return code */#define mco_trans_size 20 /* max number of updated or deleted objects in one transaction */#ifdef MCO_PLATFORM_X64#define mco_min_page_size 136 /* min size of a page */#define mco_cursor_size 136 /* cursor structure size */#define mco_handle_size 48 /* object handle size */#else //MCO_PLATFORM_X64#define mco_min_page_size 64 /* min size of a page */#define mco_cursor_size 48 /* cursor structure size */#define mco_handle_size 24 /* object handle size */#endif //MCO_PLATFORM_X64#define mco_handle_size_w ( mco_handle_size / sizeof(void *) )#define mco_cursor_size_w ( mco_cursor_size / sizeof(void *) )typedef void * MCO_Hf [ mco_handle_size_w ]; typedef struct mco_cursor_t_{ void * c[mco_cursor_size_w];} mco_cursor_t, /* cursor (structure) */* mco_cursor_h; /* cursor handle (pointer) */#ifdef MCO_NO_FORWARDStypedef void * mco_trans_h;typedef void * mco_db_h;typedef void * mco_dictionary_h;#elsestruct mco_trans_t_; typedef struct mco_trans_t_ *mco_trans_h; /* transaction handle (pointer) */struct mco_db_t_; typedef struct mco_db_t_ *mco_db_h; /* database handle (pointer) */struct mco_dictionary_t_; typedef struct mco_dictionary_t_ *mco_dictionary_h; /* dictionary handle (pointer) */#endif/* transaction priority values */typedef enum MCO_TRANS_PRIORITY_E_{ MCO_TRANS_IDLE = 1, MCO_TRANS_BACKGROUND = 2, MCO_TRANS_FOREGROUND = 3, MCO_TRANS_HIGH = 4, MCO_TRANS_ISR = 77}MCO_TRANS_PRIORITY;/* transaction types values */typedef enum MCO_TRANS_TYPE_E_{ MCO_READ_ONLY = 0, MCO_READ_WRITE = 1}MCO_TRANS_TYPE;/* Database management *//* sets the new maximum size of the transaction. MUST be called after mco_runtime_start() and before mco_db_open (...) */MCO_RET mco_set_maxtranssize ( uint4 ); MCO_RET mco_runtime_start ( void ); MCO_RET mco_runtime_stop ( void );MCO_RET mco_close_all_instances( void ); /* for multiprocessing only *//* depending on configuration, database is created in process's memory (address is specified), or in shared memory (in this case shared memory is acquired by database, and address used as "hint"; db_name used to construct shared memory id) */MCO_RET mco_db_open ( const char * db_name, mco_dictionary_h dict, void * mem_ptr, mco_puint total_size, uint2 page_size);/* extend cannot be called in shared memory mode */MCO_RET mco_db_extend ( const char * db_name, void * mem_ptr, mco_puint size );MCO_RET mco_db_close ( const char * db_name);MCO_RET mco_db_kill ( const char * db_name);MCO_RET mco_db_connect ( const char * dbname, /*OUT*/ mco_db_h * pdb );MCO_RET mco_db_disconnect ( mco_db_h db );MCO_RET mco_db_free_pages ( mco_db_h db, /*OUT*/ mco_puint * retvalue);MCO_RET mco_db_total_pages ( mco_db_h db, /*OUT*/ mco_puint * retvalue);MCO_RET mco_db_page_size ( mco_db_h db, /*OUT*/ uint2 * retvalue);MCO_RET mco_db_check_memory ( mco_db_h db );/* Transaction management */MCO_RET mco_trans_start ( mco_db_h db, MCO_TRANS_TYPE type, MCO_TRANS_PRIORITY pri, /*OUT*/ mco_trans_h * p_trans ); MCO_RET mco_trans_upgrade ( mco_trans_h t);MCO_RET mco_trans_commit ( mco_trans_h t);MCO_RET mco_trans_rollback ( mco_trans_h t);MCO_RET mco_trans_type ( mco_trans_h t, /*OUT*/ MCO_TRANS_TYPE * type);MCO_RET mco_get_last_error ( mco_trans_h t);MCO_RET mco_trans_commit_phase1( mco_trans_h t );MCO_RET mco_trans_commit_phase2( mco_trans_h t );/* Cursor-based */ typedef enum MCO_OPCODE_E_ { MCO_LT = 1, MCO_LE = 2, MCO_EQ = 3, MCO_GE = 4, MCO_GT = 5 } MCO_OPCODE; /* cursor navigation */MCO_RET mco_cursor_check ( mco_trans_h t, mco_cursor_h c); MCO_RET mco_cursor_first ( mco_trans_h t, /*INOUT*/ mco_cursor_h c); MCO_RET mco_cursor_last ( mco_trans_h t, /*INOUT*/ mco_cursor_h c); MCO_RET mco_cursor_next ( mco_trans_h t, /*INOUT*/ mco_cursor_h c); MCO_RET mco_cursor_prev ( mco_trans_h t, /*INOUT*/ mco_cursor_h c); /* cursor types */typedef enum MCO_CURSOR_TYPE_E_{ MCO_LIST_CURSOR = 0, MCO_TREE_CURSOR = 1, MCO_HASH_CURSOR = 2}MCO_CURSOR_TYPE;MCO_RET mco_cursor_type ( mco_cursor_h c, /*OUT*/ MCO_CURSOR_TYPE * type ); MCO_RET mco_cursor_get_class_code ( mco_cursor_h c, /*OUT*/ uint2 *rescode );/* statistics *//* statistics for a class, index pages are not counted here */typedef struct mco_class_stat_t_ { uint4 objects_num; uint4 core_pages; /* pages used for all data except blobs */ uint4 blob_pages; /* pages used by blobs */ mco_puint core_space; /* in bytes, not counting blobs */} mco_class_stat_t,* mco_class_stat_h;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -