Github user selvaganesang commented on a diff in the pull request: https://github.com/apache/trafodion/pull/1504#discussion_r178926825 --- Diff: core/sql/executor/ExExeUtilCli.cpp --- @@ -2091,27 +2084,57 @@ Lng32 ExeCliInterface::deleteContext(char* contextHandle) // in buf contains con Lng32 ExeCliInterface::retrieveSQLDiagnostics(ComDiagsArea *toDiags) { Lng32 retcode; - + ex_assert(toDiags != NULL, "ComDiagsArea is null"); if (diagsArea_ != NULL) { diagsArea_->clear(); diagsArea_->deAllocate(); } + retcode = SQL_EXEC_MergeDiagnostics_Internal(*toDiags); + SQL_EXEC_ClearDiagnostics(NULL); + return retcode; +} - if (toDiags != NULL) - { - retcode = SQL_EXEC_MergeDiagnostics_Internal(*toDiags); - SQL_EXEC_ClearDiagnostics(NULL); - } - else + +ComDiagsArea *ExeCliInterface::allocAndRetrieveSQLDiagnostics(ComDiagsArea *&toDiags) +{ + Lng32 retcode; + + if (diagsArea_ != NULL) { - diagsArea_ = ComDiagsArea::allocate(heap_); - retcode = SQL_EXEC_MergeDiagnostics_Internal(*diagsArea_); + diagsArea_->clear(); + diagsArea_->deAllocate(); } + if (toDiags == NULL) + toDiags = ComDiagsArea::allocate(heap_); - return retcode; + retcode = SQL_EXEC_MergeDiagnostics_Internal(*toDiags); + SQL_EXEC_ClearDiagnostics(NULL); + + if (retcode == 0) + return toDiags; + else + return NULL; } +void ExeCliInterface::retrieveOrSaveSQLDiagnostics(Lng32 cliRetcode, ComDiagsArea *diagsArea) --- End diff -- This function is not used. I created this function to avoid creating ComDiagsArea in advance for load operations. When I attempted to refactor the retrieveSQLDiagnostics and allocAndRetrieveSQLDiagnostics, it opened up more issues. I will remove this function
---