UDA Fields and Indexes

UDA Fields and Indexes

Fields in a database class are defined by the following descriptor:

 
    typedef struct tag_mco_dict_field_info_t_ 
    {
        unsigned short     field_no;       /* field sequential number (from 0) */
        char             * name;      /* DDL field name */
        mco_dict_type_t    type;      /* field type:  MCO_DD_.*/
        unsigned int       flags;     /* flags: MCO_DICT_FI_... */
        unsigned short     dimension; /* for arrays (MCO_DICT_FI_ARRAY)
        * the dimension for the array for
        * scalar-type fields is set to 0
        */
         
        unsigned short     struct_no; /* if type == MCO_DD_STRUCT),
        * the structure number,
        * otherwise, 0
        */
    } mco_dict_field_info_t, * mco_dict_field_info_p;
     

Where the values for flags can be a combination of the following:

     
    #define MCO_DICT_FI_OPTIONAL  1                    /* optional field */
    #define MCO_DICT_FI_INDEXED   2 /* the field is included in an index */
    #define MCO_DICT_FI_VECTOR    4                /* vector-based field */
    #define MCO_DICT_FI_ARRAY     8                 /* array-based field */
    #define MCO_DICT_FI_EVENT_UPD  0x10    /* update event set for field */
    #define MCO_DICT_FI_HAS_INIT_DATA	0x20
    #define MCO_DICT_FI_NULLABLE            0x40  /* field is nullable  */
    #define MCO_DICT_FI_NULL_INDICATOR      0x80  /* field is null indicator */
     

The following API functions will obtain a pointer to the field descriptor based on its number or name:

     
    MCO_RET mco_dict_field( const mco_metadict_header_t * metadict,
                    unsigned short dict_no,
                    unsigned short struct_no,
                    unsigned short field_no,
                    /* out */ mco_dict_field_info_p field_info );
     
    MCO_RET mco_dict_field_name ( const mco_metadict_header_t * metadict,
                    unsigned short dict_no,
                    unsigned short struct_no, 
                    const char * name,
                    /* out */ mco_dict_field_info_p field_info );
     

Indexes in a database class are defined by the following descriptor:

     
    typedef struct tag_mco_dict_index_info_t_
    {
        unsigned short     index_no;
        char             * name;
        unsigned int       flags;
        unsigned short     n_fields;
    } mco_dict_index_info_t, * mco_dict_index_info_p;
     

Where the values for flags can be a combination of the following:

 
    #define MCO_DICT_II_UNIQUE     1
    #define MCO_DICT_II_VOLUNTARY  2
    #define MCO_DICT_II_LIST       4
    #define MCO_DICT_II_AUTOID     8
    #define MCO_DICT_II_TREE       0x10
    #define MCO_DICT_II_HASH       0x20
    #define MCO_DICT_II_USERDEF    0x40
    #define MCO_DICT_II_KDTREE     0x80
    #define MCO_DICT_II_RTREE      0x100
    #define MCO_DICT_II_PATRICIA   0x200
    #define MCO_DICT_II_NULLABLE   0x400
     

The following API functions will obtain a pointer to the index descriptor based on its number or name:

     
    MCO_RET mco_dict_index( const mco_metadict_header_t * metadict,
                unsigned short dict_no,
                unsigned short struct_no,
                unsigned short index_no,
                /* out */ mco_dict_index_info_p index_info );
     
    MCO_RET mco_dict_index_name( const mco_metadict_header_t * metadict,
                unsigned short dict_no,
                unsigned short struct_no,
                const char * name,
                /* out */ mco_dict_index_info_p index_info );
     

When an index is composed of multiple fields, each part of the index is defined by the following descriptor:

     
    typedef struct tag_mco_dict_ifield_info_t_ 
    {
        unsigned short     ifield_no; /* segment number (zero-based) */
        unsigned short     field_no;  /* field number that corresponds to
        * the segment (within the same
        * class) */
        unsigned int       flags;    / *flags: MCO_DICT_IFI_... */
    } mco_dict_ifield_info_t, * mco_dict_ifield_info_p;
     

Where the values for flags can have the default value of 0 or :

 
    #define MCO_DICT_IFI_DESCENDING 1  /* sort descending; 0 = ascending */
    #define MCO_DICT_IFI_NULLABLE   2  /* field associated with index segment is nullable */
     

These bit-valued flags can be manipulated with bit-wise OR to set all possible combinations:

 
    flags = 0;                                              // ascending, non-nullable
    flags = MCO_DICT_IFI_DESCENDING                         // descending,non-nullable
    flags = MCO_DICT_IFI_NULLABLE                           // ascending, nullable
    flags = MCO_DICT_IFI_DESCENDING | MCO_DICT_IFI_NULLABLE // descending,non-nullable
     

The following API functions will obtain a pointer to the index field descriptor within an index composed of multiple fields based on its number or name:

 
    MCO_RET mco_dict_ifield ( const mco_metadict_header_t * metadict,
                    unsigned short dict_no,
                    unsigned short struct_no,
                    unsigned short index_no,
                    unsigned short ifield_no,
                    /* out */ mco_dict_ifield_info_p ifield_info );
 
    MCO_RET mco_dict_ifield_name( const mco_metadict_header_t * metadict,
                    unsigned short dict_no,
                    unsigned short struct_no,
                    unsigned short index_no,
                    const char * name,
                    /* out */ mco_dict_ifield_info_p ifield_info );