You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by hz...@apache.org on 2018/01/11 17:45:45 UTC

[3/6] trafodion git commit: [TRAFODION-2896] Internal error in stored procedures when a warning is generated in SQL

[TRAFODION-2896] Internal error in stored procedures when a warning is generated in SQL

This problem was seen by Any on a large cluster and Selva found this issue
during debugging. At this point we don't have an easy testcase to reproduce,
but we agree that the code change is something we should do.


Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/4d521af7
Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/4d521af7
Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/4d521af7

Branch: refs/heads/master
Commit: 4d521af7799983c44f93e9ed46ed48c8871f7993
Parents: 90f0b66
Author: Hans Zeller <hz...@apache.org>
Authored: Tue Jan 9 22:10:33 2018 +0000
Committer: Hans Zeller <hz...@apache.org>
Committed: Tue Jan 9 22:10:33 2018 +0000

----------------------------------------------------------------------
 core/sql/udrserv/UdrResultSet.cpp | 22 +++++++++++-----------
 core/sql/udrserv/spinfo.cpp       | 14 +++++++-------
 core/sql/udrserv/udrserv.cpp      |  2 +-
 3 files changed, 19 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/4d521af7/core/sql/udrserv/UdrResultSet.cpp
----------------------------------------------------------------------
diff --git a/core/sql/udrserv/UdrResultSet.cpp b/core/sql/udrserv/UdrResultSet.cpp
index 2c3388c..78beebc 100644
--- a/core/sql/udrserv/UdrResultSet.cpp
+++ b/core/sql/udrserv/UdrResultSet.cpp
@@ -545,7 +545,7 @@ UdrResultSet::setContext(SQLCTX_HANDLE &oldCtx, ComDiagsArea &d)
   Int32 result = SQL_EXEC_SwitchContext((Lng32) getContextHandle(),
                                       &tmpCtx);
 
-  if (result != 0)
+  if (result < 0)
   {
     d << DgSqlCode(-UDR_ERR_INTERNAL_CLI_ERROR)
       << DgString0("SQL_EXEC_SwitchContext")
@@ -567,7 +567,7 @@ UdrResultSet::resetContext(SQLCTX_HANDLE ctxHandle, ComDiagsArea &d)
   SQLCTX_HANDLE tmpCtxHandle;
   Int32 result = SQL_EXEC_SwitchContext(ctxHandle, &tmpCtxHandle);
 
-  if (result != 0)
+  if (result < 0)
   {
     d << DgSqlCode(-UDR_ERR_INTERNAL_CLI_ERROR)
       << DgString0("SQL_EXEC_SwitchContext")
@@ -634,7 +634,7 @@ UdrResultSet::generateProxySyntax(ComDiagsArea &d)
   outmodule->module_name =0;
 
   retcode = SQL_EXEC_AllocDesc(output_desc_, 500);
-  if (retcode != 0)
+  if (retcode < 0)
   {
     d << DgSqlCode(-UDR_ERR_INTERNAL_CLI_ERROR)
       << DgString0("SQL_EXEC_AllocDesc")
@@ -645,7 +645,7 @@ UdrResultSet::generateProxySyntax(ComDiagsArea &d)
 
   // Describe Statement.
   retcode = SQL_EXEC_DescribeStmt(stmt_id_, NULL, output_desc_);
-  if (retcode != 0)
+  if (retcode < 0)
   {
     d << DgSqlCode(-UDR_ERR_INTERNAL_CLI_ERROR)
       << DgString0("SQL_EXEC_DescribeStmt")
@@ -657,7 +657,7 @@ UdrResultSet::generateProxySyntax(ComDiagsArea &d)
   // Check how many columns there are in the output_desc
   ComUInt32 numColumns = 0;
   retcode = SQL_EXEC_GetDescEntryCount(output_desc_, (Lng32*) &numColumns);
-  if (retcode != 0)
+  if (retcode < 0)
   {
     d << DgSqlCode(-UDR_ERR_INTERNAL_CLI_ERROR)
       << DgString0("SQL_EXEC_GetDescEntryCount")
@@ -751,7 +751,7 @@ UdrResultSet::generateProxySyntax(ComDiagsArea &d)
   retcode = SQL_EXEC_GetDescItems2(output_desc_,
                                    (Lng32) numColumns * NUMDESC_ITEMS,
                                    desc_items);
-  if (retcode != 0)
+  if (retcode < 0)
   {
     d << DgSqlCode(-UDR_ERR_INTERNAL_CLI_ERROR)
       << DgString0("SQL_EXEC_GetDescItems2")
@@ -1252,7 +1252,7 @@ UdrResultSet::setupQuadFields(ComDiagsArea &d)
                                                1,
                                                (Lng32) numColumns_,
                                                quad_fields_);
-  if (retcode != 0)
+  if (retcode < 0)
   {
     d << DgSqlCode(-UDR_ERR_INTERNAL_CLI_ERROR)
       << DgString0("SQL_EXEC_SETROWSETDESCPOINTERS")
@@ -1286,7 +1286,7 @@ UdrResultSet::fetchRowsFromCLI(UdrGlobals *udrGlob,
   if (stmt_id_->tag != 0)
   {
     retcode = SQL_EXEC_DisassocFileNumber(stmt_id_);
-    if (retcode != 0)
+    if (retcode < 0)
     {
       mainDiags << DgSqlCode(-UDR_ERR_INTERNAL_CLI_ERROR)
                 << DgString0("SQL_EXEC_DisassocFileNumber")
@@ -1321,7 +1321,7 @@ UdrResultSet::fetchRowsFromCLI(UdrGlobals *udrGlob,
          ! tmpBuffer_->moreRowsToCopy())
   {
     retcode = SQL_EXEC_ClearDiagnostics(stmt_id_);
-    if (retcode != 0)
+    if (retcode < 0)
     {
       mainDiags << DgSqlCode(-UDR_ERR_INTERNAL_CLI_ERROR)
                 << DgString0("SQL_EXEC_ClearDiagnostics")
@@ -1416,7 +1416,7 @@ UdrResultSet::fetchRowsFromCLI(UdrGlobals *udrGlob,
     }
 
     retcode = SQL_EXEC_ClearDiagnostics(stmt_id_);
-    if (retcode != 0)
+    if (retcode < 0)
     {
       mainDiags << DgSqlCode(-UDR_ERR_INTERNAL_CLI_ERROR)
                 << DgString0("SQL_EXEC_ClearDiagnostics")
@@ -1431,7 +1431,7 @@ UdrResultSet::fetchRowsFromCLI(UdrGlobals *udrGlob,
     retcode = SQL_EXEC_GetDescItem(output_desc_, 1,
                                    SQLDESC_ROWSET_NUM_PROCESSED,
                                    &numRowsFetched, 0, 0, 0, 0);
-    if (retcode != 0)
+    if (retcode < 0)
     {
       mainDiags << DgSqlCode(-UDR_ERR_INTERNAL_CLI_ERROR)
                 << DgString0("SQL_EXEC_GetDescItem")

http://git-wip-us.apache.org/repos/asf/trafodion/blob/4d521af7/core/sql/udrserv/spinfo.cpp
----------------------------------------------------------------------
diff --git a/core/sql/udrserv/spinfo.cpp b/core/sql/udrserv/spinfo.cpp
index 224592e..5de87c5 100644
--- a/core/sql/udrserv/spinfo.cpp
+++ b/core/sql/udrserv/spinfo.cpp
@@ -893,7 +893,7 @@ SQLSTMT_ID *SPInfo::executeSqlStmt(const char *sql_str, ComDiagsArea &d)
   Lng32 retcode = 0;
 
   retcode = SQL_EXEC_ClearDiagnostics(NULL);
-  if (retcode != 0)
+  if (retcode < 0)
   {
     d << DgSqlCode(-UDR_ERR_INTERNAL_CLI_ERROR)
       << DgString0("SQL_EXEC_ClearDiagnostics")
@@ -915,7 +915,7 @@ SQLSTMT_ID *SPInfo::executeSqlStmt(const char *sql_str, ComDiagsArea &d)
   stmt->handle = 0;
 
   retcode = SQL_EXEC_AllocStmt(stmt, 0);
-  if (retcode != 0)
+  if (retcode < 0)
   {
     d << DgSqlCode(-UDR_ERR_INTERNAL_CLI_ERROR)
       << DgString0("SQL_EXEC_AllocStmt")
@@ -938,7 +938,7 @@ SQLSTMT_ID *SPInfo::executeSqlStmt(const char *sql_str, ComDiagsArea &d)
   sqlsrc_desc.identifier = 0;
   sqlsrc_desc.handle = 0;
   retcode = SQL_EXEC_AllocDesc(&sqlsrc_desc, 1);
-  if (retcode != 0)
+  if (retcode < 0)
   {
     d << DgSqlCode(-UDR_ERR_INTERNAL_CLI_ERROR)
       << DgString0("SQL_EXEC_AllocDesc")
@@ -966,7 +966,7 @@ SQLSTMT_ID *SPInfo::executeSqlStmt(const char *sql_str, ComDiagsArea &d)
   desc_items[2].num_val_or_len = (Lng32) strlen(sql_str) + 1;
 
   retcode = SQL_EXEC_SetDescItems2(&sqlsrc_desc, 3, desc_items);
-  if (retcode != 0)
+  if (retcode < 0)
   {
     d << DgSqlCode(-UDR_ERR_INTERNAL_CLI_ERROR)
       << DgString0("SQL_EXEC_SetDescItem2")
@@ -982,7 +982,7 @@ SQLSTMT_ID *SPInfo::executeSqlStmt(const char *sql_str, ComDiagsArea &d)
 
   // Prepare the statement; stmt has the prepared plan
   retcode = SQL_EXEC_Prepare(stmt, &sqlsrc_desc);
-  if (retcode != 0)
+  if (retcode < 0)
   {
     SQL_EXEC_MergeDiagnostics_Internal(d);
 
@@ -1000,7 +1000,7 @@ SQLSTMT_ID *SPInfo::executeSqlStmt(const char *sql_str, ComDiagsArea &d)
 
   // Execute the statement
   retcode = SQL_EXEC_ExecClose(stmt, 0, 0, 0);
-  if (retcode != 0)
+  if (retcode < 0)
   {
     SQL_EXEC_MergeDiagnostics_Internal(d);
 
@@ -1285,7 +1285,7 @@ void SPInfo::quiesceExecutor()
                     "Message carried a transaction. About to quiesce.");
       
       Lng32 sqlcode = SQL_EXEC_Xact(SQLTRANS_QUIESCE, NULL);
-      if (sqlcode != 0)
+      if (sqlcode < 0)
       {
         char msg[MAXERRTEXT];
         str_sprintf(msg, "SQL_EXEC_Xact returned error %d", (Int32) sqlcode);

http://git-wip-us.apache.org/repos/asf/trafodion/blob/4d521af7/core/sql/udrserv/udrserv.cpp
----------------------------------------------------------------------
diff --git a/core/sql/udrserv/udrserv.cpp b/core/sql/udrserv/udrserv.cpp
index a118b1c..050898f 100644
--- a/core/sql/udrserv/udrserv.cpp
+++ b/core/sql/udrserv/udrserv.cpp
@@ -2105,7 +2105,7 @@ static Int32 invokeUdrMethod(const char *method,
     if (txRequired && result == LM_OK)
     {
       cliResult = SQL_EXEC_Xact(SQLTRANS_QUIESCE, NULL);
-      if (cliResult != 0)
+      if (cliResult < 0)
       {
         fprintf(f, "%s SQL_EXEC_Xact() returned %d\n",
                 prefix, cliResult);