ctdbAddMRTTable
ctdbAddMRTTable() adds an existing MRTTable definition to the database dictionary.
Declaration
CTDBRET ctdbAddMRTTable(pCTDBDATABASE pDatabase, pTEXT Name, pTEXT ParentName, UINT info);
Description
ctdbAddMRTTable() functions much as ctdbAddTable() in adding an existing table to the database dictionary.
Return Values
Value |
Symbolic Constant |
Explanation |
---|---|---|
0 |
CTDBRET_OK |
Successful operation. |
See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values.
Example
Here is example pseudo code to add an existing MRTTable to a database dictionary. This example also demonstrates the ctdbAllocVTableInfo() ctdbGetVTableInfoFromTable(), and ctdbAddMRTTable(), ctdbFreeVTableInfo() functions.
For this example, assume that a MRTTable is already defined and you copy the host table to another machine. In this case, you simply need to add the tables to the new database dictionary.
pCTDBVTABLEINFO VTableInfo;
pCTDBTABLE hTable;
hTable = ctdbAllocTable(hDatabase);
if (hTable == NULL)
{
/* error */
}
retval = ctdbOpenTable(hTable, "tutorial_host", CTOPEN_EXCLUSIVE);
if (retval != CTDBRET_OK)
{
/* error */
}
VTableInfo = ctdbAllocVTableInfo(hTable, 200); /*retrieve max 200 definition (which is the maximum supported) */
if (VTableInfo == NULL)
{
/* error */
}
ctdbGetVTableInfoFromTable(VTableInfo);
ctdbCloseTable(hTable);
for (i = 0; i < VTableInfo->actual_elements; i++)
{
retval = ctdbAddMRTTable(hDatabase, VTableInfo->data[i].name, "tutorial_host", VTableInfo->data[i].id);
if (retval != CTDBRET_OK)
{
/* error */
}
}
ctdbFreeVTableInfo(VTableInfo );
See Also
ctdbAllocVTableInfo(), ctdbCreateMRTTable(), ctdbFreeVTableInfo(), ctdbGetVTableInfoFromTable(), ctdbGetVTableNumber(), ctdbIsVTable(), ctdbRemoveVTableResource(), ctdbSetMRTTableFilter()