ctdbMergeDatabaseDictionary
Compare and merge c-treeDB API database dictionaries.
Declaration
ctdbEXPORT CTDBRET ctdbDECL ctdbMergeDatabaseDictionary (CTHANDLE src, CTHANDLE dst, mergeFunPtr mrgfun, logFunPtr logfun);
Description
Parameters
The function prototype is:
CTDBRET (ctdbDECL *mergeFunPtr) (pCTDBLIST src_list, pCTDBLIST dst_list);
mrgfun must return either an error code (in which case the ctdbMergeSessionDictionary () function will fail with that error code) or CTDBRET_OK if no error occurred.
The c-treeDB API engine will pass two lists (CTDBLIST) containing items of type MERGEINFO. One per each dictionary entry.
The MERGEINFO structure is defined as follows:
struct tagMERGEINFO
{
DICTDATA info;
NINT todo;
};
The function must set for each entry the action to be performed on that entry as follows:
Source List Actions |
Description |
DIFF_SRC_IGNORE |
Ignore the record in the source list and do not copy it on the target dictionary |
DIFF_SRC_COPY2DST |
Copy the record to the target dictionary for entries on the dst_list. |
Destination List Actions |
Description |
DIFF_DST_KEEP |
Keep the entry as it is. |
DIFF_DST_REMOVE |
Remove the entry. |
DIFF_DST_REWRITE |
Replace the dest record on disk with the one in the list (in case we merge only some information). |
For example, to replace an entry on the target dictionary with one from the source dictionary, the todo of the item in dsl_list must be set to DIFF_DST_REMOVE, the todo of the item in src_list to DIFF_SRC_COPY2DST.
The function prototype is:
VOID (ctdbDECL*logFunPtr) (NINT lvl, pTEXT mesg, CTDBRET error, pTEXT extra);
Note: Depending on where an error occurred, this function could be called multiple times with different lvl and mesg.
Return Values
See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values.
Example
Please review the source code for ctsqlmdd.c, FairCom DB SQL Database Move Utility, for a complete implementation using this c-treeDB API function.
See Also
ctrdbMergeSessionDictionary()