ctdbAddSegmentByNbr
Add a new index segment to an index (given the table handle, field number, and index number).
Declaration
CTHANDLE ctdbAddSegmentByNbr(CTHANDLE Handle, NINT IndexNbr,
NINT FieldNbr, CTSEG_MODE SegMode)
Description
ctdbAddSegmentByNbr() adds a new index segment to an index, specifying the field by giving the table handle and the field number, and specifying the index by giving the index number.
The operation of adding a segment to an index links the specified index with the specified field in the specified table. When a segment is added with this function, the segment is defined based on an individual full field of a table, using what is known as a record schema. In other words, instead of using a byte offset into the record structure and a length, all you need to do is specify the field of interest and what table it’s in. See the FairCom DB documentation for further information on record schemas.
Use ctdbAddSegmentByName() to add a new index segment given its name. Use ctdbAddSegment() to add a new index segment given the index handle. Use ctdbAddSegmentEx() to add a new extended index segment.
ctdbAddSegmentByNbr() does the segment handle allocation. After the segments, indexes, and fields have been defined, the table can be created or altered with ctdbCreateTable() or ctdbAlterTable(). Segment handle deallocation is automatically handled by ctdbCloseTable() and ctdbCloseAll().
Returns
ctdbAddSegmentByNbr returns the segment handle on success, or NULL on failure
Example
ctdbAddField(pMyTable, "Name", CT_FSTRING, 32);
ctdbAddField(pMyTable, "Balance", CT_SFLOAT, 4);
ctdbAddIndex(pMyTable, "iName", CTINDEX_FIXED, NO, NO);
ctdbAddSegmentByNbr(pMyTable, 0, 0, CTSEG_USCHSEG);
RetVal = ctdbCreateTable(pMyTable, "Table1", CTCREATE_NORMAL);
See also
ctdbAddSegment(), ctdbAddSegmentEx(), ctdbAddSegmentByName()