trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [1/5] trafodion git commit: [TRAFODION-2853] memory leak of ComDiagsArea in CmpContext heap of mxosrvr
Date Mon, 26 Mar 2018 20:00:49 GMT
Repository: trafodion
Updated Branches:
  refs/heads/master 7d77dd4f9 -> 7430ca834


[TRAFODION-2853] memory leak of ComDiagsArea in CmpContext heap of mxosrvr

Fixed a memory leak in ComDiagsArea that was missed out earlier. Also
took care of the review comments from the earlier PR


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

Branch: refs/heads/master
Commit: 8868d81895c3b7a8dd25363578c8f749f5b490ce
Parents: 3e26f86
Author: selvaganesang <selva.govindarajan@esgyn.com>
Authored: Tue Mar 20 18:46:38 2018 +0000
Committer: selvaganesang <selva.govindarajan@esgyn.com>
Committed: Tue Mar 20 21:25:08 2018 +0000

----------------------------------------------------------------------
 core/sql/executor/ExExeUtilGetStats.cpp     | 10 ++++++-
 core/sql/executor/ExExeUtilLoad.cpp         | 13 +++-----
 core/sql/executor/ex_ddl.cpp                | 18 ++++++-----
 core/sql/executor/ex_root.cpp               | 38 +++++++++++++++++++++---
 core/sql/export/ComDiags.cpp                | 10 +++++++
 core/sql/export/ComDiags.h                  |  2 ++
 core/sql/regress/compGeneral/EXPECTED013.SB | 12 ++++----
 core/sql/regress/core/DIFF038.KNOWN.LINUX   |  3 ++
 core/sql/regress/executor/DIFF001.KNOWN.SB  |  9 ++----
 core/sql/regress/privs2/EXPECTED129         |  8 ++---
 core/sql/regress/privs2/EXPECTED139         |  4 +--
 core/sql/regress/privs2/EXPECTED140         |  2 +-
 core/sql/regress/seabase/DIFF002.KNOWN      |  3 ++
 core/sql/regress/seabase/EXPECTED020        |  4 +--
 core/sql/regress/seabase/EXPECTED026        |  2 +-
 core/sql/regress/seabase/EXPECTED031        |  8 ++---
 core/sql/sqlci/SqlCmd.cpp                   | 20 +++++++------
 core/sql/sqlci/sqlcmd.h                     |  2 +-
 18 files changed, 110 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/executor/ExExeUtilGetStats.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilGetStats.cpp b/core/sql/executor/ExExeUtilGetStats.cpp
index 9e99b5c..087820a 100644
--- a/core/sql/executor/ExExeUtilGetStats.cpp
+++ b/core/sql/executor/ExExeUtilGetStats.cpp
@@ -4024,15 +4024,23 @@ short ExExeUtilGetRTSStatisticsTcb::work()
       break;
     case HANDLE_ERROR_:
       {
+        // SQL_EXEC_GetStatistics2 CLI call populates the diagnostics area
+        // in context directly. However, ExHandleErrors will push this
+        // into queue entry. CLI layer populates from queue into context
+        // causing the errors to be displayed twice. Hence clear
+        // Context diagnostics area here
+        ComDiagsArea *diagsArea = currContext->getDiagsArea();
         ExHandleErrors(qparent_,
 			        pentry_down,
 			        0,
 			        getGlobals(),
-			        NULL,
+			        (diagsArea->getNumber() > 0 ? diagsArea : NULL),
 			        (ExeErrorCode)cliRC,
 			        NULL,
 			        NULL
 			        );
+        if (diagsArea->getNumber() > 0)
+           diagsArea->clear();
         step_ = DONE_;
       }
       break;

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/executor/ExExeUtilLoad.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilLoad.cpp b/core/sql/executor/ExExeUtilLoad.cpp
index 97c185c..72d49b2 100644
--- a/core/sql/executor/ExExeUtilLoad.cpp
+++ b/core/sql/executor/ExExeUtilLoad.cpp
@@ -1128,9 +1128,8 @@ short ExExeUtilHBaseBulkLoadTcb::work()
   ex_queue_entry * pentry_down = qparent_.down->getHeadEntry();
   ExExeUtilPrivateState & pstate = *((ExExeUtilPrivateState*) pentry_down->pstate);
 
-  ContextCli *currContext =
-    getGlobals()->castToExExeStmtGlobals()->castToExMasterStmtGlobals()->
-    getStatement()->getContext();
+  ExMasterStmtGlobals *masterGlob = getGlobals()->castToExExeStmtGlobals()->castToExMasterStmtGlobals();
+  ContextCli *currContext = masterGlob->getStatement()->getContext();
   ExTransaction *ta = currContext->getTransaction();
 
 
@@ -1195,8 +1194,6 @@ short ExExeUtilHBaseBulkLoadTcb::work()
         return rc;
 
         // Set the parserflag to prevent privilege checks in purgedata
-        ExExeStmtGlobals *exeGlob = getGlobals()->castToExExeStmtGlobals();
-        ExMasterStmtGlobals *masterGlob = exeGlob->castToExMasterStmtGlobals();
         NABoolean parserFlagSet = FALSE;
         if ((masterGlob->getStatement()->getContext()->getSqlParserFlags() &
0x20000) == 0)
         {
@@ -1406,8 +1403,6 @@ short ExExeUtilHBaseBulkLoadTcb::work()
 
           // If the WITH SAMPLE clause is included, set the internal exe util
           // parser flag to allow it.
-          ExExeStmtGlobals *exeGlob = getGlobals()->castToExExeStmtGlobals();
-          ExMasterStmtGlobals *masterGlob = exeGlob->castToExMasterStmtGlobals();
           NABoolean parserFlagSet = FALSE;
           if (hblTdb().getUpdateStats() && !ustatNonEmptyTable)
           {
@@ -1708,11 +1703,11 @@ short ExExeUtilHBaseBulkLoadTcb::work()
       else
         diagsArea->incrRefCount(); // setDiagsArea call below will decr ref count
 
-      diagsArea->setRowCount(rowsAffected_);
-
       if (getDiagsArea())
         diagsArea->mergeAfter(*getDiagsArea());
 
+      masterGlob->setRowsAffected(rowsAffected_);
+
       up_entry->setDiagsArea(diagsArea);
 
       // insert into parent

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/executor/ex_ddl.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_ddl.cpp b/core/sql/executor/ex_ddl.cpp
index ed04c04..8471e04 100644
--- a/core/sql/executor/ex_ddl.cpp
+++ b/core/sql/executor/ex_ddl.cpp
@@ -274,20 +274,14 @@ short ExDDLTcb::work()
             currContext->exHeap()->deallocateMemory((void*)dummyReply);
           if (cpStatus == ExSqlComp::SUCCESS)
             {
-           // CatSQLObjectCache &catCache = CatProcess.getSQLObjectCache();
-           // catCache.cleanupCache();
-              // clear diagsArea of cli context which may have warnings
-              // set when calling cli inside the embedded compiler
-              if (!currContext->diags().getNumber(DgSqlCode::ERROR_))
-                currContext->diags().clear();
               goto endOfData;
             }
           else
             {
               handleErrors(pentry_down, cpDiagsArea, cpStatus);
               //Don't proceed if its an error.
-              if (cpStatus == ExSqlComp::ERROR)
-                goto endOfData;
+              if (cpStatus == ExSqlComp::ERROR) 
+                 goto endOfData;
             }
         }
       else if (getArkcmp())  // regular arkcmp exists
@@ -384,6 +378,14 @@ short ExDDLTcb::work()
 	  
           diagsArea->mergeAfter (*cpDiagsArea);
           up_entry->setDiagsArea(diagsArea);
+          // For now, copy the warnings to currContext diaga area
+          // because ex_root_tcb::execute returns 0 for warnings
+          if (cpDiagsArea->getNumber(DgSqlCode::WARNING_) > 0)
+          {
+             diagsArea = currContext->getDiagsArea();
+             diagsArea->mergeAfter (*cpDiagsArea);
+          }
+          cpDiagsArea->decrRefCount();
         }
 
       up_entry->upState.parentIndex = 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/executor/ex_root.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_root.cpp b/core/sql/executor/ex_root.cpp
index 38654b3..5b4bb97 100644
--- a/core/sql/executor/ex_root.cpp
+++ b/core/sql/executor/ex_root.cpp
@@ -932,7 +932,6 @@ Int32 ex_root_tcb::execute(CliGlobals *cliGlobals,
       return fatal_error(glob, diagsArea);
     }
 
-
   // Following code is test for soln 10-081104-7061.  A CQD
   // COMP_INT_38 can be used to force various kinds of abends
   // in the master.
@@ -972,9 +971,39 @@ Int32 ex_root_tcb::execute(CliGlobals *cliGlobals,
         break;
       }
   }
-#endif 
-
-  return 0;
+#endif
+  Int32 retcode = 0;
+// The lines below were added to return proper value
+// for retcode at the time of execute. But it seems to
+// open up more issues. So commented out for now
+/*
+  if (qchild.up->isEmpty())
+     return 0;  
+  ex_queue_entry *centry = qchild.up->getHeadEntry();
+  if (centry == NULL)
+     return 0;
+  if (centry->getDiagsArea()) {
+     if (diagsArea == NULL)     
+        diagsArea = ex_root_tcb::moveDiagsAreaFromEntry (centry);
+     else
+        diagsArea->mergeAfter(*centry->getDiagsArea());
+  }
+  // Copied the diagsArea to be returned as part of the SQL_EXEC_Fetch
+  // But SQL_EXEC_Exec will continue to return 0 to avoid
+  // breaking the implied protocol.
+  if (diagsArea != NULL) {
+     if (retcode == 0 && diagsArea->mainSQLCODE() > 0)
+        // It's a warning. So return 1. That's what the cli expects.
+        retcode = 1;
+     else if (diagsArea->mainSQLCODE() < 0)
+        // It's an error. Return the negative value.
+        retcode = -1;
+     else
+        // It's a Diags Area w/o any Conditions.
+        retcode = 0;
+  }
+*/
+  return retcode;
 }
 
 void ex_root_tcb::setupWarning(Lng32 retcode, const char * str,
@@ -2117,6 +2146,7 @@ Int32 ex_root_tcb::oltExecute(ExExeStmtGlobals * glob,
       ipcEnv->getAllConnections()->waitOnAll();
       
     } // while (1)
+
 }
 
 /////////////////////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/export/ComDiags.cpp
----------------------------------------------------------------------
diff --git a/core/sql/export/ComDiags.cpp b/core/sql/export/ComDiags.cpp
index 270423e..b3c6169 100644
--- a/core/sql/export/ComDiags.cpp
+++ b/core/sql/export/ComDiags.cpp
@@ -2958,6 +2958,16 @@ void ComDiagsArea::clearErrorConditionsOnly()
    }
 }
 
+void ComDiagsArea::clearWarnings()
+{
+   DiagsCondition  *ptr;
+   while (warnings_.getFirst(ptr)) 
+   {
+     ptr->deAllocate();
+     --maxDiagsId_;
+   }
+}
+
 // Returnes the SQLSTATE value of the last SIGNAL statement.
 // Assumes the SIGNAL condition is the highest priority error.
 const char *ComDiagsArea::getSignalSQLSTATE() const

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/export/ComDiags.h
----------------------------------------------------------------------
diff --git a/core/sql/export/ComDiags.h b/core/sql/export/ComDiags.h
index da54f7d..7bdb5c6 100644
--- a/core/sql/export/ComDiags.h
+++ b/core/sql/export/ComDiags.h
@@ -939,6 +939,8 @@ public:
   void                    clear                      ();
   void                    clearConditionsOnly        ();
   void			  clearErrorConditionsOnly   ();
+
+  void			  clearWarnings();
   // the next 3 methods are called to set a warning, an EOD indication(100),
   // or an error. Useful while debugging to find out when/where an 
   // error/warning/EOD is being set.

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/regress/compGeneral/EXPECTED013.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/EXPECTED013.SB b/core/sql/regress/compGeneral/EXPECTED013.SB
index 7592226..13dd0ce 100644
--- a/core/sql/regress/compGeneral/EXPECTED013.SB
+++ b/core/sql/regress/compGeneral/EXPECTED013.SB
@@ -53,7 +53,7 @@ SCAN
 
 *** WARNING[1313] The referential integrity constraint TRAFODION.SCH.CONS11 has been created
with the NOT ENFORCED attribute and will not be enforced during INSERT, UPDATE, OR DELETE
statements.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>create table orders1 (o_orderkey int not null, o_custkey int, foreign key(o_custkey)
references customer(c_custkey) enforced, primary key(o_orderkey)) no partitions;
 
 --- SQL operation complete.
@@ -328,28 +328,28 @@ SCAN
 
 *** WARNING[1313] The referential integrity constraint TRAFODION.SCH.CONS2 has been created
with the NOT ENFORCED attribute and will not be enforced during INSERT, UPDATE, OR DELETE
statements.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>create table fk1 ( a int not null primary key, b int, c int, constraint cons3 foreign
key (b) references uk1(a) not enforced) ;
 
 *** WARNING[1313] The referential integrity constraint TRAFODION.SCH.CONS3 has been created
with the NOT ENFORCED attribute and will not be enforced during INSERT, UPDATE, OR DELETE
statements.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>create table fk2 ( a int not null primary key, b int, c int, constraint cons4 foreign
key (a,b) references uk2(a,b) not enforced) ;
 
 *** WARNING[1313] The referential integrity constraint TRAFODION.SCH.CONS4 has been created
with the NOT ENFORCED attribute and will not be enforced during INSERT, UPDATE, OR DELETE
statements.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>create table fk3 ( a int not null primary key, b int, c int, constraint cons5 foreign
key (a,b,c) references uk3(a,b,c) not enforced) ;
 
 *** WARNING[1313] The referential integrity constraint TRAFODION.SCH.CONS5 has been created
with the NOT ENFORCED attribute and will not be enforced during INSERT, UPDATE, OR DELETE
statements.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>
 >>create table ffk0 ( a int not null primary key, b int, c int, constraint cons6 foreign
key (b) references fk0(a) not enforced) ;
 
 *** WARNING[1313] The referential integrity constraint TRAFODION.SCH.CONS6 has been created
with the NOT ENFORCED attribute and will not be enforced during INSERT, UPDATE, OR DELETE
statements.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>
 >>-- tables for sol: 10-100722-1962 test
 >>create table t_013 ( a int not null, 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/regress/core/DIFF038.KNOWN.LINUX
----------------------------------------------------------------------
diff --git a/core/sql/regress/core/DIFF038.KNOWN.LINUX b/core/sql/regress/core/DIFF038.KNOWN.LINUX
new file mode 100644
index 0000000..0ddbe3b
--- /dev/null
+++ b/core/sql/regress/core/DIFF038.KNOWN.LINUX
@@ -0,0 +1,3 @@
+361a362,363
+> *** WARNING[3250] The specified blocksize is not valid. Blocksize of 32768 is used instead.
+> 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/regress/executor/DIFF001.KNOWN.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/executor/DIFF001.KNOWN.SB b/core/sql/regress/executor/DIFF001.KNOWN.SB
index 37172bd..edfe7ce 100644
--- a/core/sql/regress/executor/DIFF001.KNOWN.SB
+++ b/core/sql/regress/executor/DIFF001.KNOWN.SB
@@ -1,6 +1,3 @@
-690a691
->  10 10
-692c693
-< --- 1 row(s) selected.
----
-> --- 2 row(s) selected.
+8a9,10
+> *** WARNING[3169] SJIS is not a known collation.
+> 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/regress/privs2/EXPECTED129
----------------------------------------------------------------------
diff --git a/core/sql/regress/privs2/EXPECTED129 b/core/sql/regress/privs2/EXPECTED129
index 5cc90c4..5dc8a05 100644
--- a/core/sql/regress/privs2/EXPECTED129
+++ b/core/sql/regress/privs2/EXPECTED129
@@ -823,7 +823,7 @@ CREATE TABLE TRAFODION.US4.T4
 
 *** WARNING[1018] Grant of role or privilege SELECT WITH GRANT OPTION (columm number 2) on
TRAFODION.US4.T3 from SQL_USER4 to SQL_USER3 not found, revoke request ignored.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>revoke select (b) on t3 from sql_user3;
 
 --- SQL operation complete.
@@ -832,7 +832,7 @@ CREATE TABLE TRAFODION.US4.T4
 
 *** WARNING[1018] Grant of role or privilege SELECT WITH GRANT OPTION (columm number 2) on
TRAFODION.US4.T3 from SQL_USER4 to SQL_USER3 not found, revoke request ignored.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>
 >>revoke grant option for select (d) on t3 from sql_user3;
 
@@ -842,12 +842,12 @@ CREATE TABLE TRAFODION.US4.T4
 
 *** WARNING[1018] Grant of role or privilege SELECT WITH GRANT OPTION (columm number 1) on
TRAFODION.US4.T3 from SQL_USER4 to SQL_USER3 not found, revoke request ignored.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>revoke grant option for select (b) on t3 from sql_user3 cascade;
 
 *** WARNING[1018] Grant of role or privilege SELECT WITH GRANT OPTION (columm number 1) on
TRAFODION.US4.T3 from SQL_USER4 to SQL_USER3 not found, revoke request ignored.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>showddl t3;
 
 CREATE TABLE TRAFODION.US4.T3

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/regress/privs2/EXPECTED139
----------------------------------------------------------------------
diff --git a/core/sql/regress/privs2/EXPECTED139 b/core/sql/regress/privs2/EXPECTED139
index b791810..1c11104 100644
--- a/core/sql/regress/privs2/EXPECTED139
+++ b/core/sql/regress/privs2/EXPECTED139
@@ -531,7 +531,7 @@ ALTER TABLE TRAFODION.T139SCH.GAMES ADD CONSTRAINT
 
 *** WARNING[1018] Grant of role or privilege ALL_DML from DB__ROOT to SQL_USER2 not found,
revoke request ignored.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>showddl games;
 
 CREATE TABLE TRAFODION.T139SCH.GAMES
@@ -561,7 +561,7 @@ ALTER TABLE TRAFODION.T139SCH.GAMES ADD CONSTRAINT
 
 *** WARNING[1018] Grant of role or privilege ALL_DML from DB__ROOT to SQL_USER3 not found,
revoke request ignored.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>showddl teams;
 
 CREATE TABLE TRAFODION.T139SCH.TEAMS

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/regress/privs2/EXPECTED140
----------------------------------------------------------------------
diff --git a/core/sql/regress/privs2/EXPECTED140 b/core/sql/regress/privs2/EXPECTED140
index 62e0b5b..b49bd55 100644
--- a/core/sql/regress/privs2/EXPECTED140
+++ b/core/sql/regress/privs2/EXPECTED140
@@ -618,7 +618,7 @@ Tom                                                 White Socks
 
 *** WARNING[1013] Not all privileges were granted.  You lack grant option for the INSERT
privilege.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>
 >>-- user3 can propagate insert on table players
 >>grant insert on players to sql_user4;

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/regress/seabase/DIFF002.KNOWN
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/DIFF002.KNOWN b/core/sql/regress/seabase/DIFF002.KNOWN
new file mode 100644
index 0000000..b323eb2
--- /dev/null
+++ b/core/sql/regress/seabase/DIFF002.KNOWN
@@ -0,0 +1,3 @@
+1264,1265d1263
+< *** WARNING[8742] GetMetaDataInfo operation could not be completed. Reason: Datatype
array<string> for column 'a' in table hive.hive.thivearr is not supported. This table
will be ignored.
+< 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/regress/seabase/EXPECTED020
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED020 b/core/sql/regress/seabase/EXPECTED020
index 15771ce..18dd7a7 100644
--- a/core/sql/regress/seabase/EXPECTED020
+++ b/core/sql/regress/seabase/EXPECTED020
@@ -3125,7 +3125,7 @@ VCH15            NINT         CH3  NLARGE
 
 *** WARNING[1313] The referential integrity constraint TRAFODION.SCH.T34_1 has been created
with the NOT ENFORCED attribute and will not be enforced during INSERT, UPDATE, OR DELETE
statements.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>showddl test020_t34;
 
 CREATE TABLE TRAFODION.SCH.TEST020_T34
@@ -3165,7 +3165,7 @@ ALTER TABLE TRAFODION.SCH.TEST020_T34 ADD CONSTRAINT TRAFODION.SCH.T34_1
 
 *** WARNING[1313] The referential integrity constraint TRAFODION.SCH.T34_1 has been created
with the NOT ENFORCED attribute and will not be enforced during INSERT, UPDATE, OR DELETE
statements.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>showddl test020_t34;
 
 CREATE TABLE TRAFODION.SCH.TEST020_T34

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/regress/seabase/EXPECTED026
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED026 b/core/sql/regress/seabase/EXPECTED026
index fb16c30..05be357 100644
--- a/core/sql/regress/seabase/EXPECTED026
+++ b/core/sql/regress/seabase/EXPECTED026
@@ -269,7 +269,7 @@
 
 *** WARNING[4255] Provided schema name does not exist in metadata. Cleanup will be performed
on objects in this schema, if they exist.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>create schema sch026;
 
 --- SQL operation complete.

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/regress/seabase/EXPECTED031
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED031 b/core/sql/regress/seabase/EXPECTED031
index 43a3d2d..35637cd 100644
--- a/core/sql/regress/seabase/EXPECTED031
+++ b/core/sql/regress/seabase/EXPECTED031
@@ -771,7 +771,7 @@ A            B                     C
 
 *** WARNING[4493] Stored Descriptor Status: Uptodate and current.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>
 >>alter table t031t1 delete stored descriptor;
 
@@ -800,7 +800,7 @@ A            B                     C
 
 *** WARNING[4493] Stored Descriptor Status: Uptodate and current.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>invoke t031t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T031T1
@@ -891,7 +891,7 @@ CREATE INDEX T031T1I1 ON TRAFODION.SCH.T031T1
 
 *** WARNING[4493] Stored Descriptor Status: Uptodate and current.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>alter table t031t1 delete stored descriptor;
 
 --- SQL operation complete.
@@ -923,7 +923,7 @@ CREATE INDEX T031T1I1 ON TRAFODION.SCH.T031T1
 
 *** WARNING[4493] Stored Descriptor Status: Uptodate and current.
 
---- SQL operation complete.
+--- SQL operation completed with warnings.
 >>showddl t031t1;
 
 CREATE TABLE TRAFODION.SCH.T031T1

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/sqlci/SqlCmd.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlci/SqlCmd.cpp b/core/sql/sqlci/SqlCmd.cpp
index e645af4..8370aa8 100644
--- a/core/sql/sqlci/SqlCmd.cpp
+++ b/core/sql/sqlci/SqlCmd.cpp
@@ -150,11 +150,13 @@ void HandleCLIError(SQLSTMT_ID *stmt, Lng32 &error, SqlciEnv *sqlci_env,
 		    NABoolean displayErr, NABoolean * isEOD,
                                Int32 prepcode)
 {
-  Int64 diagsCondCount = 0;
-  if (error == 100) 
+  Int32 diagsCondCount = 0;
+  if (error == 100)
      diagsCondCount = getDiagsCondCount(stmt); 
-  NABoolean getWarningWithEOF = (diagsCondCount > 0); 
-  HandleCLIError(error, sqlci_env, displayErr, isEOD, prepcode, getWarningWithEOF);
+  // Get Warnings only when there are 2 or more conditions.
+  // One condition is for the error code 100 and the others are the actual warnings
+  NABoolean getWarningsWithEOF = (diagsCondCount > 1); 
+  HandleCLIError(error, sqlci_env, displayErr, isEOD, prepcode, getWarningsWithEOF);
 }
 
 void HandleCLIError(Lng32 &error, SqlciEnv *sqlci_env,
@@ -492,17 +494,17 @@ Int64 getRowsAffected(SQLSTMT_ID *stmt)
       return -1;
 }
 
-Int64 getDiagsCondCount(SQLSTMT_ID *stmt)
+Int32 getDiagsCondCount(SQLSTMT_ID *stmt)
 {
    Int32 rc;
-   Int64 diagsCondCount;
+   Int32 diagsCondCount;
    rc = SQL_EXEC_GetDiagnosticsStmtInfo2(stmt,
                            SQLDIAG_NUMBER, &diagsCondCount,
                            NULL, 0, NULL);
-   if (rc == 0)
-      return 0; 
+   if (rc >= 0)
+      return diagsCondCount; 
    else
-      return diagsCondCount;
+      return 0;
 }
 
 static char * upshiftStr(char * inStr, char * outStr, UInt32 len)

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8868d818/core/sql/sqlci/sqlcmd.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlci/sqlcmd.h b/core/sql/sqlci/sqlcmd.h
index b7d40f9..d2c936f 100644
--- a/core/sql/sqlci/sqlcmd.h
+++ b/core/sql/sqlci/sqlcmd.h
@@ -65,7 +65,7 @@ extern void HandleCLIError(SQLSTMT_ID *stmt, Lng32 &err, SqlciEnv *sqlci_env,
 
 void handleLocalError(ComDiagsArea *diags, SqlciEnv *sqlci_env);
 Int64 getRowsAffected(SQLSTMT_ID *stmt);
-Int64 getDiagsCondCount(SQLSTMT_ID *stmt);
+Int32 getDiagsCondCount(SQLSTMT_ID *stmt);
 // for unnamed parameters
 #define MAX_NUM_UNNAMED_PARAMS  128
 #define MAX_LEN_UNNAMED_PARAM 300


Mime
View raw message