Product Documentation

FairCom DB API for C

Previous Topic

Next Topic

ctdbSetDefaultIndex

Set the number of the new default index.

Declaration

CTDBRET ctdbSetDefaultIndex(CTHANDLE Handle, NINT indexno)

Description

ctdbSetDefaultIndex() sets the number of the new default index. Use ctdbGetDefaultIndex() to retrieve the table default index. Initially, the default index is the first index created during the table definition.

To force a physical data table traversal without using any indexes, specify the following constant:

  • CTDB_DATA_IDXNO

If not disabled during the table creation, two default indexes are created during the table definition, besides the indexes defined by the user. These indexes may be used to sort the table, and they are:

  • ROWID - this unique index represents the ordering of the table by input order. To set this index as the default, the Index parameter should be set to CTDB_ROWID_IDXNO;
  • RECBYT - this index represents the offset of the record inside the table. It is used internally to improve backward physical traversal of variable-length records. To set this index as the default, the Index parameter should be set to CTDB_RECBYT_IDXNO.

See the discussion on Hidden fields regarding these two indexes.

Use ctdbSetDefaultIndexByName() to set the table default index by name.

  • Handle [in] the record handle.
  • Index [in] the index number to be set as default.

Returns

ctdbSetDefaultIndex() returns CTDBRET_OK on success, or FairCom DB API C API error code on failure.

See also

ctdbAllocRecord(), ctdbSetTableDefaultIndexExtentSize(), ctdbGetDefaultIndex(), ctdbSetDefaultIndexByName()

TOCIndex