Github user selvaganesang commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1470#discussion_r174679546
--- Diff: core/sql/sqlci/SqlCmd.cpp ---
@@ -440,25 +461,50 @@ void handleLocalError(ComDiagsArea &diags, SqlciEnv
*sqlci_env)
// when HandleCLIError() is called with a error after a CLI call.
// Soln :10-021203-3433
- if (diags.getNumber(DgSqlCode::ERROR_)) {
+ if (diags->getNumber(DgSqlCode::ERROR_)) {
worstcode = SQL_Error;
}
- else if (diags.getNumber(DgSqlCode::WARNING_)) {
+ else if (diags->getNumber(DgSqlCode::WARNING_)) {
worstcode = SQL_Warning;
}
if (!lastLineWasABlank) log->WriteAllWithoutEOL("");
lastLineWasABlank = TRUE;
ostringstream errMsg;
- NADumpDiags(errMsg, &diags, TRUE/*newline*/, 0, NULL, log->isVerbose(),
+ NADumpDiags(errMsg, diags, TRUE/*newline*/, 0, NULL, log->isVerbose(),
sqlci_env->getTerminalCharset());
errMsg << ends;
log->WriteAllWithoutEOL(errMsg.str().c_str());
}
+Int64 getRowsAffected(SQLSTMT_ID *stmt)
+{
+ Int32 rc;
+ rc = SQL_EXEC_GetDiagnosticsStmtInfo2(stmt,
+ SQLDIAG_ROW_COUNT, &rowsAffected,
+ NULL, 0, NULL);
+ if (rc == 0)
+ return rowsAffected;
+ else
+ return -1;
+}
+
+Int64 getDiagsCondCount(SQLSTMT_ID *stmt)
+{
+ Int32 rc;
+ Int64 diagsCondCount;
+ rc = SQL_EXEC_GetDiagnosticsStmtInfo2(stmt,
+ SQLDIAG_NUMBER, &diagsCondCount,
+ NULL, 0, NULL);
+ if (rc == 0)
+ return 0;
+ else
+ return diagsCondCount;
--- End diff --
I just realized that I misread the function SQLCLI_ReturnCode. It looks
like diagsCondCount is uninitialized and hence junk value was returned for
getDiagsCondCount that enabled us to return warnings. Basically two issues made
this function to behave as expected most of the time. I will be fixing it soon
---