Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic

ctdbSetIndexFilename

Specify the Physical index file name.

Declaration

CTDBRET ctdbSetIndexFilename(CTHANDLE Handle, pTEXT path, pTEXT filename);

Description

  • Handle is an index handle returned by ctdbAddIndex() or ctdbGetIndex() calls.
  • path specifies the directory location of the index file. A NULL value for path indicates that the index file is to be located in the same directory as the data file.
  • filename specifies the name of the index file. If filename is NULL, this index is to be a member of the previous index file. If the filename of all index files are NULL, then all indexes will be placed in one physical index file located in the same directory as the data file, and the index file name is the same as the data file name, with the current index file extension.

An application can change the current index file extension by calling ctdbSetIndexExtension().

Return

Value

Symbolic Constant

Explanation

0

CTDBRET_OK

ctdbSetIndexFilename() returns CTDBRET_OK on success or c-treeDB API SDK error code on failure.

See Appendix A "c-tree Plus Error Codes" in c-tree Plus Programmer's Reference Guide for a complete listing of valid c-tree Plus error values.

Example

CTHANDLE hTable = ctdbAllocTable(hDatabase);

CTHANDLE hIndex;


ctdbAddField(hTable, "name", CT_FSTRING, 20);

ctdbAddField(hTable, "age", CT_INT2);


hIndex = ctdbAddIndex(hTable, "index1", CTINDEX_FIXED, NO, NO);

ctdbSetIndexFilename(hIndex, NULL, "myindex1");

ctdbAddSegmentByName(hTable, 0, "name", CTSEG_SCHSEG);

ctdbAddIndex(hTable, "index2", CTINDEX_FIXED, NO, NO);

ctdbAddSegmentByName(hTable, 1, "age", CTSEG_SCHSEG);


hIndex = ctdbAddIndex(hTable, "index3", CTINDEX_FIXED, NO, NO);

ctdbSetIndexFilename(hIndex, NULL, "myindex2");

ctdbAddSegmentByName(hTable, 2, "name", CTSEG_SCHSEG);

ctdbAddSegmentByName(hTable, 2, "age", CTSEG_SCHSEG);


if (ctdbCreateTable(hTable, "mytable", CTCREATE_NORMAL) != CTDBRET_OK)

printf("ctdbCreateTable failed with code %d\n", ctdbGetError(hTable));

See also

ctdbGetIndexFilename(), ctdbSetIndexExtension(), ctdbAddIndex(), ctdbGetIndex()

TOCIndex