Repository: trafodion
Updated Branches:
  refs/heads/master 1ecac0ae7 -> 6bd356468


[TRAFODION-3175] enhance ExeCliInterface get interface to return null indicator


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

Branch: refs/heads/master
Commit: e2a4b805dbac396d9892fe696b1b60307f04ec1e
Parents: 5e8bfc7
Author: Liu Ming <[email protected]>
Authored: Sat Aug 11 13:03:47 2018 +0000
Committer: Liu Ming <[email protected]>
Committed: Sat Aug 11 13:03:47 2018 +0000

----------------------------------------------------------------------
 core/sql/executor/ExExeUtilCli.cpp | 58 ++++++++++++++++++++-------------
 1 file changed, 35 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/e2a4b805/core/sql/executor/ExExeUtilCli.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilCli.cpp 
b/core/sql/executor/ExExeUtilCli.cpp
index 2a0b9e1..8a47f4d 100644
--- a/core/sql/executor/ExExeUtilCli.cpp
+++ b/core/sql/executor/ExExeUtilCli.cpp
@@ -46,6 +46,8 @@ OutputInfo::OutputInfo(Lng32 numEntries)
   : numEntries_(numEntries)
 {
   
+   ex_assert( numEntries <= MAX_OUTPUT_ENTRIES, "try to fetch more than max 
rows allowed");
+  
    for (Int32 i = 0; i < numEntries_; i++)
     {
       data_[i] = NULL;
@@ -108,7 +110,8 @@ void OutputInfo::dealloc(CollHeap * heap)
 {
   for (Int32 i = 0; i < numEntries_; i++)
     {
-      NADELETEBASIC(data_[i], heap);
+      if(data_[i] != NULL)
+        NADELETEBASIC(data_[i], heap);
     }
 }
 
@@ -1296,33 +1299,42 @@ short ExeCliInterface::fetchAllRows(Queue * &infoList,
        
        for (Int32 j = 0; j < numOutputEntries; j++)
        {
-         char * ptr;
+         char * ptr, *r;
          Lng32   len;
           Lng32   type;
+          short nulind=0;
+          short *indaddr=&nulind;
+          short **ind;
           getAttributes(j+1, FALSE, type, len, NULL, NULL);
-         getPtrAndLen(j+1, ptr, len);
-         NABoolean nullTerminate = 
+         getPtrAndLen(j+1, ptr, len, ind);
+          if( ((char*)*ind)[0] == -1 ) // NULL value
+          {
+            oi->insert(j, NULL, 0, type);
+          }
+          else
+          {
+           NABoolean nullTerminate = 
            DFS2REC::is8bitCharacter(outputAttrs_[j].fsDatatype_);
 
-         char * r = new(getHeap()) char
-           [(varcharFormat ? SQL_VARCHAR_HDR_SIZE : 0) 
-            + len + (nullTerminate ? 1 : 0)];
-         if (varcharFormat)
-         {
-           *(short*)r = (short)len;
-           str_cpy_all(&r[SQL_VARCHAR_HDR_SIZE], ptr, len);
-
-           if (nullTerminate)
-             r[SQL_VARCHAR_HDR_SIZE + len] = 0;
-         }
-         else
-         {
-           str_cpy_all(r, ptr, len);
-           
-           if (nullTerminate)
-             r[len] = 0;
-         }
-         oi->insert(j, r, len, type);
+           r = new(getHeap()) char
+             [(varcharFormat ? SQL_VARCHAR_HDR_SIZE : 0) 
+              + len + (nullTerminate ? 1 : 0)];
+           if (varcharFormat)
+           {
+             *(short*)r = (short)len;
+             str_cpy_all(&r[SQL_VARCHAR_HDR_SIZE], ptr, len);
+
+             if (nullTerminate)
+               r[SQL_VARCHAR_HDR_SIZE + len] = 0;
+           }
+           else
+           {
+             str_cpy_all(r, ptr, len);
+             if (nullTerminate)
+               r[len] = 0;
+           }
+           oi->insert(j, r, len, type);
+           }
        }
        
        infoList->insert(oi);

Reply via email to