MCO_RET mco_register_collations( /*IN*/ const_char * dbname,
/*IN*/ mco_collation_funcs_h colls);
| dbname | The name of the database |
|
colls |
A |
This function registers collation functions with the runtime when a specific collation order is required for the database. Two callback functions are required: one that is called by the runtime when two database fields (treated as character arrays) are compared, and the second generates a hash
| MCO_S_OK | Collation functions successfully registered |
|
MCO_E_INSTANCES_LIMIT |
Registry is full |
Schema file snippet:
declare database colldb;
class Record
{
string name;
uint4 value;
unique tree <name collate C1> tcoll;
};
Collation file (colldb_coll.c) snippet:
/* collation compare function */
int2 C1_collation_compare ( mco_collate_h c1, uint2 len1, mco_collate_h c2, uint2 len2)
{
/* TODO: add your implementation here */
return 0;
}
Application snippet:
const char * dbname = "colldb";
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 );
if( (MCO_S_OK == rc)
{
/* register alloc callback */
mco_register_collations( dbname, colldb_get_collations() );
/* connect to database */
rc = mco_db_connect(dbName, &db);
...
}
...
}