Changes to take care of closing internal cursor statement when extract 
operation is done and the exact length of data is passed in to be extracted.


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

Branch: refs/heads/master
Commit: 89576f3dc7f5e37977ec3cdd9f0fd5ecadee0d36
Parents: d538162
Author: Sandhya Sundaresan <sand...@apache.org>
Authored: Tue Aug 22 17:38:42 2017 +0000
Committer: Sandhya Sundaresan <sand...@apache.org>
Committed: Tue Aug 22 17:38:42 2017 +0000

----------------------------------------------------------------------
 core/sql/executor/ExExeUtil.h       |  2 +-
 core/sql/executor/ExExeUtilLoad.cpp | 26 ++------------------------
 core/sql/exp/ExpLOBaccess.cpp       | 11 +++++++++--
 3 files changed, 12 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/89576f3d/core/sql/executor/ExExeUtil.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtil.h b/core/sql/executor/ExExeUtil.h
index 51695c6..1ca9c97 100644
--- a/core/sql/executor/ExExeUtil.h
+++ b/core/sql/executor/ExExeUtil.h
@@ -2978,7 +2978,7 @@ public:
   char * lobData2_;
   Int64 lobDataSpecifiedExtractLen_;
   Int64 lobDataLen_;
-  Lng32 remainingBytes_;
+  Int64 remainingBytes_;
   Lng32 currPos_;
   Lng32 numChildRows_;
   Int64 requestTag_;

http://git-wip-us.apache.org/repos/asf/trafodion/blob/89576f3d/core/sql/executor/ExExeUtilLoad.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilLoad.cpp 
b/core/sql/executor/ExExeUtilLoad.cpp
index dfbbac4..45a15e5 100644
--- a/core/sql/executor/ExExeUtilLoad.cpp
+++ b/core/sql/executor/ExExeUtilLoad.cpp
@@ -3246,7 +3246,7 @@ short ExExeUtilLobExtractTcb::work()
                break;
              }
 
-           remainingBytes_ = (Lng32)lobDataOutputLen;
+           remainingBytes_ = lobDataOutputLen;
            currPos_ = 0;
 
             
@@ -3309,33 +3309,11 @@ short ExExeUtilLobExtractTcb::work()
                                getLobErrStr(intParam1));
                step_ = HANDLE_ERROR_;
                break;
-             }
+             } 
            step_ = DONE_;
          }
          break;
 
-
-       case RETURN_STRING_:
-         {
-           if (qparent_.up->isFull())
-             return WORK_OK;
-
-           Lng32 size = MINOF((Lng32)lobTdb().dataExtractSizeIOAddr(), 
(Lng32)remainingBytes_);
-
-           moveRowToUpQueue(&lobData_[currPos_], size);
-
-           remainingBytes_ -= size;
-           currPos_ += size;
-
-           if (remainingBytes_ <= 0)
-             {
-               step_ = READ_CURSOR_;
-               qparent_.down->removeHead();
-             }
-
-           return WORK_RESCHEDULE_AND_RETURN;
-         }
-         break;
    
        case RETURN_STATUS_:
          {

http://git-wip-us.apache.org/repos/asf/trafodion/blob/89576f3d/core/sql/exp/ExpLOBaccess.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpLOBaccess.cpp b/core/sql/exp/ExpLOBaccess.cpp
index 3764752..9478c64 100644
--- a/core/sql/exp/ExpLOBaccess.cpp
+++ b/core/sql/exp/ExpLOBaccess.cpp
@@ -1949,7 +1949,7 @@ Ex_Lob_Error ExLob::readCursorData(char *tgt, Int64 
tgtSize, cursor_t &cursor, I
    char logBuf[4096];
    lobDebugInfo("In ExLob::readCursorData",0,__LINE__,lobTrace_);
 
-   while ( (operLen < tgtSize) && !cursor.eod_ )
+   while ( (operLen <= tgtSize) && !cursor.eod_ )
    {
     
       if (cursor.bytesRead_ == cursor.descSize_) // time to read next chunck
@@ -1970,7 +1970,14 @@ Ex_Lob_Error ExLob::readCursorData(char *tgt, Int64 
tgtSize, cursor_t &cursor, I
               continue;
          }
       }
-      
+      if (operLen == tgtSize)
+        {
+          //The cursor still has data available but wait until redrive since
+          //we have fetched all the data for this extract operation
+          hdfsCloseFile(fs_, fdData_);
+          fdData_ = NULL;
+          return LOB_OPER_OK;
+        }
       bytesAvailable = cursor.descSize_ - cursor.bytesRead_;
       bytesToCopy = min(bytesAvailable, tgtSize - operLen);
       offset = cursor.descOffset_ + cursor.bytesRead_;

Reply via email to