Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic


Set the number of the new default index.


CTDBRET ctdbSetDefaultIndex(CTHANDLE Handle, NINT indexno)


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:


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.


ctdbSetDefaultIndex() returns CTDBRET_OK on success, or c-treeDB API C API error code on failure.

See also

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