...
- A caller never allocates the ComDiagsArea, but instead passes a reference to a pointer to the callee. The caller initializes the pointer to NULL. When an error/warning is raised the callee needs to allocate ComDiagsArea (if not already allocated) and populate it. Then the caller moves it to the objects of step 3 and destroys the ComDiagsArea allocated in the callee.
- In case of a process hop, the ComDiagsArea is shipped from the child only when there is an error or warning via IPC mechanism.
- While switching back from "META" CmpContext to user CmpContext, the errors/warnings from the META CmpContext are copied to the user CmpContext.
- Applications such as sqlci and mxosrvr should attempt to obtain the diagnostics info based on the return code of a CLI call. When the return code is 100, get the number of error condition via less expensive call SQL_EXEC_GetDiagnosticsStmtInfo2. When this call returns two or more conditions, then there are warnings other than 100.
- Use mark/rewind and other methods of ComDiagsArea to manipulate it rather than creating and copying it.
In the Executor, there is a macro, ExRaiseSqlError, that should be used. It takes care of the details of allocating a ComDiagsArea object if needed, and inserting the diagnostic into ComDiagsArea.
Code reviewers should monitor code changes involving ComDiagsArea to make sure these practices are followed.
...