ctdbRebuildTable
Calls the RBLIFILX() function to rebuild a c-tree table.
Declaration
CTDBRET ctdbRebuildTable(CTHANDLE Handle, CTREBUILD_MODE mode);
Description
CTREBUILD Mode |
Description |
CTREBUILD_NONE |
The normal rebuild mode. |
CTREBUILD_PURGEDUP |
Purge duplicate records during rebuild. |
CTREBUILD_UPDATEIFIL |
Update the IFIL structure in the table. |
CTREBUILD_DATAONLY |
Rebuild only the datafile. |
CTREBUILD_COMPACT |
Compact and rebuild. |
CTREBUILD_ONLINE |
(In V13 and later) Triggers a shared mode index rebuild (requires the table create mode CTCREATE_TRNLOG) CTREBUILD_ONLINE can be combined with CTREBUILD_COMPACT (that is, CTREBUILD_ONLINE|CTREBUILD_COMPACT) to perform an online version of the compact operation that runs while the files are open for update by other users. However, if the table does not use the CTCREATE_TRNLOG create mode, the online compact occurs but the indexes are not rebuilt. |
Note: Exercise care when using CTREBUILD_DATAONLY and CTCREBUILD_UPDATEIFIL modes together as the index files will be removed from the table IFIL definition even if the index files still exist in the file system. This can cause later problems if ctdbAlterTable() is called to recreate the removed indexes.
ctdbRebuildTable() calls the FairCom DB RBLIFILX() function to rebuild a c-tree table. When used in conjunction with the open modes CTOPEN_CORRUPT and CTOPEN_DATAONLY, the ctdbRebuildTable() function can be used as a direct replacement for the c-tree ctrbldif rebuild utility.
The following steps are performed by c-treeDB API during a table rebuild process:
You must open the table before ctdbRebuildTable() is executed. It is recommended that the table be opened with CTOPEN_EXCLUSIVE mode. If the table is corrupt, you will need to open the table with the CTOPEN_CORRUPT mode and then call ctdbRebuildTable() to rebuild the data and index files. If there are missing or corrupt index files, open the table with CTOPEN_DATAONLY mode and ctdbRebuildTable() will reconstruct the missing index files.
There may be situations when you need to invoke this function to rebuild only the data file. After the data file rebuild is successful, you may need to call ctdbRebuildTable() again to rebuild the index files.
Return Values
Value |
Symbolic Constant |
Explanation |
---|---|---|
0 |
CTDBRET_OK |
Successful operation. |
650 |
DUPJ_ERR |
Duplicate keys purged and logged. |
See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values.
See Also
ctdbAlterTable()