fix issues for local var and support complex get command

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

Branch: refs/heads/master
Commit: 14f57eaad0e8ffae58ff79f42c29b551e8fa2280
Parents: e18bab4
Author: Liu Ming <ovis_p...@sina.com>
Authored: Wed Jul 11 12:24:38 2018 -0400
Committer: Liu Ming <ovis_p...@sina.com>
Committed: Wed Jul 11 12:24:38 2018 -0400

----------------------------------------------------------------------
 core/sql/executor/ExExeUtil.h      |  7 +++++++
 core/sql/executor/ExExeUtilGet.cpp | 21 ++++++++++++++++-----
 2 files changed, 23 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/14f57eaa/core/sql/executor/ExExeUtil.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtil.h b/core/sql/executor/ExExeUtil.h
index 595a0a6..dac9c18 100644
--- a/core/sql/executor/ExExeUtil.h
+++ b/core/sql/executor/ExExeUtil.h
@@ -2491,6 +2491,11 @@ protected:
   Lng32 getUsedObjects(Queue * infoList,
                       NABoolean isShorthandView,
                       char* &viewName, Lng32 &len);
+  void setReturnRowCount( Lng32 n) { returnRowCount_ = n; }
+
+  Lng32 getReturnRowCount() {return returnRowCount_;}
+
+  void incReturnRowCount() {returnRowCount_++; }
 
 private:
 
@@ -2518,6 +2523,8 @@ private:
     const char *schName,
     const char *objName);
 
+  Lng32 returnRowCount_;
+
 };
 
 //////////////////////////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/trafodion/blob/14f57eaa/core/sql/executor/ExExeUtilGet.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilGet.cpp 
b/core/sql/executor/ExExeUtilGet.cpp
index 27064e2..dbc5097 100644
--- a/core/sql/executor/ExExeUtilGet.cpp
+++ b/core/sql/executor/ExExeUtilGet.cpp
@@ -149,6 +149,7 @@ ExExeUtilGetMetadataInfoTcb::ExExeUtilGetMetadataInfoTcb(
   patternStr_ = new(glob->getDefaultHeap()) char[1000];
 
   numOutputEntries_ = 0;
+  returnRowCount_ = 0;
 }
 
 ExExeUtilGetMetadataInfoTcb::~ExExeUtilGetMetadataInfoTcb()
@@ -1818,11 +1819,8 @@ short ExExeUtilGetMetadataInfoTcb::work()
 {
   short retcode = 0;
   Lng32 cliRC = 0;
-  Lng32 returnRowCount=0;
-  char returnMsg[256];
   ex_expr::exp_return_type exprRetCode = ex_expr::EXPR_OK;
 
-  memset(returnMsg, 0, 256);
 
   // if no parent request, return
   if (qparent_.down->isEmpty())
@@ -3188,7 +3186,7 @@ short ExExeUtilGetMetadataInfoTcb::work()
             }
 
            infoList_->advance();
-            returnRowCount++;
+            incReturnRowCount();
          }
        break;
 
@@ -3351,7 +3349,9 @@ short ExExeUtilGetMetadataInfoTcb::work()
             if (NOT getMItdb().noHeader())
             {
               short rc = 0;
-              sprintf(returnMsg, "\n=======================\nSummary info of 
get:\nGet %d rows.", returnRowCount);
+              char returnMsg[256];
+              memset(returnMsg, 0, 256);
+              sprintf(returnMsg, "\n=======================\nSummary info of 
get:\nGet %d rows.", getReturnRowCount());
               moveRowToUpQueue(returnMsg, strlen(returnMsg), &rc);
               moveRowToUpQueue(" ");
             }
@@ -3891,6 +3891,7 @@ short ExExeUtilGetMetadataInfoComplexTcb::work()
              moveRowToUpQueue(" ", 0, &rc);
 
            infoList_->advance();
+            incReturnRowCount();
          }
        break;
 
@@ -3906,6 +3907,15 @@ short ExExeUtilGetMetadataInfoComplexTcb::work()
 
        case DONE_:
          {
+            if (NOT getMItdb().noHeader())
+            {
+              short rc = 0;
+              char returnMsg[256];
+              memset(returnMsg, 0, 256);
+              sprintf(returnMsg, "\n=======================\nSummary info of 
get:\nGet %d rows.", getReturnRowCount());
+              moveRowToUpQueue(returnMsg, strlen(returnMsg), &rc);
+              moveRowToUpQueue(" ");
+            }
            retcode = handleDone();
            if (retcode == 1)
              return WORK_OK;
@@ -4741,6 +4751,7 @@ short ExExeUtilGetHiveMetadataInfoTcb::work()
             }
 
            infoList_->advance();
+            incReturnRowCount();
          }
          break;
 

Reply via email to