trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sand...@apache.org
Subject [04/10] incubator-trafodion git commit: Changes to support new syntax and implementation empty_blob/empty_clob for insert/updates Changes to support new syntax for updating a lob directly through a lobhandle without scanning the table.This is done via
Date Wed, 04 Jan 2017 23:06:44 GMT
Changes to support new syntax and implementation empty_blob/empty_clob for insert/updates
Changes to support new syntax for  updating a lob directly through a lobhandle without scanning the table.This is done via  new ExeUtil operator.
Changes to add columnname info to LOBMD_ table. This helps in mapping any given lobhandle back to the table and the column.
Added new sections to the regression test executor/TEST130 to test these changes


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

Branch: refs/heads/master
Commit: 7baf325f3fd612125f49b6f6763e6e895ba52d58
Parents: 34772bc
Author: Sandhya Sundaresan <sandhya@apache.org>
Authored: Wed Dec 21 19:04:25 2016 +0000
Committer: Sandhya Sundaresan <sandhya@apache.org>
Committed: Wed Dec 21 19:04:25 2016 +0000

----------------------------------------------------------------------
 core/sql/bin/clitest.cpp                   |  97 ++++-
 core/sql/cli/Cli.cpp                       |  85 ++--
 core/sql/cli/Cli.h                         |   1 +
 core/sql/cli/CliExtern.cpp                 |   2 +
 core/sql/cli/sqlcli.h                      |   3 +-
 core/sql/clitest/blobtest.cpp              | 104 +++++
 core/sql/clitest/blobtest.h                |   3 +
 core/sql/comexe/ComTdb.h                   |   1 +
 core/sql/comexe/ComTdbExeUtil.cpp          |  82 +++-
 core/sql/comexe/ComTdbExeUtil.h            | 115 +++++-
 core/sql/comexe/ComTdbRoot.h               |   3 +-
 core/sql/common/ComSmallDefs.h             |   3 +-
 core/sql/executor/ExComTdb.cpp             |   7 +
 core/sql/executor/ExExeUtil.h              |  88 ++++-
 core/sql/executor/ExExeUtilLoad.cpp        | 498 +++++++++++++++++++++++-
 core/sql/executor/ExHdfsScan.cpp           |   2 +-
 core/sql/exp/ExpLOB.cpp                    | 123 +++++-
 core/sql/exp/ExpLOB.h                      |  14 +-
 core/sql/exp/ExpLOBaccess.cpp              |  58 ++-
 core/sql/exp/ExpLOBenums.h                 |   2 +
 core/sql/exp/ExpLOBexternal.h              |   1 +
 core/sql/generator/GenItemFunc.cpp         |   4 +
 core/sql/generator/GenPreCode.cpp          |  44 ++-
 core/sql/generator/GenRelExeUtil.cpp       | 179 +++++++++
 core/sql/generator/GenRelMisc.cpp          |   5 +
 core/sql/optimizer/BindItemExpr.cpp        | 106 ++---
 core/sql/optimizer/ItemExpr.cpp            |  10 +-
 core/sql/optimizer/ItemFunc.h              |  12 +-
 core/sql/optimizer/NATable.cpp             |   5 +-
 core/sql/optimizer/RelExeUtil.cpp          |  92 +++++
 core/sql/optimizer/RelExeUtil.h            |  81 +++-
 core/sql/optimizer/SynthType.cpp           |  63 ++-
 core/sql/parser/ParKeyWords.cpp            |   6 +-
 core/sql/parser/sqlparser.y                | 108 ++++-
 core/sql/parser/ulexer.cpp                 |   7 +
 core/sql/regress/executor/EXPECTED130      | 303 +++++++++++---
 core/sql/regress/executor/TEST015          |   2 +-
 core/sql/regress/executor/TEST130          |  57 ++-
 core/sql/regress/executor/TEST130_argfile3 |   3 +
 core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp  |   1 +
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp    |   8 +-
 41 files changed, 2164 insertions(+), 224 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/bin/clitest.cpp
----------------------------------------------------------------------
diff --git a/core/sql/bin/clitest.cpp b/core/sql/bin/clitest.cpp
index 360dadb..bdb8a56 100644
--- a/core/sql/bin/clitest.cpp
+++ b/core/sql/bin/clitest.cpp
@@ -82,7 +82,9 @@ int main(int argc, const char * argv[])
       cout << "Blob test to insert to lob column   3     "<< endl;
       cout << "Blob test to update lob column      4     "<< endl;
       cout << "Blob test to append to lob column   5      "<< endl;
-
+      cout << "Blob test to update to lob lobhandle   6   "<< endl;
+      cout << "Blob test to append to lobhandle   7      "<< endl;
+      cout << "Blob test to truncate to lobhandle   8      "<< endl;
       return 0;
     }
   Int32 retcode = 0;
@@ -258,7 +260,98 @@ int main(int argc, const char * argv[])
 	return retcode;
       }
       break;
-    }
+    case 6:
+      {
+	
+	cout <<"*************************************"  <<endl;
+	cout << "Blob test update  lobhandle from a buffer " << endl;
+	cout << "Input lob table name :" << endl;
+	cin.getline(tablename,40);
+	cout << "Table name : " << tablename << endl;
+	cout << "Input lob column name to get handle from :" << endl;
+	cin.getline(columnname,40); 
+	cout << "Column Name : " << columnname << endl;
+
+        //extract lob handle
+      
+        char *lobHandle = new char[1024];
+        str_cpy_all(lobHandle," ",1024);
+        cout << "Extracting  lob handle for column " << columnname << "..." << endl;
+        retcode = extractLobHandle(cliGlob, lobHandle, (char *)columnname,tablename);
+        if (retcode)
+          {
+            cout << "extractLobHandle returned " << retcode <<endl;
+	
+            delete lobHandle;
+	  return retcode;
+          }
+        cout << "LOB handle for "<< columnname << ": " << lobHandle << endl;
+	retcode = updateBufferToLobHandle(cliGlob,lobHandle);
+	return retcode;
+      }
+      break;
+case 7:
+      {
+	
+	cout <<"*************************************"  <<endl;
+	cout << "Blob test append  lobhandle from a buffer " << endl;
+	cout << "Input lob table name :" << endl;
+	cin.getline(tablename,40);
+	cout << "Table name : " << tablename << endl;
+	cout << "Input lob column name to get handle from :" << endl;
+	cin.getline(columnname,40); 
+	cout << "Column Name : " << columnname << endl;
+
+        //extract lob handle
+      
+        char *lobHandle = new char[1024];
+        str_cpy_all(lobHandle," ",1024);
+        cout << "Extracting  lob handle for column " << columnname << "..." << endl;
+        retcode = extractLobHandle(cliGlob, lobHandle, (char *)columnname,tablename);
+        if (retcode)
+          {
+            cout << "extractLobHandle returned " << retcode <<endl;
+	
+            delete lobHandle;
+	  return retcode;
+          }
+        cout << "LOB handle for "<< columnname << ": " << lobHandle << endl;
+	retcode = updateAppendBufferToLobHandle(cliGlob,lobHandle);
+	return retcode;
+      }
+      break;
+case 8:
+      {
+	
+	cout <<"*************************************"  <<endl;
+	cout << "Blob test empty  lobhandle from a buffer " << endl;
+	cout << "Input lob table name :" << endl;
+	cin.getline(tablename,40);
+	cout << "Table name : " << tablename << endl;
+	cout << "Input lob column name to get handle from :" << endl;
+	cin.getline(columnname,40); 
+	cout << "Column Name : " << columnname << endl;
+
+        //extract lob handle
+      
+        char *lobHandle = new char[1024];
+        str_cpy_all(lobHandle," ",1024);
+        cout << "Extracting  lob handle for column " << columnname << "..." << endl;
+        retcode = extractLobHandle(cliGlob, lobHandle, (char *)columnname,tablename);
+        if (retcode)
+          {
+            cout << "extractLobHandle returned " << retcode <<endl;
+	
+            delete lobHandle;
+	  return retcode;
+          }
+        cout << "LOB handle for "<< columnname << ": " << lobHandle << endl;
+	retcode = updateTruncateLobHandle(cliGlob,lobHandle);
+	return retcode;
+      }
+      break;
+
+    }//end switch
   
   return 0;
   

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/cli/Cli.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/Cli.cpp b/core/sql/cli/Cli.cpp
index ac8d454..5a0950b 100644
--- a/core/sql/cli/Cli.cpp
+++ b/core/sql/cli/Cli.cpp
@@ -9709,40 +9709,41 @@ Lng32 SQLCLI_LOBcliInterface
 	    goto error_return;
 	  }
 
-	// insert into lob descriptor chunks table
-	if (blackBox && (blackBoxLen && (*blackBoxLen > 0)))
-	  {
+        
+        // insert into lob descriptor chunks table
+        if (blackBox && (blackBoxLen && (*blackBoxLen > 0)))
+          {
             //blackBox points to external file name
-	    str_sprintf(query, "insert into table(ghost table %s) values (%Ld, %Ld, 1, %Ld, %Ld, '%s')",
-			lobDescChunksName, descPartnKey, descSyskey,
-			(dataLen ? *dataLen : 0),
-			(dataOffset ? *dataOffset : 0),
-			blackBox);
+            str_sprintf(query, "insert into table(ghost table %s) values (%Ld, %Ld, 1, %Ld, %Ld, '%s')",
+                        lobDescChunksName, descPartnKey, descSyskey,
+                        (dataLen ? *dataLen : 0),
+                        (dataOffset ? *dataOffset : 0),
+                        blackBox);
             lobDebugInfo(query,0,__LINE__,lobTrace);
-	  }
-	else
-	  {
-	    str_sprintf(query, "insert into table(ghost table %s) values (%Ld, %Ld, 1, %Ld, %Ld, NULL)",
-			lobDescChunksName, descPartnKey, descSyskey,
-			(dataLen ? *dataLen : 0),
-			(dataOffset ? *dataOffset : 0));
+          }
+        else
+          {
+            str_sprintf(query, "insert into table(ghost table %s) values (%Ld, %Ld, 1, %Ld, %Ld, NULL)",
+                        lobDescChunksName, descPartnKey, descSyskey,
+                        (dataLen ? *dataLen : 0),
+                        (dataOffset ? *dataOffset : 0));
             lobDebugInfo(query,0,__LINE__,lobTrace);
-	  }
+          }
 
-	// set parserflags to allow ghost table
-	currContext.setSqlParserFlags(0x1);
+        // set parserflags to allow ghost table
+        currContext.setSqlParserFlags(0x1);
 	
-	cliRC = cliInterface->executeImmediate(query);
+        cliRC = cliInterface->executeImmediate(query);
 
-	currContext.resetSqlParserFlags(0x1);
+        currContext.resetSqlParserFlags(0x1);
 
-	if (cliRC < 0)
-	  {
-	    cliInterface->retrieveSQLDiagnostics(myDiags);
+        if (cliRC < 0)
+          {
+            cliInterface->retrieveSQLDiagnostics(myDiags);
 	    
-	    goto error_return;
-	  }
-
+            goto error_return;
+          }
+        
 	if (inoutDescPartnKey)
 	  *inoutDescPartnKey = descPartnKey;
 
@@ -10121,6 +10122,23 @@ Lng32 SQLCLI_LOBcliInterface
 	    if (inoutDescSyskey)
 	      *inoutDescSyskey = inDescSyskey;
 	  }
+        else
+          {
+            if (cliRC == 100)
+              {
+                if (dataLen)
+                  *dataLen = 0;
+                if (dataOffset)
+                  *dataOffset = 0;
+                if (blackBoxLen)
+                  *blackBoxLen = 0;
+                if (inoutDescPartnKey)
+                  *inoutDescPartnKey = descPartnKey;
+
+                if (inoutDescSyskey)
+                  *inoutDescSyskey = inDescSyskey;
+              }
+          }
 	//	else
 	//cliRC = -100;
 
@@ -10642,6 +10660,7 @@ Lng32 SQLCLI_LOBddlInterface
  /*IN*/     short *lobNumList,
  /*IN*/     short *lobTypList,
  /*IN*/     char* *lobLocList,
+/*IN*/      char* *lobColNameList,
  /*IN*/     char *hdfsServer,
  /*IN*/     Int32 hdfsPort,
 /*IN*/    Int64 lobMaxSize,
@@ -10678,7 +10697,7 @@ Lng32 SQLCLI_LOBddlInterface
     case LOB_CLI_CREATE:
       {
 	// create lob metadata table
-	str_sprintf(query, "create ghost table %s (lobnum smallint not null, storagetype smallint not null, location varchar(4096) not null, primary key (lobnum)) ",lobMDName);
+	str_sprintf(query, "create ghost table %s (lobnum smallint not null, storagetype smallint not null, location varchar(4096) not null, column_name varchar(256 bytes) character set utf8, primary key (lobnum)) ",lobMDName);
 	 lobDebugInfo(query,0,__LINE__,lobTrace);
 
 	// set parserflags to allow ghost table
@@ -10697,9 +10716,9 @@ Lng32 SQLCLI_LOBddlInterface
 	// populate the lob metadata table
 	for (Lng32 i = 0; i < numLOBs; i++)
 	  {
-	    str_sprintf(query, "insert into table (ghost table %s) values (%d, %d, '%s')",
+	    str_sprintf(query, "insert into table (ghost table %s) values (%d, %d, '%s','%s')",
 			lobMDName, 
-			lobNumList[i], lobTypList[i], lobLocList[i]);
+			lobNumList[i], lobTypList[i], lobLocList[i],lobColNameList[i]);
             lobDebugInfo(query,0,__LINE__,lobTrace);
 
 	    // set parserflags to allow ghost table
@@ -10925,11 +10944,11 @@ Lng32 SQLCLI_LOBddlInterface
     case LOB_CLI_SELECT_UNIQUE:
        {
 	 if (qType == LOB_CLI_SELECT_CURSOR)
-	   str_sprintf(query, "select lobnum, storagetype, location from table(ghost table %s) order by lobnum for read uncommitted access",
+	   str_sprintf(query, "select lobnum, storagetype, location,column_name from table(ghost table %s) order by lobnum for read uncommitted access",
 		       lobMDName);
          
 	 else
-	   str_sprintf(query, "select lobnum, storagetype, location from table(ghost table %s) where lobnum = %d for read uncommitted access",
+	   str_sprintf(query, "select lobnum, storagetype, location ,column_name from table(ghost table %s) where lobnum = %d for read uncommitted access",
 		       lobMDName, numLOBs);
          lobDebugInfo(query,0,__LINE__,lobTrace);
 
@@ -10979,7 +10998,9 @@ Lng32 SQLCLI_LOBddlInterface
 
 		cliInterface->getPtrAndLen(3, ptr, len);
 		str_cpy_and_null(lobLocList[j], ptr, len, '\0', ' ', TRUE);
-
+	
+                cliInterface->getPtrAndLen(4, ptr, len);
+		str_cpy_and_null(lobColNameList[j], ptr, len, '\0', ' ', TRUE);
 		j++;
 
 		if ((qType == LOB_CLI_SELECT_UNIQUE) &&

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/cli/Cli.h
----------------------------------------------------------------------
diff --git a/core/sql/cli/Cli.h b/core/sql/cli/Cli.h
index 594df3d..ae322d5 100644
--- a/core/sql/cli/Cli.h
+++ b/core/sql/cli/Cli.h
@@ -941,6 +941,7 @@ Lng32 SQLCLI_LOBddlInterface
  /*IN*/     short *lobNumList,
  /*IN*/     short *lobTypList,
  /*IN*/     char* *lobLocList,
+ /*IN*/     char* *lobColNameList,
  /*IN*/    char *hdfsServer,
  /*IN*/    Int32 hdfsPort,
  /*IN*/     Int64 lobMaxSize,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/cli/CliExtern.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/CliExtern.cpp b/core/sql/cli/CliExtern.cpp
index 0c7f423..95ed04b 100644
--- a/core/sql/cli/CliExtern.cpp
+++ b/core/sql/cli/CliExtern.cpp
@@ -7523,6 +7523,7 @@ Lng32 SQL_EXEC_LOBddlInterface
  /*IN*/     short *lobNumList,
  /*IN*/     short *lobTypList,
  /*IN*/     char* *lobLocList,
+ /*IN*/     char* *lobColNameList,
  /*IN*/     char *hdfsServer,
  /*IN*/     Int32 hdfsPort,
  /*IN */    Int64 lobMaxSize,
@@ -7547,6 +7548,7 @@ Lng32 SQL_EXEC_LOBddlInterface
 				      lobNumList,
 				      lobTypList,
 				       lobLocList,
+                                       lobColNameList,
                                        hdfsServer,
                                        hdfsPort, 
                                        lobMaxSize,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/cli/sqlcli.h
----------------------------------------------------------------------
diff --git a/core/sql/cli/sqlcli.h b/core/sql/cli/sqlcli.h
index 5ab95d9..79e31df 100644
--- a/core/sql/cli/sqlcli.h
+++ b/core/sql/cli/sqlcli.h
@@ -851,7 +851,8 @@ enum SQLATTR_SUBQUERY_TYPE
   SQL_STMT_HBASE_LOAD = 6,
   SQL_STMT_HBASE_UNLOAD = 7,
   /* Used to denote lob access */
-  SQL_LOB_EXTRACT = 8
+  SQL_LOB_EXTRACT = 8,
+  SQL_LOB_UPDATE_UTIL = 9
 };
 
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/clitest/blobtest.cpp
----------------------------------------------------------------------
diff --git a/core/sql/clitest/blobtest.cpp b/core/sql/clitest/blobtest.cpp
index 5bcba01..2df98f2 100644
--- a/core/sql/clitest/blobtest.cpp
+++ b/core/sql/clitest/blobtest.cpp
@@ -267,3 +267,107 @@ Int32 updateAppendBufferToLob(CliGlobals *cliglob, char *tableName, char *column
   return retcode;
 
 }
+
+
+Int32 updateBufferToLobHandle(CliGlobals *cliglob,char *handle)
+{
+  Int32 retcode = 0;
+  ExeCliInterface cliInterface((cliglob->currContext())->exHeap(), (Int32)SQLCHARSETCODE_UTF8, cliglob->currContext(),NULL);
+  // update lob data into via a buffer.
+  char * query = new char [500];
+  
+ 
+  char statusBuf[200] = {'\0'};
+  Int32 statusBufLen = 0;
+  Int64 lobUpdateLen = 10;
+  char *lobDataBuf = new char[lobUpdateLen];
+  memcpy(lobDataBuf, "zzzzzzzzzzzzzzzzzzzz",20);
+  str_sprintf(query,"update lob (LOB '%s' , LOCATION %Ld, SIZE %Ld)", handle, (Int64)lobDataBuf, lobUpdateLen);
+ 
+ 
+  retcode = cliInterface.executeImmediate(query);
+  if (retcode <0)
+    {
+      cliInterface.executeImmediate("rollback work");
+      delete query;
+      delete lobDataBuf;
+      return retcode;
+    }
+
+  retcode = cliInterface.executeImmediate("commit work");
+  delete query;
+  delete lobDataBuf;
+    
+
+  return retcode;
+
+}
+
+Int32 updateAppendBufferToLobHandle(CliGlobals *cliglob,char *handle)
+{
+  Int32 retcode = 0;
+  ExeCliInterface cliInterface((cliglob->currContext())->exHeap(), (Int32)SQLCHARSETCODE_UTF8, cliglob->currContext(),NULL);
+  // update lob data into via a buffer.
+  char * query = new char [500];
+  
+ 
+  char statusBuf[200] = {'\0'};
+  Int32 statusBufLen = 0;
+  Int64 lobUpdateLen = 10;
+  char *lobDataBuf = new char[lobUpdateLen];
+  memcpy(lobDataBuf, "zzzzzzzzzzzzzzzzzzzz",20);
+  str_sprintf(query,"update lob (LOB '%s' , LOCATION %Ld, SIZE %Ld,append )", handle, (Int64)lobDataBuf, lobUpdateLen);
+ 
+ 
+  retcode = cliInterface.executeImmediate(query);
+  if (retcode <0)
+    {
+      cliInterface.executeImmediate("rollback work");
+      delete query;
+      delete lobDataBuf;
+      return retcode;
+    }
+
+  retcode = cliInterface.executeImmediate("commit work");
+  delete query;
+  delete lobDataBuf;
+    
+
+  return retcode;
+
+}
+
+
+Int32 updateTruncateLobHandle(CliGlobals *cliglob,char *handle)
+{
+  Int32 retcode = 0;
+  ExeCliInterface cliInterface((cliglob->currContext())->exHeap(), (Int32)SQLCHARSETCODE_UTF8, cliglob->currContext(),NULL);
+  // update lob data into via a buffer.
+  char * query = new char [500];
+  
+ 
+  char statusBuf[200] = {'\0'};
+  Int32 statusBufLen = 0;
+  Int64 lobUpdateLen = 10;
+  char *lobDataBuf = new char[lobUpdateLen];
+  memcpy(lobDataBuf, "zzzzzzzzzzzzzzzzzzzz",20);
+  str_sprintf(query,"update lob (LOB '%s' , empty_blob())", handle, (Int64)lobDataBuf, lobUpdateLen);
+ 
+ 
+  retcode = cliInterface.executeImmediate(query);
+  if (retcode <0)
+    {
+      cliInterface.executeImmediate("rollback work");
+      delete query;
+      delete lobDataBuf;
+      return retcode;
+    }
+
+  retcode = cliInterface.executeImmediate("commit work");
+  delete query;
+  delete lobDataBuf;
+    
+
+  return retcode;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/clitest/blobtest.h
----------------------------------------------------------------------
diff --git a/core/sql/clitest/blobtest.h b/core/sql/clitest/blobtest.h
index 4faa4b3..65b53c0 100644
--- a/core/sql/clitest/blobtest.h
+++ b/core/sql/clitest/blobtest.h
@@ -74,3 +74,6 @@ Int32 extractLobToFileInChunks(CliGlobals *cliglob, char * lobHandle, char *file
 Int32 insertBufferToLob(CliGlobals *cliglob,char *tbaleName);
 Int32 updateBufferToLob(CliGlobals *cliglob, char *tableName, char *columnName);
 Int32 updateAppendBufferToLob(CliGlobals *cliGlob, char *tableName, char *columnName);
+Int32 updateBufferToLobHandle(CliGlobals *cliglob,  char *handle);
+Int32 updateTruncateLobHandle(CliGlobals *cliglob,  char *handle);
+Int32 updateAppendBufferToLobHandle(CliGlobals *cliglob,  char *handle);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/comexe/ComTdb.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdb.h b/core/sql/comexe/ComTdb.h
index 6e803d5..fe6a29b 100644
--- a/core/sql/comexe/ComTdb.h
+++ b/core/sql/comexe/ComTdb.h
@@ -321,6 +321,7 @@ public:
     ex_DDL_WITH_STATUS = 151,
     ex_GET_QID = 152,
     ex_HIVE_TRUNCATE = 153,
+    ex_LOB_UPDATE_UTIL = 154,
     ex_LAST = 9999              // not used
   };
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/comexe/ComTdbExeUtil.cpp
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdbExeUtil.cpp b/core/sql/comexe/ComTdbExeUtil.cpp
index d4b4c23..7b4e27b 100644
--- a/core/sql/comexe/ComTdbExeUtil.cpp
+++ b/core/sql/comexe/ComTdbExeUtil.cpp
@@ -2417,8 +2417,88 @@ void ComTdbExeUtilLobExtract::displayContents(Space * space,ULng32 flag)
       displayChildren(space,flag);
     }
 }
+///////////////////////////////////////////////////////////////////////////
+//
+// Methods for class ComTdbExeUtilLobUpdate
+//
+///////////////////////////////////////////////////////////////////////////
+ComTdbExeUtilLobUpdate::ComTdbExeUtilLobUpdate
+(
+     char * handle,
+     Lng32 handleLen,
+     UpdateFromType fromType,
+     Int64 bufAddr,
+     Int64 updateSize,
+     Int32 lobStorageType,
+     char * lobHdfsServer,
+     Lng32 lobHdfsPort,
+     ex_expr * input_expr,
+     ULng32 input_rowlen,
+     ex_cri_desc * work_cri_desc,
+     const unsigned short work_atp_index,
+     ex_cri_desc * given_cri_desc,
+     ex_cri_desc * returned_cri_desc,
+     queue_index down,
+     queue_index up,
+     Lng32 num_buffers,
+     ULng32 buffer_size)
+  : ComTdbExeUtil(ComTdbExeUtil::LOB_UPDATE_UTIL_,
+                   NULL, 0, (Int16)SQLCHARSETCODE_UNKNOWN,
+                   NULL, 0,
+                   input_expr, input_rowlen,
+                   NULL, 0,
+                   NULL,
+                   work_cri_desc, work_atp_index,
+                   given_cri_desc, returned_cri_desc,
+                   down, up, 
+                   num_buffers, buffer_size),
+     handle_(handle),
+     handleLen_(handleLen),
+     fromType_((short)fromType),
+     bufAddr_(bufAddr),
+     updateSize_(updateSize),
+     lobStorageType_(lobStorageType),
+     lobHdfsServer_(lobHdfsServer),
+     lobHdfsPort_(lobHdfsPort),
+     totalBufSize_(0),
+     flags_(0)
+{
+  setNodeType(ComTdb::ex_LOB_UPDATE_UTIL);
+}
+Long ComTdbExeUtilLobUpdate::pack(void * space)
+{
+  if (handle_)
+    handle_.pack(space);
+  if (lobHdfsServer_)
+    lobHdfsServer_.pack(space);
+  return ComTdbExeUtil::pack(space);
+}
+Lng32 ComTdbExeUtilLobUpdate::unpack(void * base, void * reallocator)
+{
+  if (handle_.unpack(base))
+    return -1;
+  if (lobHdfsServer_.unpack(base))
+    return -1;
+ return ComTdbExeUtil::unpack(base, reallocator);
+}
 
-
+void ComTdbExeUtilLobUpdate::displayContents(Space * space,ULng32 flag)
+{
+  ComTdb::displayContents(space,flag & 0xFFFFFFFE);
+  
+  if(flag & 0x00000008)
+    {
+      char buf[100];
+      str_sprintf(buf, "\nFor ComTdbExeUtilLobUpdate :");
+      space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));
+    }
+  
+  if (flag & 0x00000001)
+    {
+      displayExpression(space,flag);
+      displayChildren(space,flag);
+    }
+}
 ///////////////////////////////////////////////////////////////////////////
 //
 // Methods for class ComTdbExeUtilLobShowddl

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/comexe/ComTdbExeUtil.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdbExeUtil.h b/core/sql/comexe/ComTdbExeUtil.h
index 61df851..cedb10b 100644
--- a/core/sql/comexe/ComTdbExeUtil.h
+++ b/core/sql/comexe/ComTdbExeUtil.h
@@ -90,7 +90,8 @@ public:
     HBASE_UNLOAD_            = 33,
     HBASE_UNLOAD_TASK_       = 34,
     GET_QID_                 = 35,
-    HIVE_TRUNCATE_           = 36
+    HIVE_TRUNCATE_           = 36,
+    LOB_UPDATE_UTIL_         = 37
   };
 
   ComTdbExeUtil()
@@ -2861,6 +2862,118 @@ private:
   char fillersComTdbExeUtilLobExtract_[40];            
 };
 
+
+class ComTdbExeUtilLobUpdate : public ComTdbExeUtil
+{
+   friend class ExExeUtilLobUpdateTcb;
+   friend class ExExeUtilPrivateState;
+
+public:
+  enum UpdateFromType
+  {
+    FROM_BUFFER_, FROM_STRING_, FROM_EXTERNAL_,NOOP_
+  };
+ 
+
+  ComTdbExeUtilLobUpdate()
+  : ComTdbExeUtil()
+  {}
+  ComTdbExeUtilLobUpdate
+    (
+     char * handle,
+     Lng32 handleLen,
+     UpdateFromType fromType,
+     Int64 bufAddr,
+     Int64 updateSize,
+     Int32 lobStorageType,
+     char * lobHdfsServer,
+     Lng32 lobHdfsPort,
+     ex_expr * input_expr,
+     ULng32 input_rowlen,
+     ex_cri_desc * work_cri_desc,
+     const unsigned short work_atp_index,
+     ex_cri_desc * given_cri_desc,
+     ex_cri_desc * returned_cri_desc,
+     queue_index down,
+     queue_index up,
+     Lng32 num_buffers,
+     ULng32 buffer_size
+     );
+  Long pack(void * space);
+  Lng32 unpack(void * base, void * reallocator);
+
+  char * getHandle() { return handle_; }
+  Lng32 getHandleLen() { return handleLen_; }
+  char * getLobHdfsServer() { return lobHdfsServer_; }
+  Lng32 getLobHdfsPort() { return lobHdfsPort_; }
+
+  UpdateFromType getFromType() { return (UpdateFromType)fromType_; }
+ 
+  // ---------------------------------------------------------------------
+  // Redefine virtual functions required for Versioning.
+  //----------------------------------------------------------------------
+  virtual short getClassSize() {return (short)sizeof(ComTdbExeUtilLobUpdate);}
+
+  virtual const char *getNodeName() const
+  {
+    return "LOB_UPDATE_UTIL";
+  };
+
+  // ---------------------------------------------------------------------
+  // Used by the internal SHOWPLAN command to get attributes of a TDB.
+  // ---------------------------------------------------------------------
+  NA_EIDPROC void displayContents(Space *space, ULng32 flag);
+
+  void setAppend(NABoolean v)
+  {(v ? flags_ |= APPEND_ : flags_ &= ~APPEND_); };
+  NABoolean isAppend() { return (flags_ & APPEND_) != 0; };
+
+  void setErrorIfExists(NABoolean v)
+  {(v ? flags_ |= ERROR_IF_EXISTS_ : flags_ &= ~ERROR_IF_EXISTS_); };
+  NABoolean isErrorIfExists() { return (flags_ & ERROR_IF_EXISTS_) != 0; };
+
+  void setTruncate(NABoolean v)
+  {(v ? flags_ |= TRUNCATE_ : flags_ &= ~TRUNCATE_); };
+  NABoolean isTruncate() { return (flags_ & TRUNCATE_) != 0; };
+
+  void setReplace(NABoolean v)
+  {(v ? flags_ |= REPLACE_ : flags_ &= ~REPLACE_); };
+  NABoolean isReplace() { return (flags_ & REPLACE_) != 0; };
+  void setUpdateSize(Int64 upd_size){ updateSize_ = upd_size;};
+  Int64 updateSize() { return updateSize_;}
+  void setTotalBufSize(Int64 bufSize) { totalBufSize_ = bufSize;};
+  Int64 getTotalBufSize() { return totalBufSize_;};
+  void setBufAddr(Int64 bufAddr) {bufAddr_ = bufAddr;};
+  Int64 getBufAddr() { return bufAddr_;};
+ void setLobMaxSize(Int64 lms) {lobMaxSize_ = lms;};
+  Int64 getLobMaxSize() { return lobMaxSize_;};
+ void setLobMaxChunkSize(Int64 lmcs) {lobMaxChunkSize_ = lmcs;};
+  Int64 getLobMaxChunkSize() { return lobMaxChunkSize_;};
+ void setLobGCLimit(Int64 gcl ) {lobGCLimit_ = gcl;};
+  Int64 getLobGCLimit() { return lobGCLimit_;};
+private:
+  enum
+    {
+      ERROR_IF_EXISTS_ = 0x0001,
+      TRUNCATE_ = 0x0002,
+      APPEND_ = 0x0004,
+      REPLACE_=0x0008
+    };
+  NABasicPtr handle_;
+  Int32 handleLen_;
+  short fromType_;
+  Int32 flags_;
+  Int64 updateSize_;
+  Int64 totalBufSize_;
+  Int64 bufAddr_;
+  Lng32 lobStorageType_;
+  Lng32 lobHdfsPort_;
+  NABasicPtr lobHdfsServer_;
+  Int64 lobMaxSize_;
+  Int64 lobMaxChunkSize_;
+  Int64 lobGCLimit_;
+};
+ 
 class ComTdbExeUtilLobShowddl : public ComTdbExeUtil
 {
   friend class ExExeUtilLobShowddlTcb;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/comexe/ComTdbRoot.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdbRoot.h b/core/sql/comexe/ComTdbRoot.h
index 3f3b6ce..b1e4662 100644
--- a/core/sql/comexe/ComTdbRoot.h
+++ b/core/sql/comexe/ComTdbRoot.h
@@ -629,7 +629,8 @@ public:
     SQL_DISPLAY_EXPLAIN = 5,
     SQL_STMT_HBASE_LOAD = 6,
     SQL_STMT_HBASE_UNLOAD = 7,
-    SQL_STMT_LOB_EXTRACT = 8
+    SQL_STMT_LOB_EXTRACT = 8,
+    SQL_STMT_LOB_UPDATE_UTIL = 9
    };
   
   ComTdbRoot();

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/common/ComSmallDefs.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComSmallDefs.h b/core/sql/common/ComSmallDefs.h
index 10a37c3..0adb1e2 100644
--- a/core/sql/common/ComSmallDefs.h
+++ b/core/sql/common/ComSmallDefs.h
@@ -1758,7 +1758,8 @@ enum ComLobsStorage {
     Lob_InMemory_File = 7,
     Lob_External_HDFS_File = 8,
     Lob_External_HBASE_Table = 9,
-    Lob_External_Local_File = 10
+    Lob_External_Local_File = 10,
+    Lob_Empty = 11
 };
 
 // for the TRANSFORM utility - equivalent definitions in catapirequest.h

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/executor/ExComTdb.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExComTdb.cpp b/core/sql/executor/ExComTdb.cpp
index d6c0145..df54e7b 100644
--- a/core/sql/executor/ExComTdb.cpp
+++ b/core/sql/executor/ExComTdb.cpp
@@ -639,7 +639,14 @@ case ex_LOB_INFO:
 
       break;
     }
+  case ex_LOB_UPDATE_UTIL:
+    {
+#pragma nowarn(1506)   // warning elimination
+      GetVTblPtr(vtblptr,ExExeUtilLobUpdateTdb);
+#pragma warn(1506)  // warning elimination
 
+      break;
+    }
    case ex_LOB_SHOWDDL:
     {
 #pragma nowarn(1506)   // warning elimination

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/executor/ExExeUtil.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtil.h b/core/sql/executor/ExExeUtil.h
index f3fccb8..307d28a 100755
--- a/core/sql/executor/ExExeUtil.h
+++ b/core/sql/executor/ExExeUtil.h
@@ -2911,7 +2911,7 @@ public:
 			 ex_globals * glob = 0);
   
   virtual short work();
-
+  
   ExExeUtilLobExtractTdb & lobTdb() const
   {
     return (ExExeUtilLobExtractTdb &) tdb;
@@ -2969,8 +2969,92 @@ public:
   LOBglobals *lobGlobals_;
 };
 
+
+
+//////////////////////////////////////////////////////////////////////////
+// -----------------------------------------------------------------------
+// ExExeUtilLobUpdateTdb
+// -----------------------------------------------------------------------
+class ExExeUtilLobUpdateTdb : public ComTdbExeUtilLobUpdate
+{
+ public:
+
+  // ---------------------------------------------------------------------
+  // Constructor is only called to instantiate an object used for
+  // retrieval of the virtual table function pointer of the class while
+  // unpacking. An empty constructor is enough.
+  // ---------------------------------------------------------------------
+  NA_EIDPROC ExExeUtilLobUpdateTdb()
+    {}
+
+  NA_EIDPROC virtual ~ExExeUtilLobUpdateTdb()
+    {}
+
+
+  // ---------------------------------------------------------------------
+  // Build a TCB for this TDB. Redefined in the Executor project.
+  // ---------------------------------------------------------------------
+  NA_EIDPROC virtual ex_tcb *build(ex_globals *globals);
+private:
+};
+
+//////////////////////////////////////////////////////////////////////////
+// -----------------------------------------------------------------------
+// ExExeUtilLobUpdateTcb
+// -----------------------------------------------------------------------
+
+
+class ExExeUtilLobUpdateTcb : public ExExeUtilTcb
+{
+  friend class ExExeUtilLobUpdateTdb;
+  friend class ExExeUtilPrivateState;
+
+public:
+  // Constructor
+  ExExeUtilLobUpdateTcb(const ComTdbExeUtilLobUpdate & exe_util_tdb,
+			 const ex_tcb * child_tcb, 
+			 ex_globals * glob = 0);
+  
+  virtual short work();
+  
+  ExExeUtilLobUpdateTdb & lobTdb() const
+  {
+    return (ExExeUtilLobUpdateTdb &) tdb;
+  };
+  LOBglobals *getLobGlobals() { return lobGlobals_;}
+ protected:
+  enum Step
+    {
+      EMPTY_,
+      GET_HANDLE_,
+      UPDATE_LOB_DATA_,
+      EMPTY_LOB_DATA_,
+      APPEND_LOB_DATA_,
+      RETURN_STATUS_,
+      DONE_,
+      CANCEL_,
+      HANDLE_ERROR_,
+      CANCELLED_
+    };
+  Step step_;
+  Lng32 lobHandleLen_;
+  char  lobHandle_[2050];
+  char lobInputHandleBuf_[4096];
+  char lobNameBuf_[1024];
+  Lng32 lobNameLen_;
+  char * lobName_;
+  Lng32 lobType_;
+  char * lobData_;
+  Int64 lobDataLen_;
+  Int64 requestTag_;
+  char lobLoc_[1024];
+  ExLobStats lobStats_;
+  char statusString_[200];
+  fstream indata_;
+  LOBglobals *lobGlobals_;
+};
 // -----------------------------------------------------------------------
-// ExExeUtilFileExtractTcb
+// ExExeUtilFileUpdateTcb
 // -----------------------------------------------------------------------
 class ExExeUtilFileExtractTcb : public ExExeUtilLobExtractTcb
 {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/executor/ExExeUtilLoad.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilLoad.cpp b/core/sql/executor/ExExeUtilLoad.cpp
index d11f182..bd33663 100644
--- a/core/sql/executor/ExExeUtilLoad.cpp
+++ b/core/sql/executor/ExExeUtilLoad.cpp
@@ -2960,8 +2960,10 @@ short ExExeUtilLobExtractTcb::work()
 	    short *lobNumList = new (getHeap()) short[1];
 	    short *lobTypList = new (getHeap()) short[1];
 	    char  **lobLocList = new (getHeap()) char*[1];
+             char  **lobColNameList = new (getHeap()) char*[1];
 	    lobLocList[0] = new (getHeap()) char[1024];
-	    
+	    lobColNameList[0] = new (getHeap()) char[256];
+
 	    Lng32 numLobs = lobNum;
 	    Lng32 cliRC = SQL_EXEC_LOBddlInterface
 	      (
@@ -2972,7 +2974,7 @@ short ExExeUtilLobExtractTcb::work()
 	       LOB_CLI_SELECT_UNIQUE,
 	       lobNumList,
 	       lobTypList,
-	       lobLocList,lobTdb().getLobHdfsServer(),
+	       lobLocList,lobColNameList,lobTdb().getLobHdfsServer(),
                lobTdb().getLobHdfsPort(),0,FALSE);
 	    if (cliRC < 0)
 	      {
@@ -3052,7 +3054,6 @@ short ExExeUtilLobExtractTcb::work()
 	       lobType_,
 	       lobTdb().getLobHdfsServer(),
 	       lobTdb().getLobHdfsPort(),
-
 	       lobHandleLen_, lobHandle_,
                0, // cursor bytes 
                NULL, //cursor id
@@ -3276,6 +3277,495 @@ ExExeUtilFileExtractTcb::ExExeUtilFileExtractTcb
 {
 }
 
+
+
+///////////////////////////////////////////////////////////////////
+// class ExExeUtilLobUpdateTdb
+///////////////////////////////////////////////////////////////
+ex_tcb * ExExeUtilLobUpdateTdb::build(ex_globals * glob)
+{
+  ExExeUtilLobUpdateTcb * exe_util_lobupdate_tcb;
+
+  ex_tcb * childTcb = NULL;
+  if (child_)
+    {
+      // build the child first
+      childTcb = child_->build(glob);
+    }
+  
+  
+  if (getFromType() == ComTdbExeUtilLobUpdate::FROM_BUFFER_)
+    exe_util_lobupdate_tcb = new(glob->getSpace()) 
+      ExExeUtilLobUpdateTcb(*this, childTcb, glob);
+  else
+    {
+      ex_assert(TRUE,"Only buffer input supported");
+    }
+
+  exe_util_lobupdate_tcb->registerSubtasks();
+
+  return (exe_util_lobupdate_tcb);
+}
+
+ExExeUtilLobUpdateTcb::ExExeUtilLobUpdateTcb
+(
+ const ComTdbExeUtilLobUpdate & exe_util_lobupdate_tdb,
+ const ex_tcb * child_tcb, 
+ ex_globals * glob)
+  : ExExeUtilTcb(exe_util_lobupdate_tdb, child_tcb, glob),
+    step_(EMPTY_)    
+{
+  ContextCli *currContext =
+    getGlobals()->castToExExeStmtGlobals()->castToExMasterStmtGlobals()->
+    getStatement()->getContext();
+  lobHandleLen_ = 2050;
+  lobHandle_ = {0};
+  lobGlobals_ = 
+    new(currContext->exHeap()) LOBglobals(currContext->exHeap());
+  ExpLOBoper::initLOBglobal
+    (lobGlobals_->lobAccessGlobals(), 
+     currContext->exHeap(),currContext,lobTdb().getLobHdfsServer(),
+               lobTdb().getLobHdfsPort());
+}
+
+short ExExeUtilLobUpdateTcb::work()
+{
+  Lng32 cliRC = 0;
+  Lng32 retcode = 0;
+
+  // if no parent request, return
+  if (qparent_.down->isEmpty())
+    return WORK_OK;
+
+  ex_queue_entry * pentry_down = qparent_.down->getHeadEntry();
+  ExExeUtilPrivateState & pstate =
+    *((ExExeUtilPrivateState*) pentry_down->pstate);
+
+  ContextCli *currContext =
+    getGlobals()->castToExExeStmtGlobals()->castToExMasterStmtGlobals()->
+    getStatement()->getContext();
+
+  ComDiagsArea & diags       = currContext->diags();
+
+  LobsSubOper so = Lob_None;
+  
+  if (lobTdb().getFromType() == ComTdbExeUtilLobUpdate::FROM_STRING_)
+    so = Lob_Memory;
+  else if (lobTdb().getFromType() == ComTdbExeUtilLobUpdate::FROM_EXTERNAL_)
+    so = Lob_External;
+  else if (lobTdb().getFromType() == ComTdbExeUtilLobUpdate::FROM_BUFFER_)  //Only this is supported
+    so= Lob_Buffer;
+  
+  Int64 lobLen = lobTdb().updateSize();
+  char * data = (char *)lobTdb().getBufAddr();
+  
+  if (so == Lob_Buffer)
+    {
+      Int64 inputAddr = lobTdb().getBufAddr();
+      data = (char *)&inputAddr;
+    }
+  void * lobGlobs = getLobGlobals()->lobAccessGlobals();
+
+  while (1)
+    {
+      switch (step_)
+	{
+	case EMPTY_:
+	  {    
+            workAtp_->getTupp(lobTdb().workAtpIndex())
+	      .setDataPointer(lobInputHandleBuf_);  
+            step_ = GET_HANDLE_;   
+            break;
+          }
+          break;
+        case GET_HANDLE_:
+          {
+            ex_expr::exp_return_type exprRetCode =
+	      lobTdb().inputExpr_->eval(NULL, 
+					workAtp_);
+	    if (exprRetCode == ex_expr::EXPR_ERROR)
+              {	      
+                step_ = CANCEL_;
+                break;
+              }
+            if (ExpLOBoper::genLOBhandleFromHandleString
+		    (lobTdb().getHandle(),
+		     lobTdb().getHandleLen(),
+		     lobHandle_,
+		     lobHandleLen_))
+		  {
+		    ComDiagsArea * da = getDiagsArea();
+		    ExRaiseSqlError(getMyHeap(),
+				    &da,
+				    (ExeErrorCode)(EXE_INVALID_LOB_HANDLE));
+		    step_ = HANDLE_ERROR_;
+		    break;
+		  }
+            if (lobTdb().getFromType() == ComTdbExeUtilLobUpdate::FROM_BUFFER_)
+              {
+                if (lobTdb().isTruncate())
+                  step_ = EMPTY_LOB_DATA_;
+                else if (lobTdb().isReplace())
+                  step_ = UPDATE_LOB_DATA_;
+                else if(lobTdb().isAppend())
+                  step_ = APPEND_LOB_DATA_;
+                
+              }
+            else
+		{
+		  // invalid "fromType"
+		  ex_queue_entry * up_entry = qparent_.up->getTailEntry();
+		  ComDiagsArea * da = up_entry->getDiagsArea();
+		  ExRaiseSqlError(getMyHeap(),
+				  &da,
+				  (ExeErrorCode)(EXE_INTERNAL_ERROR));
+		  step_ = CANCEL_;
+		
+		break;
+
+		}
+            
+          }
+          break;
+        case UPDATE_LOB_DATA_:
+          {
+            Int32 retcode = 0;
+            Int16 flags;
+	    Lng32  lobNum;
+	    Int64 uid, inDescSyskey, descPartnKey;
+	    short schNameLen;
+	    char schName[1024];
+            Int64 dummy = 0;
+	    
+	    ExpLOBoper::extractFromLOBhandle(&flags, &lobType_, &lobNum, &uid,  
+					     &inDescSyskey, &descPartnKey, 
+					     &schNameLen, (char *)schName,
+					     (char *)lobHandle_, (Lng32)lobHandleLen_);
+	    lobName_ = ExpLOBoper::ExpGetLOBname(uid, lobNum, lobNameBuf_, 1000);
+
+	    lobDataLen_ = lobTdb().totalBufSize_; 
+            short *lobNumList = new (getHeap()) short[1];
+	    short *lobTypList = new (getHeap()) short[1];
+	    char  **lobLocList = new (getHeap()) char*[1];
+            char  **lobColNameList = new (getHeap()) char*[1];
+	    lobLocList[0] = new (getHeap()) char[1024];
+	    lobColNameList[0] = new (getHeap()) char[256];
+
+	    Lng32 numLobs = lobNum;
+	    Lng32 cliRC = SQL_EXEC_LOBddlInterface
+	      (
+	       schName,
+	       schNameLen,
+	       uid,
+	       numLobs,
+	       LOB_CLI_SELECT_UNIQUE,
+	       lobNumList,
+	       lobTypList,
+	       lobLocList,lobColNameList,lobTdb().getLobHdfsServer(),
+               lobTdb().getLobHdfsPort(),0,FALSE);
+	    if (cliRC < 0)
+	      {
+		getDiagsArea()->mergeAfter(diags);
+
+		step_ = HANDLE_ERROR_;
+		break;
+	      }
+
+	    strcpy(lobLoc_, lobLocList[0]);
+            char outLobHandle[LOB_HANDLE_LEN];
+            Int32 outHandleLen;
+            Int64 requestTag = 0;
+            retcode = ExpLOBInterfaceUpdate(lobGlobs,
+                                            lobTdb().getLobHdfsServer(),
+                                            lobTdb().getLobHdfsPort(),
+                                            lobName_,
+                                            lobLoc_,
+                                            lobHandleLen_,
+                                            lobHandle_,
+                                            &outHandleLen, outLobHandle,
+                                            requestTag,
+                                            getLobGlobals()->xnId(),
+                                            0,
+                                            1,
+                                            so,
+                                            inDescSyskey,
+                                            lobLen,
+                                            data,
+                                            lobName_, schNameLen, schName,
+                                            dummy, dummy,
+                                            lobTdb().getLobMaxSize(),
+                                            lobTdb().getLobMaxChunkSize(),
+                                            lobTdb().getLobGCLimit());
+            
+            if (retcode < 0)
+	      {
+		Lng32 cliError = 0;
+
+		Lng32 intParam1 = -retcode;
+		ComDiagsArea * diagsArea = getDiagsArea();
+		ExRaiseSqlError(getHeap(), &diagsArea, 
+				(ExeErrorCode)(8442), NULL, &intParam1, 
+				&cliError, NULL, (char*)"ExpLOBInterfaceUpdate",
+				getLobErrStr(intParam1));
+		step_ = HANDLE_ERROR_;
+		break;
+	      }  
+            if (so == Lob_Buffer)
+	      {
+		str_sprintf(statusString_," Updated/Replaced %d bytes of LOB data ", lobLen);
+		step_ = RETURN_STATUS_;
+	      }
+            
+            break;
+          }
+          break;
+        case APPEND_LOB_DATA_:
+          {
+            Int32 retcode = 0;
+            Int16 flags;
+	    Lng32  lobNum;
+	    Int64 uid, inDescSyskey, descPartnKey;
+	    short schNameLen;
+	    char schName[1024];
+            Int64 dummy = 0;
+	    
+	    ExpLOBoper::extractFromLOBhandle(&flags, &lobType_, &lobNum, &uid,  
+					     &inDescSyskey, &descPartnKey, 
+					     &schNameLen, (char *)schName,
+					     (char *)lobHandle_, (Lng32)lobHandleLen_);
+	    lobName_ = ExpLOBoper::ExpGetLOBname(uid, lobNum, lobNameBuf_, 1000);
+
+	    lobDataLen_ = lobTdb().totalBufSize_; 
+            short *lobNumList = new (getHeap()) short[1];
+	    short *lobTypList = new (getHeap()) short[1];
+	    char  **lobLocList = new (getHeap()) char*[1];
+            char  **lobColNameList = new (getHeap()) char*[1];
+	    lobLocList[0] = new (getHeap()) char[1024];
+            lobColNameList[0] = new (getHeap()) char[256];
+	    
+	    Lng32 numLobs = lobNum;
+	    Lng32 cliRC = SQL_EXEC_LOBddlInterface
+	      (
+	       schName,
+	       schNameLen,
+	       uid,
+	       numLobs,
+	       LOB_CLI_SELECT_UNIQUE,
+	       lobNumList,
+	       lobTypList,
+	       lobLocList,lobColNameList,lobTdb().getLobHdfsServer(),
+               lobTdb().getLobHdfsPort(),0,FALSE);
+	    if (cliRC < 0)
+	      {
+		getDiagsArea()->mergeAfter(diags);
+
+		step_ = HANDLE_ERROR_;
+		break;
+	      }
+
+	    strcpy(lobLoc_, lobLocList[0]);
+            char outLobHandle[LOB_HANDLE_LEN];
+            Int32 outHandleLen;
+            Int64 requestTag = 0;
+            retcode = ExpLOBInterfaceUpdateAppend(lobGlobs,
+                                            lobTdb().getLobHdfsServer(),
+                                            lobTdb().getLobHdfsPort(),
+                                            lobName_,
+                                            lobLoc_,
+                                            lobHandleLen_,
+                                            lobHandle_,
+                                            &outHandleLen, outLobHandle,
+                                            requestTag,
+                                            getLobGlobals()->xnId(),
+                                            0,
+                                            1,
+                                            so,
+                                            inDescSyskey,
+                                            lobLen,
+                                            data,
+                                            lobName_, schNameLen, schName,
+                                            dummy, dummy,
+                                            lobTdb().getLobMaxSize(),
+                                            lobTdb().getLobMaxChunkSize(),
+                                            lobTdb().getLobGCLimit());
+            
+            if (retcode < 0)
+	      {
+		Lng32 cliError = 0;
+
+		Lng32 intParam1 = -retcode;
+		ComDiagsArea * diagsArea = getDiagsArea();
+		ExRaiseSqlError(getHeap(), &diagsArea, 
+				(ExeErrorCode)(8442), NULL, &intParam1, 
+				&cliError, NULL, (char*)"ExpLOBInterfaceUpdate",
+				getLobErrStr(intParam1));
+		step_ = HANDLE_ERROR_;
+		break;
+	      }  
+            if (so == Lob_Buffer)
+	      {
+		str_sprintf(statusString_," Updated/Appended %d bytes of LOB data ", lobLen);
+		step_ = RETURN_STATUS_;
+	      }
+            
+            break;
+          }
+          break;
+
+        case EMPTY_LOB_DATA_:
+          {
+            Int32 retcode = 0;
+            Int16 flags;
+	    Lng32  lobNum;
+	    Int64 uid, inDescSyskey, descPartnKey;
+	    short schNameLen;
+	    char schName[1024];
+            Int64 dummy = 0;
+	    
+	    ExpLOBoper::extractFromLOBhandle(&flags, &lobType_, &lobNum, &uid,  
+					     &inDescSyskey, &descPartnKey, 
+					     &schNameLen, (char *)schName,
+					     (char *)lobHandle_, (Lng32)lobHandleLen_);
+	    lobName_ = ExpLOBoper::ExpGetLOBname(uid, lobNum, lobNameBuf_, 1000);
+
+	    lobDataLen_ = lobTdb().totalBufSize_; 
+            short *lobNumList = new (getHeap()) short[1];
+	    short *lobTypList = new (getHeap()) short[1];
+	    char  **lobLocList = new (getHeap()) char*[1];
+            char  **lobColNameList = new (getHeap()) char*[1];
+	    lobLocList[0] = new (getHeap()) char[1024];
+	    lobColNameList[0] = new (getHeap()) char[256];
+	    Lng32 numLobs = lobNum;
+	    Lng32 cliRC = SQL_EXEC_LOBddlInterface
+	      (
+	       schName,
+	       schNameLen,
+	       uid,
+	       numLobs,
+	       LOB_CLI_SELECT_UNIQUE,
+	       lobNumList,
+	       lobTypList,
+	       lobLocList,lobColNameList,lobTdb().getLobHdfsServer(),
+               lobTdb().getLobHdfsPort(),0,FALSE);
+	    if (cliRC < 0)
+	      {
+		getDiagsArea()->mergeAfter(diags);
+
+		step_ = HANDLE_ERROR_;
+		break;
+	      }
+
+	    strcpy(lobLoc_, lobLocList[0]);
+            char outLobHandle[LOB_HANDLE_LEN];
+            Int32 outHandleLen;
+            Int64 requestTag = 0;
+            /*    retcode = ExpLOBInterfaceDelete(lobGlobs,
+                                             lobTdb().getLobHdfsServer(),
+                                            lobTdb().getLobHdfsPort(),
+                                            lobName_,
+                                            lobLoc_,
+                                            lobHandleLen_,
+                                            lobHandle_,
+                                            requestTag_,
+                                            getLobGlobals()->xnId(),
+                                            inDescSyskey,
+                                            0,1);
+            if (retcode < 0)
+	      {
+		Lng32 cliError = 0;
+                
+		Lng32 intParam1 = -retcode;
+		ComDiagsArea * diagsArea = getDiagsArea();
+		ExRaiseSqlError(getHeap(), &diagsArea, 
+				(ExeErrorCode)(8442), NULL, &intParam1, 
+				&cliError, NULL, (char*)"ExpLOBInterfaceUpdate",
+				getLobErrStr(intParam1));
+		step_ = HANDLE_ERROR_;
+		break;
+                }  */
+            retcode = ExpLOBInterfaceUpdate(lobGlobs,
+                                            lobTdb().getLobHdfsServer(),
+                                            lobTdb().getLobHdfsPort(),
+                                            lobName_,
+                                            lobLoc_,
+                                            lobHandleLen_,
+                                            lobHandle_,
+                                            &outHandleLen, outLobHandle,
+                                            requestTag,
+                                            getLobGlobals()->xnId(),
+                                            0,
+                                            1,
+                                            so,
+                                            inDescSyskey,
+                                            0,
+                                            NULL,
+                                            lobName_, schNameLen, schName,
+                                            dummy, dummy,
+                                            lobTdb().getLobMaxSize(),
+                                            lobTdb().getLobMaxChunkSize(),
+                                            lobTdb().getLobGCLimit());
+            
+            if (retcode < 0)
+	      {
+		Lng32 cliError = 0;
+
+		Lng32 intParam1 = -retcode;
+		ComDiagsArea * diagsArea = getDiagsArea();
+		ExRaiseSqlError(getHeap(), &diagsArea, 
+				(ExeErrorCode)(8442), NULL, &intParam1, 
+				&cliError, NULL, (char*)"ExpLOBInterfaceUpdate",
+				getLobErrStr(intParam1));
+		step_ = HANDLE_ERROR_;
+		break;
+	      }  
+            if (so == Lob_Buffer)
+	      {
+		str_sprintf(statusString_," Updated with empty_blob/clob  ");
+		step_ = RETURN_STATUS_;
+	      }
+            
+            break;
+          }
+          break;
+        case CANCEL_:
+          {
+            break;
+          }
+          break;
+        case RETURN_STATUS_:
+	  {
+	    if (qparent_.up->isFull())
+	      return WORK_OK;
+	    //Return to upqueue whatever is in the lobStatusMsg_ data member
+      	    short rc; 
+	    moveRowToUpQueue(statusString_, 200, &rc);	   
+            step_ = DONE_ ;
+	  }
+	  break;
+        case HANDLE_ERROR_:
+          {
+            retcode = handleError();
+	    if (retcode == 1)
+	      return WORK_OK;
+	    step_ = DONE_;
+            
+          }
+          break;
+        case DONE_:
+          {
+            retcode = handleDone();
+	    if (retcode == 1)
+	      return WORK_OK;
+
+	    step_ = EMPTY_;
+	    return WORK_OK;
+          }
+          break;
+        }
+    }
+  return 0;
+}
+
 NABoolean ExExeUtilFileExtractTcb::needStatsEntry()
 {
   // stats are collected for ALL and OPERATOR options.
@@ -3307,6 +3797,8 @@ ExOperStats * ExExeUtilFileExtractTcb::doAllocateStatsEntry(
     }
 }
 
+
+
 short ExExeUtilFileExtractTcb::work()
 {
   Lng32 cliRC = 0;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/executor/ExHdfsScan.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExHdfsScan.cpp b/core/sql/executor/ExHdfsScan.cpp
index 8c630fd..69da813 100644
--- a/core/sql/executor/ExHdfsScan.cpp
+++ b/core/sql/executor/ExHdfsScan.cpp
@@ -122,7 +122,7 @@ ExHdfsScanTcb::ExHdfsScanTcb(
 {
   Space * space = (glob ? glob->getSpace() : 0);
   CollHeap * heap = (glob ? glob->getDefaultHeap() : 0);
-
+  lobGlob_ = NULL;
   const int readBufSize =  (Int32)hdfsScanTdb.hdfsBufSize_;
   hdfsScanBuffer_ = new(space) char[ readBufSize + 1 ]; 
   hdfsScanBuffer_[readBufSize] = '\0';

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/exp/ExpLOB.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpLOB.cpp b/core/sql/exp/ExpLOB.cpp
index cb6ded8..1400cfc 100644
--- a/core/sql/exp/ExpLOB.cpp
+++ b/core/sql/exp/ExpLOB.cpp
@@ -402,7 +402,6 @@ void ExpLOBoper::genLOBhandle(Int64 uid,
   lobHandle->objUID_ = uid;
   lobHandle->descSyskey_ = descKey;
   lobHandle->descPartnkey_ = descTS;
-  str_pad(lobHandle->filler_, 30, '\0');
   lobHandle->schNameLen_ = schNameLen;
   handleLen = sizeof(LOBHandle);
   if (schNameLen > 0)
@@ -478,14 +477,7 @@ void ExpLOBoper::createLOBhandleString(Int16 flags,
 	      findNumDigits(descTS), descTS,
 	      schNameLen, schName);
 
-  /*
-
-  str_sprintf(lobHandleBuf, "LOBH%04d%020Ld%04d%02d%Ld%02d%Ld%03d%s",
-  	      flags, uid, lobNum, 
-	      findNumDigits(descKey), descKey, 
-	      findNumDigits(descTS), descTS,
-	      schNameLen, schName);
-  */
+ 
 }
 
 // Extracts values from the string format of LOB handle 
@@ -501,13 +493,14 @@ Lng32 ExpLOBoper::extractFromLOBstring(Int64 &uid,
 				       Lng32 handleLen)
 {
   // opp of:
-  ////  // str_sprintf(lobHandleBuf, "LOBH%04d%020Ld%04d%02d%Ld%02d%Ld%03d%s",
-
-  //  str_sprintf(lobHandleBuf, "LOBH%04d%02d%04d%020d%02d%Ld%02d%Ld%03d%s",
-  //		  header, flags, lobtype, lobNum, uid, descPartnKey, descSyskey, schNameLen/SchName
+  //  str_sprintf(lobHandleBuf, "LOBH%04d%04d%04d%020Ld%02d%Ld%02d%Ld%03d%s",
+  //	      flags, lobType, lobNum, uid,
+  //	      findNumDigits(descKey), descKey, 
+  //	      findNumDigits(descTS), descTS,
+  //	      schNameLen, schName)
 
 
-  if (handleLen < (4 + 4 + 2 + 4 + 20 + 2))
+  if (handleLen < (4 + 4 + 4  + 20 + 2)) // Minimum sanity check.
     return -1;
 
   Lng32 curPos = 4;
@@ -515,7 +508,7 @@ Lng32 ExpLOBoper::extractFromLOBstring(Int64 &uid,
   flags = (Lng32)str_atoi(&handle[curPos], 4);
   curPos += 4;
 
-  lobType = (Lng32)str_atoi(&handle[curPos], 2);
+  lobType = (Lng32)str_atoi(&handle[curPos], 4);
   curPos += 4;
 
   lobNum = (Lng32)str_atoi(&handle[curPos], 4);
@@ -736,7 +729,7 @@ ex_expr::exp_return_type ExpLOBiud::insertDesc(char *op_data[],
   else
     {
       Int64 descTS = NA_JulianTimestamp();
-
+      
       lobHandle = lobHandleBuf;
       ExpLOBoper::genLOBhandle(objectUID_, lobNum(), (short)lobStorageType(),
 			       -1, descTS, -1,
@@ -755,6 +748,15 @@ ex_expr::exp_return_type ExpLOBiud::insertDesc(char *op_data[],
     so = Lob_Buffer;
   else if (fromExternal())
     so = Lob_External;
+  else if (fromEmpty())
+    {
+      /* str_cpy_all(result, lobHandle, handleLen);
+
+       getOperand(0)->setVarLength(handleLen, op_data[-MAX_OPERANDS]);
+      //we can return now - nothing to insert into the descriptors
+      return ex_expr::EXPR_OK; */
+      so = Lob_Memory;
+    }
 
   
 
@@ -770,8 +772,10 @@ ex_expr::exp_return_type ExpLOBiud::insertDesc(char *op_data[],
 
   // temp. Pass lobLen. When ExLobsOper fixes it so len is not needed during
   // lob desc update, then remove this.
-  Int64 lobLen = getOperand(1)->getLength();
-
+  Int64 lobLen = 0;
+  if(!fromEmpty())
+    lobLen = getOperand(1)->getLength();
+  
   blackBoxLen_ = 0;
   if (fromExternal())
     {
@@ -1033,6 +1037,8 @@ ex_expr::exp_return_type ExpLOBinsert::eval(char *op_data[],
   if (err == ex_expr::EXPR_ERROR)
     return err;
     
+  if(fromEmpty())
+    return err;
 
 #ifndef __EID
   char * handle = op_data[0];
@@ -1256,6 +1262,18 @@ ex_expr::exp_return_type ExpLOBupdate::eval(char *op_data[],
 		       &sDescSyskey, &sDescTS, 
 		       &sSchNameLen, sSchName,
 		       lobHandle); //op_data[2]);
+  if (sDescSyskey == -1) //updating empty lob
+    {
+      ex_expr::exp_return_type err = insertDesc(op_data, h, diagsArea);
+      if (err == ex_expr::EXPR_ERROR)
+	return err;
+     
+      char * handle = op_data[0];
+      handleLen = getOperand(0)->getLength();
+      err = insertData(handleLen, handle, op_data, h, diagsArea);
+     
+      return err;
+    }
 
   
   // get the lob name where data need to be updated
@@ -1299,6 +1317,9 @@ ex_expr::exp_return_type ExpLOBupdate::eval(char *op_data[],
     so= Lob_Buffer;
   else if (fromExternal())
     so = Lob_External;
+ 
+   
+ 
   Int64 lobMaxSize = 0;
   if (getLobSize() > 0)
     {
@@ -1329,7 +1350,60 @@ ex_expr::exp_return_type ExpLOBupdate::eval(char *op_data[],
       memcpy(&lobLen, op_data[3],sizeof(Int64)); // user specified buffer length
       memcpy(data,op_data[1],sizeof(Int64)); // user buffer address
     }
-  if (isAppend())
+
+  if(fromEmpty())
+    {
+      lobLen = 0;
+      so = Lob_Memory;
+    }
+  /*  if (fromEmpty())
+    {
+      // delete the lob and initialize with  a new lob handle
+     
+      rc = ExpLOBInterfaceDelete(getExeGlobals()->getExLobGlobal(), 
+                                 getLobHdfsServer(),
+                                 getLobHdfsPort(),
+                                 tgtLobName, 
+                                 lobStorageLocation(),
+                                 handleLen, 
+                                 lobHandle,
+                                 requestTag_,
+                                 getExeGlobals()->lobGlobals()->xnId(),
+                                 fromDescKey,
+                                 (lobOperStatus == CHECK_STATUS_ ? 1 : 0),
+                                 waitedOp
+                                 );
+      if (rc < 0)
+        {
+          Lng32 intParam1 = -rc;
+          ExRaiseSqlError(h, diagsArea, 
+                          (ExeErrorCode)(8442), NULL, &intParam1, 
+                          &cliError, NULL, (char*)"ExpLOBInterfaceUpdate",
+                          (char*)"ExpLOBInterfaceUpdate",getLobErrStr(intParam1));
+          return ex_expr::EXPR_ERROR;
+        }
+      //Initialize a fresh lob handle
+      char * lobHandle = NULL;
+      Lng32 handleLen = 0;
+      char lobHandleBuf[LOB_HANDLE_LEN];
+      Int64 descTS = NA_JulianTimestamp();
+
+      lobHandle = lobHandleBuf;
+      ExpLOBoper::genLOBhandle(objectUID_, lobNum(), (short)lobStorageType(),
+			       -1, descTS, -1,
+			       descSchNameLen_, descSchName(),
+			       handleLen, lobHandle);
+      // update lob handle with the returned values
+      str_cpy_all(result, lobHandle, handleLen);
+      //     str_cpy_all(result, op_data[2], handleLen);
+      //     ExpLOBoper::updLOBhandle(sDescSyskey, 0, result); 
+      getOperand(0)->setVarLength(handleLen, op_data[-MAX_OPERANDS]);
+
+      return ex_expr::EXPR_OK;                     
+                                 
+    }
+
+    else*/ if (isAppend() && !fromEmpty())
     {
       rc = ExpLOBInterfaceUpdateAppend
 	(getExeGlobals()->getExLobGlobal(), 
@@ -1520,7 +1594,16 @@ ex_expr::exp_return_type ExpLOBconvert::eval(char *op_data[],
   char lobNameBuf[100];
   char * lobName = ExpGetLOBname(uid, lobNum, lobNameBuf, 100);
       
- 
+  if (descKey == -1) //This is an empty_blob/clob
+    {
+      Int32 intParam1 = LOB_DATA_EMPTY_ERROR;
+      Int32 cliError = 0;
+       ExRaiseSqlError(h, diagsArea, 
+			  (ExeErrorCode)(8442), NULL, &intParam1, 
+			  &cliError, NULL, (char*)"ExpLOBInterfaceSelect",
+			  (char*)"ExpLOBInterfaceSelect",getLobErrStr(intParam1));
+	  return ex_expr::EXPR_ERROR;
+    }
   if(toFile())
     {
       so = Lob_File;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/exp/ExpLOB.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpLOB.h b/core/sql/exp/ExpLOB.h
index 822a694..296fe69 100644
--- a/core/sql/exp/ExpLOB.h
+++ b/core/sql/exp/ExpLOB.h
@@ -353,7 +353,6 @@ public:
     Int64 objUID_;
     Int64 descSyskey_;
     Int64 descPartnkey_;
-    char  filler_[30];  
     short schNameLen_;
     char  schName_;
    
@@ -447,11 +446,19 @@ class ExpLOBiud : public ExpLOBoper {
   {
     return ((liudFlags_ & FROM_BUFFER) != 0);
   };
-
   NA_EIDPROC inline void setFromBuffer(NABoolean v)
   {
     (v) ? liudFlags_ |= FROM_BUFFER: liudFlags_ &= ~FROM_BUFFER;
   };
+  NA_EIDPROC inline void setFromEmpty(NABoolean v)
+  {
+    (v) ? liudFlags_ |= FROM_EMPTY: liudFlags_ &= ~FROM_EMPTY;
+  };
+  NA_EIDPROC NABoolean fromEmpty()
+  {
+    return ((liudFlags_ & FROM_EMPTY) != 0);
+  };
+ 
   NA_EIDPROC NABoolean fromFile()
   {
     return ((liudFlags_ & FROM_FILE) != 0);
@@ -504,7 +511,8 @@ class ExpLOBiud : public ExpLOBoper {
     FROM_LOAD          = 0x0008,
     FROM_LOB           = 0x0010,
     FROM_EXTERNAL      = 0x0020,
-    FROM_BUFFER        = 0x0040
+    FROM_BUFFER        = 0x0040,
+    FROM_EMPTY         = 0x0080
   };
 
   Lng32 liudFlags_;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/exp/ExpLOBaccess.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpLOBaccess.cpp b/core/sql/exp/ExpLOBaccess.cpp
index e8e0f08..f20fdcb 100644
--- a/core/sql/exp/ExpLOBaccess.cpp
+++ b/core/sql/exp/ExpLOBaccess.cpp
@@ -818,7 +818,7 @@ Ex_Lob_Error ExLob::writeDesc(Int64 &sourceLen, char *source, LobsSubOper subOpe
 	if (err != LOB_OPER_OK)
 	  return err;
       }
-    if (sourceLen <= 0 || sourceLen > lobMaxSize)
+    if (sourceLen < 0 || sourceLen > lobMaxSize)
       {
 	return LOB_MAX_LIMIT_ERROR; //exceeded the size of the max lob size
         //TBD trigger compaction
@@ -1217,7 +1217,7 @@ Ex_Lob_Error ExLob::update(char *data, Int64 size, LobsSubOper so,Int64 headDesc
       }
     if(so != Lob_External)
       {
-        if (sourceLen <= 0 || sourceLen > lobMaxSize)
+        if (sourceLen < 0 || sourceLen > lobMaxSize)
           {
             return LOB_MAX_LIMIT_ERROR; //exceeded the size of the max lob size
           }
@@ -1241,6 +1241,11 @@ Ex_Lob_Error ExLob::update(char *data, Int64 size, LobsSubOper so,Int64 headDesc
       
        return LOB_DESC_UPDATE_ERROR;
     }
+    if (sourceLen ==0 )
+      {
+        //No need to write any data
+        return err;
+      }
     char *inputAddr = data;
     if (so == Lob_Buffer)
       {
@@ -1502,7 +1507,50 @@ Ex_Lob_Error ExLob::allocateDesc(ULng32 size, Int64 &descNum, Int64 &dataOffset,
     char logBuf[4096];
     lobDebugInfo("In ExLob::allocateDesc",0,__LINE__,lobTrace_);
     Int32 openFlags = O_RDONLY ;   
-    
+    if (size == 0) //we are trying to empty this lob.
+      {
+        //rename lob datafile
+        char * saveLobDataFile = new(getLobGlobalHeap()) char[MAX_LOB_FILE_NAME_LEN+6];
+        str_sprintf(saveLobDataFile, "%s_save",lobDataFile_);
+        Int32 rc2 = hdfsRename(fs_,lobDataFile_,saveLobDataFile);
+        if (rc2 == -1)
+          {
+            lobDebugInfo("Problem renaming datafile to save data file",0,__LINE__,lobTrace_);
+            NADELETEBASIC(saveLobDataFile,getLobGlobalHeap());
+            return LOB_DATA_FILE_WRITE_ERROR;
+          }
+        //create a new file of the same name.
+        hdfsFile fdNew = hdfsOpenFile(fs_, lobDataFile_,O_WRONLY|O_CREAT,0,0,0);
+        if (!fdNew) 
+          {
+            str_sprintf(logBuf,"Could not create/open file:%s",lobDataFile_);
+            lobDebugInfo(logBuf,0,__LINE__,lobTrace_);
+            
+            //restore previous version
+            Int32 rc2 = hdfsRename(fs_,saveLobDataFile,lobDataFile_);
+              if (rc2 == -1)
+                {
+                  lobDebugInfo("Problem restoring datafile . Will need to retry the update",0,__LINE__,lobTrace_);
+                  NADELETEBASIC(saveLobDataFile,getLobGlobalHeap());
+                  return LOB_DATA_FILE_WRITE_ERROR;
+                }
+            return LOB_DATA_FILE_OPEN_ERROR;
+            
+          }
+        else
+          {
+            //A new empty data file has been created.
+            // delete the saved data file
+            Int32 rc2 = hdfsDelete(fs_,saveLobDataFile,FALSE);//ok to ignore error.nt32            
+            if (rc2 == -1)
+              {
+                lobDebugInfo("Problem deleting saved datafile . Will need to manually cleanup saved datafile",0,__LINE__,lobTrace_);
+              }
+            NADELETEBASIC(saveLobDataFile,getLobGlobalHeap());
+            hdfsCloseFile(fs_,fdNew);
+            fdNew = NULL;    
+          }
+      }
     hdfsFileInfo *fInfo = hdfsGetPathInfo(fs_, lobDataFile_);
     if (fInfo)
       dataOffset = fInfo->mSize;
@@ -1777,9 +1825,11 @@ Ex_Lob_Error ExLob::readCursorData(char *tgt, Int64 tgtSize, cursor_t &cursor, I
             cursor.descSize_ = outSize;
             cursor.descOffset_ = outOffset;
             cursor.bytesRead_ = 0;
+            if (outSize == 0) // this is an empty lob entry
+              continue;
          }
       }
-
+      
       bytesAvailable = cursor.descSize_ - cursor.bytesRead_;
       bytesToCopy = min(bytesAvailable, tgtSize - operLen);
       offset = cursor.descOffset_ + cursor.bytesRead_;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/exp/ExpLOBenums.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpLOBenums.h b/core/sql/exp/ExpLOBenums.h
index 98d0d88..3f46d37 100644
--- a/core/sql/exp/ExpLOBenums.h
+++ b/core/sql/exp/ExpLOBenums.h
@@ -93,6 +93,7 @@ typedef enum {
   LOB_MAX_LIMIT_ERROR = 560,
   LOB_TARGET_FILE_EXISTS_ERROR,
   LOB_DATA_MOD_CHECK_ERROR,
+  LOB_DATA_EMPTY_ERROR,
   LOB_MAX_ERROR_NUM     // keep this as the last element in enum list.
 } Ex_Lob_Error;
 
@@ -161,6 +162,7 @@ static const char * const lobErrorEnumStr[] =
   "LOB_MAX_LIMIT_ERROR", //560
   "LOB_TGT_FILE_EXISTS_ERROR",
   "LOB_DATA_MOD_CHECK_ERROR",
+  "LOB_DATA_EMPTY_ERROR",
   "LOB_MAX_ERROR_NUM"     // keep this as the last element in enum list.
 };
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/exp/ExpLOBexternal.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpLOBexternal.h b/core/sql/exp/ExpLOBexternal.h
index 48905d3..1bfd33e 100644
--- a/core/sql/exp/ExpLOBexternal.h
+++ b/core/sql/exp/ExpLOBexternal.h
@@ -162,6 +162,7 @@ Lng32 SQL_EXEC_LOBddlInterface
  /*IN*/     short *lobNumList,
  /*IN*/     short *lobTypList,
  /*IN*/     char* *lobLocList,
+ /*IN*/     char* *lobColNameList,
  /*IN*/     char*  hdfsServer,
  /*IN*/     Lng32  hdfsPort,
  /*IN*/     Int64 lobMaxSize,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/generator/GenItemFunc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenItemFunc.cpp b/core/sql/generator/GenItemFunc.cpp
index 77d9913..2aab1ec 100644
--- a/core/sql/generator/GenItemFunc.cpp
+++ b/core/sql/generator/GenItemFunc.cpp
@@ -2803,6 +2803,8 @@ short LOBinsert::codeGen(Generator * generator)
     li->setFromExternal(TRUE);
   else if (obj_ ==LOBoper::BUFFER_)
     li->setFromBuffer(TRUE);
+  else if(obj_ == LOBoper::EMPTY_LOB_)
+    li->setFromEmpty(TRUE);
 
   li->lobNum() = lobNum();
   li->setLobStorageType(lobStorageType());
@@ -2877,6 +2879,8 @@ short LOBupdate::codeGen(Generator * generator)
     lu->setFromExternal(TRUE);
   else if (obj_ == LOBoper::BUFFER_)
     lu->setFromBuffer(TRUE);
+  else if(obj_ == LOBoper::EMPTY_LOB_)
+    lu->setFromEmpty(TRUE);
 
   lu->lobNum() = lobNum();
   lu->setLobStorageType(lobStorageType());

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/generator/GenPreCode.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenPreCode.cpp b/core/sql/generator/GenPreCode.cpp
index 2e0ae24..f95238b 100644
--- a/core/sql/generator/GenPreCode.cpp
+++ b/core/sql/generator/GenPreCode.cpp
@@ -5397,7 +5397,11 @@ RelExpr * HbaseUpdate::preCodeGen(Generator * generator,
 	      lu->updatedTableSchemaName() += "\"";
               lu->lobSize() = col->getType()->getPrecision();
 	      lu->lobNum() = col->lobNum();
-	      // lu->lobStorageType() = col->lobStorageType();
+	     
+              if (lu->lobStorageType() == Lob_Empty)
+                    {
+                      lu->lobStorageType() = col->lobStorageType();
+                    }
               if (lu->lobStorageType() != col->lobStorageType())
                     {
                       *CmpCommon::diags() << DgSqlCode(-1432)
@@ -5557,6 +5561,12 @@ RelExpr * HbaseInsert::preCodeGen(Generator * generator,
 		  li->insertedTableSchemaName() += "\"";
 		  
 		  li->lobNum() = col->lobNum();
+                  //If we are initializing an empty_lob, assume the storage 
+                  //type of the underlying column
+                  if (li->lobStorageType() == Lob_Empty)
+                    {
+                      li->lobStorageType() = col->lobStorageType();
+                    }
                   if (li->lobStorageType() != col->lobStorageType())
                     {
                       *CmpCommon::diags() << DgSqlCode(-1432)
@@ -5708,6 +5718,38 @@ RelExpr * ExeUtilLobExtract::preCodeGen(Generator * generator,
    return this;
  }
 
+RelExpr * ExeUtilLobUpdate::preCodeGen(Generator * generator,
+                                       const ValueIdSet & externalInputs,
+                                       ValueIdSet &pulledNewInputs)
+{
+  if (nodeIsPreCodeGenned())
+    return this;
+
+  if (! ExeUtilExpr::preCodeGen(generator,externalInputs,pulledNewInputs))
+    return NULL;
+
+  ValueIdSet availableValues;
+  for (ValueId exprId = getGroupAttr()->getCharacteristicInputs().init();
+       getGroupAttr()->getCharacteristicInputs().next(exprId);
+       getGroupAttr()->getCharacteristicInputs().advance(exprId) )
+    {
+      if (exprId.getItemExpr()->getOperatorType() != ITM_VEG_REFERENCE)
+       availableValues += exprId;
+    }
+  
+  getGroupAttr()->setCharacteristicInputs(availableValues);
+  getInputValuesFromParentAndChildren(availableValues);
+
+  if (handle_)
+    handle_->replaceVEGExpressions
+      (availableValues, getGroupAttr()->getCharacteristicInputs());
+  xnNeeded() = TRUE;
+  markAsPreCodeGenned();
+
+   // Done.
+   return this;
+ }
+
 RelExpr * HashGroupBy::preCodeGen(Generator * generator,
                                  const ValueIdSet & externalInputs,
                                  ValueIdSet &pulledNewInputs)

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/generator/GenRelExeUtil.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenRelExeUtil.cpp b/core/sql/generator/GenRelExeUtil.cpp
index ee089b4..187e90b 100644
--- a/core/sql/generator/GenRelExeUtil.cpp
+++ b/core/sql/generator/GenRelExeUtil.cpp
@@ -4180,6 +4180,185 @@ if (handleInStringFormat_)
 
 /////////////////////////////////////////////////////////
 //
+// ExeUtilLobUpdate::codeGen()
+//
+/////////////////////////////////////////////////////////
+short ExeUtilLobUpdate::codeGen(Generator * generator)
+{
+  ExpGenerator * expGen = generator->getExpGenerator();
+  Space * space = generator->getSpace();
+
+  // allocate a map table for the retrieved columns
+  generator->appendAtEnd();
+
+  ex_cri_desc * givenDesc
+    = generator->getCriDesc(Generator::DOWN);
+
+  ex_cri_desc * returnedDesc
+#pragma nowarn(1506)   // warning elimination
+    = new(space) ex_cri_desc(givenDesc->noTuples() + 1, space);
+#pragma warn(1506)  // warning elimination
+
+  ex_cri_desc * workCriDesc = new(space) ex_cri_desc(4, space);
+  const Int32 work_atp = 1;
+  const Int32 exe_util_row_atp_index = 2;
+  const Int32 work_row_atp_index = 2;
+
+  ComTdb * child_tdb = NULL;
+  ExplainTuple *childExplainTuple = NULL;
+  if (child(0))
+    {
+      MapTable * childMapTable = generator->appendAtEnd();
+
+      // generate code for child tree
+      child(0)->codeGen(generator);
+      child_tdb = (ComTdb *)(generator->getGenObj());
+      childExplainTuple = generator->getExplainTuple();
+    }
+
+  short rc = processOutputRow(generator, work_atp, exe_util_row_atp_index,
+                              returnedDesc);
+  if (rc)
+    {
+      return -1;
+    }
+
+  char * handle = NULL;
+  Lng32 handleLen = 0;
+  if (handle_ && handle_->getOperatorType() == ITM_CONSTANT)
+    {
+      ConstValue * cv = (ConstValue*)handle_;
+      
+      NAString h = *(cv->getRawText());
+      handleLen = h.length();
+
+      handle = space->allocateAlignedSpace(handleLen + 1);
+      strcpy(handle, h.data());
+    }
+
+  
+
+  ex_expr * input_expr = 0;
+  ULng32 inputRowLen = 0;
+  if (handle_)
+    {
+      ValueIdList inputVIDList;
+      ItemExpr * inputExpr = new(generator->wHeap())
+        
+	Cast(handle_, 
+	     &handle_->getValueId().getType()); // Leave it in string format.
+ 
+      
+      inputExpr->bindNode(generator->getBindWA());
+      NAType &nat = (NAType&)inputExpr->getValueId().getType();
+      nat.setNullable(TRUE);
+      inputVIDList.insert(inputExpr->getValueId());
+      
+      expGen->
+	processValIdList(inputVIDList,
+			 ExpTupleDesc::SQLARK_EXPLODED_FORMAT,
+			 inputRowLen,
+			 work_atp,
+			 work_row_atp_index
+			 );
+      
+      expGen->
+	generateContiguousMoveExpr(inputVIDList,
+				   0, // don't add conv nodes
+				   work_atp,
+				   work_row_atp_index,
+				   ExpTupleDesc::SQLARK_EXPLODED_FORMAT,
+				   inputRowLen,
+				   &input_expr);
+    }
+
+  Lng32 lst = 0;
+
+
+  Lng32 hdfsPort = (Lng32)CmpCommon::getDefaultNumeric(LOB_HDFS_PORT);
+  const char* f = ActiveSchemaDB()->getDefaults().
+    getValue(LOB_HDFS_SERVER);
+  char * hdfsServer = space->allocateAlignedSpace(strlen(f) + 1);
+  strcpy(hdfsServer, f);
+  
+  ComTdbExeUtilLobUpdate * exe_util_lobupdate_tdb = new(space) 
+    ComTdbExeUtilLobUpdate
+    (
+     handle,
+     handleLen,
+     (fromType_ == FROM_BUFFER_ ? ComTdbExeUtilLobUpdate::FROM_BUFFER_ :
+       (fromType_ == FROM_STRING_ ? ComTdbExeUtilLobUpdate::FROM_STRING_ :
+	(fromType_ == FROM_EXTERNAL_ ? ComTdbExeUtilLobUpdate::FROM_EXTERNAL_ :
+	  ComTdbExeUtilLobUpdate::NOOP_))),
+     bufAddr_,
+     updateSize_,
+     lst,
+     hdfsServer,
+     hdfsPort,
+     input_expr,
+     inputRowLen,
+     workCriDesc,
+     work_row_atp_index,
+     givenDesc,
+     returnedDesc,
+     (queue_index)8,
+     (queue_index)128,
+#pragma nowarn(1506)   // warning elimination 
+     2,
+     32000);
+#pragma warn(1506)  // warning elimination 
+
+
+
+  if (updateAction_ == UpdateActionType::ERROR_IF_EXISTS_)
+    exe_util_lobupdate_tdb->setErrorIfExists(TRUE);   
+  else
+    exe_util_lobupdate_tdb->setErrorIfExists(FALSE);
+
+  if (updateAction_ == UpdateActionType::TRUNCATE_EXISTING_)
+    exe_util_lobupdate_tdb->setTruncate(TRUE);
+  else
+    exe_util_lobupdate_tdb->setTruncate(FALSE);
+  if (updateAction_ == UpdateActionType::REPLACE_)
+    exe_util_lobupdate_tdb->setReplace(TRUE);
+  else
+    exe_util_lobupdate_tdb->setReplace(FALSE);
+  if (updateAction_ == UpdateActionType::APPEND_)
+    exe_util_lobupdate_tdb->setAppend(TRUE);
+  else
+    exe_util_lobupdate_tdb->setAppend(FALSE);
+
+  generator->initTdbFields(exe_util_lobupdate_tdb);
+
+  if (child_tdb)
+    exe_util_lobupdate_tdb->setChildTdb(child_tdb);
+
+  if(!generator->explainDisabled()) {
+    generator->setExplainTuple(
+       addExplainInfo(exe_util_lobupdate_tdb, childExplainTuple, 0, generator));
+  }
+ 
+  exe_util_lobupdate_tdb->setTotalBufSize(CmpCommon::getDefaultNumeric(LOB_MAX_CHUNK_MEM_SIZE));
+  exe_util_lobupdate_tdb->setLobMaxSize( CmpCommon::getDefaultNumeric(LOB_MAX_SIZE));
+  exe_util_lobupdate_tdb->setLobMaxChunkSize(CmpCommon::getDefaultNumeric(LOB_MAX_CHUNK_MEM_SIZE));
+  exe_util_lobupdate_tdb->setLobGCLimit(CmpCommon::getDefaultNumeric(LOB_GC_LIMIT_SIZE));
+                                           
+                                        
+  generator->setCriDesc(givenDesc, Generator::DOWN);
+  generator->setCriDesc(returnedDesc, Generator::UP);
+  generator->setGenObj(this, exe_util_lobupdate_tdb);
+
+  // Set the transaction flag.
+  if (xnNeeded())
+    {
+       generator->setTransactionFlag(-1);
+    }
+  
+  return 0;
+}
+
+/////////////////////////////////////////////////////////
+//
 // ExeUtilLobShowddl::codeGen()
 //
 /////////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/generator/GenRelMisc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenRelMisc.cpp b/core/sql/generator/GenRelMisc.cpp
index f48f1b3..d78f8f0 100644
--- a/core/sql/generator/GenRelMisc.cpp
+++ b/core/sql/generator/GenRelMisc.cpp
@@ -2507,6 +2507,11 @@ short RelRoot::codeGen(Generator * generator)
 	 {
 	   root_tdb->setSubqueryType(ComTdbRoot::SQL_STMT_LOB_EXTRACT);
 	 }
+       else if(exeUtil->getExeUtilType() == ExeUtilExpr::LOB_UPDATE_UTIL_)
+         {
+           root_tdb->setSubqueryType(ComTdbRoot::SQL_STMT_LOB_UPDATE_UTIL
+); 
+         }
 
       else if (exeUtil->isExeUtilQueryType())
 	{

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/optimizer/BindItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindItemExpr.cpp b/core/sql/optimizer/BindItemExpr.cpp
index d145a18..a2cf690 100644
--- a/core/sql/optimizer/BindItemExpr.cpp
+++ b/core/sql/optimizer/BindItemExpr.cpp
@@ -664,10 +664,12 @@ void ItemExpr::bindChildren(BindWA *bindWA)
 {
   Int32 savedCurrChildNo = currChildNo();
   for (Int32 i = 0; i < getArity(); i++, currChildNo()++) {
-
+   
     ItemExpr *boundExpr = child(i)->bindNode(bindWA);
     if (bindWA->errStatus()) return;
     child(i) = boundExpr;
+      
+      
   }
   currChildNo() = savedCurrChildNo;
 }
@@ -696,7 +698,7 @@ void ItemExpr::bindSelf(BindWA *bindWA)
   NABoolean defaultSpecBoundAsSQLnull = FALSE;
 
   for (Int32 i = 0; i < getArity(); i++, currChildNo()++) {
-
+   
     ItemExpr *boundExpr = child(i)->bindNode(bindWA);
     if (bindWA->errStatus()) 
       return;
@@ -707,10 +709,11 @@ void ItemExpr::bindSelf(BindWA *bindWA)
       }
 
     if (boundExpr->getOperatorType() == ITM_CONSTANT &&
-	((ConstValue *)boundExpr)->isNullWasDefaultSpec())
+        ((ConstValue *)boundExpr)->isNullWasDefaultSpec())
       defaultSpecBoundAsSQLnull = TRUE;
 
     child(i) = boundExpr;
+      
   }
 
   //##? Should   getOperatorType() != ITM_CAST		?##
@@ -1529,52 +1532,53 @@ ItemExpr* ItemExpr::tryToDoImplicitCasting(BindWA *bindWA)
   // Step 1: Determine if we have children with different character set attributes
   //
   for (Int32 i = 0; i < arity; i++) {
-
+    
     const NAType& type = child(i)->getValueId().getType();
     if ( type.getTypeQualifier() == NA_CHARACTER_TYPE )
-    {
-       curr_chld_cs = ((const CharType&)type).getCharSet();
-       if ( i==0 ) chld0_cs = curr_chld_cs;  // Remember this one
+      {
+        curr_chld_cs = ((const CharType&)type).getCharSet();
+        if ( i==0 ) chld0_cs = curr_chld_cs;  // Remember this one
 
-       Int16 cur_chld_cs_ndx = iUNK;
+        Int16 cur_chld_cs_ndx = iUNK;
 
-       switch ( curr_chld_cs )
-       {
-        case CharInfo::UNICODE :
-          cur_chld_cs_ndx = iUCS2;
-          break;
+        switch ( curr_chld_cs )
+          {
+          case CharInfo::UNICODE :
+            cur_chld_cs_ndx = iUCS2;
+            break;
 
-        case CharInfo::ISO88591:
-          cur_chld_cs_ndx = iISO;
-          break;
+          case CharInfo::ISO88591:
+            cur_chld_cs_ndx = iISO;
+            break;
 
-        case CharInfo::UTF8:
-          cur_chld_cs_ndx = iUTF8;
-          break;
+          case CharInfo::UTF8:
+            cur_chld_cs_ndx = iUTF8;
+            break;
 
-        case CharInfo::SJIS:
-          cur_chld_cs_ndx = iSJIS;
-          break;
+          case CharInfo::SJIS:
+            cur_chld_cs_ndx = iSJIS;
+            break;
 
-        case CharInfo::GBK:
-          cur_chld_cs_ndx = iGBK;
-          break;
+          case CharInfo::GBK:
+            cur_chld_cs_ndx = iGBK;
+            break;
 
-        //case CharInfo::KANJI_MP:
-        //case CharInfo::KSC5601_MP:
-        default:
-          break; // Can not translate these currently.
-       }
-       charsets_involved[cur_chld_cs_ndx]++;
+            //case CharInfo::KANJI_MP:
+            //case CharInfo::KSC5601_MP:
+          default:
+            break; // Can not translate these currently.
+          }
+        charsets_involved[cur_chld_cs_ndx]++;
 
-       OperatorTypeEnum curr_chld_opType = child(i)->getOperatorType();
-       if (i == 0 ) chld0_opType = curr_chld_opType;  // Remember this one
+        OperatorTypeEnum curr_chld_opType = child(i)->getOperatorType();
+        if (i == 0 ) chld0_opType = curr_chld_opType;  // Remember this one
 
-       if ( curr_chld_opType == ITM_CONSTANT )
+        if ( curr_chld_opType == ITM_CONSTANT )
           Literals_involved[cur_chld_cs_ndx] += 1 ;
-       else
+        else
           nonLiterals_involved[cur_chld_cs_ndx] += 1 ;
-    }
+      }
+      
   }
 
   for (Int32 j = 0; j < iUNK; j++)
@@ -3124,24 +3128,26 @@ ItemExpr *BuiltinFunction::bindNode(BindWA *bindWA)
       Int32 origArity = getArity();
       
       for (Int32 chld=0; chld < origArity; chld++)
-      {
-        switch (child(chld)->getOperatorType())
         {
-          case ITM_ROW_SUBQUERY:
-            subq = (Subquery *) child(chld)->castToItemExpr();
-            childDegree += subq->getSubquery()->getDegree();
-            break;
+       
+          switch (child(chld)->getOperatorType())
+            {
+            case ITM_ROW_SUBQUERY:
+              subq = (Subquery *) child(chld)->castToItemExpr();
+              childDegree += subq->getSubquery()->getDegree();
+              break;
             
-          case ITM_USER_DEF_FUNCTION:
-            udf = (UDFunction *) child(chld)->castToItemExpr();
-            childDegree += udf->getRoutineDesc()->getOutputColumnList().entries();
-            break;
+            case ITM_USER_DEF_FUNCTION:
+              udf = (UDFunction *) child(chld)->castToItemExpr();
+              childDegree += udf->getRoutineDesc()->getOutputColumnList().entries();
+              break;
             
-          default:
-            childDegree += 1;
-            break;
+            default:
+              childDegree += 1;
+              break;
+            }
+          
         }
-      }
       
       if (childDegree > origArity) 
       {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/optimizer/ItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemExpr.cpp b/core/sql/optimizer/ItemExpr.cpp
index aa0b722..eb14a39 100644
--- a/core/sql/optimizer/ItemExpr.cpp
+++ b/core/sql/optimizer/ItemExpr.cpp
@@ -12757,7 +12757,15 @@ ItemExpr * LOBupdate::copyTopNode(ItemExpr *derivedNode, CollHeap* outHeap)
 
   return LOBoper::copyTopNode(result, outHeap);
 }
-
+/*
+Int32 LOBupdate::getArity() const
+{
+  if (obj_ == EMPTY_LOB_)
+    return 0;
+  else
+    return getNumChildren();
+}
+*/
 ItemExpr * LOBconvert::copyTopNode(ItemExpr *derivedNode, CollHeap* outHeap)
 {
   ItemExpr *result;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/optimizer/ItemFunc.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemFunc.h b/core/sql/optimizer/ItemFunc.h
index 7493134..68245b6 100644
--- a/core/sql/optimizer/ItemFunc.h
+++ b/core/sql/optimizer/ItemFunc.h
@@ -2783,11 +2783,11 @@ public:
  enum ObjectType
  {
    STRING_, FILE_, BUFFER_, CHUNK_, STREAM_, LOB_, LOAD_, EXTERNAL_, 
-   EXTRACT_, NOOP_
+   EXTRACT_, EMPTY_LOB_,NOOP_
  };
 
  LOBoper(OperatorTypeEnum otype,
-	 ItemExpr *val1Ptr, ItemExpr *val2Ptr = NULL,ItemExpr *val3Ptr = NULL, 
+	 ItemExpr *val1Ptr=NULL, ItemExpr *val2Ptr = NULL,ItemExpr *val3Ptr = NULL, 
 	 ObjectType obj = NOOP_)
    : BuiltinFunction(otype,  CmpCommon::statementHeap(),
                      3, val1Ptr, val2Ptr,val3Ptr),
@@ -2800,10 +2800,14 @@ public:
      hdfsPort_((Lng32)CmpCommon::getDefaultNumeric(LOB_HDFS_PORT)),
      hdfsServer_( CmpCommon::getDefaultString(LOB_HDFS_SERVER))
    {
-     if ((obj == STRING_) || (obj == BUFFER_) || (obj == FILE_))
+     if ((obj == STRING_) || (obj == BUFFER_) || (obj == FILE_) )
        lobStorageType_ = Lob_HDFS_File;
      else if (obj == EXTERNAL_)
        lobStorageType_ = Lob_External_HDFS_File;
+     else if (obj == EMPTY_LOB_)
+       lobStorageType_ = Lob_Empty;
+     else
+       lobStorageType_ = Lob_Invalid_Storage;
     
    }
 
@@ -2979,7 +2983,7 @@ class LOBupdate : public LOBoper
   virtual short codeGen(Generator*);
   // method to do precode generation
   virtual ItemExpr * preCodeGen(Generator*);
-
+  // virtual Int32 getArity() const;
   NABoolean isAppend() { return append_; };
 
   Int64 & updatedTableObjectUID() { return objectUID_; }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/optimizer/NATable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.cpp b/core/sql/optimizer/NATable.cpp
index c119f78..b1157ac 100644
--- a/core/sql/optimizer/NATable.cpp
+++ b/core/sql/optimizer/NATable.cpp
@@ -5639,7 +5639,7 @@ NABoolean createNAFileSets(TrafDesc * table_desc       /*IN*/,
 	    short *lobNumList = new (heap_) short[getColumnCount()];
 	    short *lobTypList = new (heap_) short[getColumnCount()];
 	    char  **lobLocList = new (heap_) char*[getColumnCount()];
-
+            char  **lobColNameList = new (heap_) char*[getColumnCount()];
 	    const NAColumnArray &colArray = getNAColumnArray();
 	    NAColumn *nac = NULL;
 
@@ -5651,6 +5651,7 @@ NABoolean createNAFileSets(TrafDesc * table_desc       /*IN*/,
 		    if (nac->getType()->getTypeQualifier() == NA_LOB_TYPE)
 		    {
 			    lobLocList[j] = new (heap_) char[1024];
+                            lobColNameList[j] = new (heap_)char[256];
 			    j++;
 		    }
 	    }      
@@ -5672,7 +5673,7 @@ NABoolean createNAFileSets(TrafDesc * table_desc       /*IN*/,
 		     LOB_CLI_SELECT_CURSOR,
 		     lobNumList,
 		     lobTypList,
-		     lobLocList,(char *)lobHdfsServer,lobHdfsPort,0,FALSE);
+		     lobLocList,lobColNameList,(char *)lobHdfsServer,lobHdfsPort,0,FALSE);
 
 	    if (cliRC == 0)
 	    {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7baf325f/core/sql/optimizer/RelExeUtil.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelExeUtil.cpp b/core/sql/optimizer/RelExeUtil.cpp
index f2bf489..c568081 100644
--- a/core/sql/optimizer/RelExeUtil.cpp
+++ b/core/sql/optimizer/RelExeUtil.cpp
@@ -5689,6 +5689,98 @@ void ExeUtilLobExtract::pushdownCoveredExpr(const ValueIdSet & outputExpr,
 
 }
 
+
+// -----------------------------------------------------------------------
+// Member functions for class ExeUtilLobUpdate
+// -----------------------------------------------------------------------
+RelExpr * ExeUtilLobUpdate::copyTopNode(RelExpr *derivedNode, CollHeap* outHeap)
+{
+  ExeUtilLobUpdate *result;
+
+  if (derivedNode == NULL)
+    result = new (outHeap) ExeUtilLobUpdate(NULL, NOOP_,
+                                             0, 0,ERROR_IF_EXISTS_,NULL,
+					     outHeap);
+  else
+    result = (ExeUtilLobUpdate *) derivedNode;
+
+  result->handle_ = handle_;
+  result->fromType_ = fromType_;
+  result->bufAddr_ = bufAddr_;
+  result->updateSize_ = updateSize_;
+ 
+  return ExeUtilExpr::copyTopNode(result, outHeap);
+}
+
+RelExpr * ExeUtilLobUpdate::bindNode(BindWA *bindWA)
+{
+  if (nodeIsBound()) {
+    bindWA->getCurrentScope()->setRETDesc(getRETDesc());
+    return this;
+  }
+
+  // BindScope *currScope = bindWA->getCurrentScope();
+ 
+  //
+  // Bind the child nodes.
+  //
+  bindChildren(bindWA);
+  if (bindWA->errStatus())
+    return this;
+
+  //  currScope = bindWA->getCurrentScope();
+  // bindWA->getCurrentScope()->setRETDesc(getRETDesc());
+  
+  if (handle_)
+    {
+      handle_->bindNode(bindWA);
+      if (bindWA->errStatus())
+	return NULL;
+    }
+
+  RelExpr * boundExpr = ExeUtilExpr::bindNode(bindWA);
+  if (bindWA->errStatus())
+    return NULL;
+
+  return boundExpr;
+}
+
+void ExeUtilLobUpdate::transformNode(NormWA & normWARef,
+				      ExprGroupId & locationOfPointerToMe)
+{
+  RelExpr::transformNode(normWARef, locationOfPointerToMe);
+
+}
+
+RelExpr * ExeUtilLobUpdate::normalizeNode(NormWA & normWARef)
+{
+  
+  return RelExpr::normalizeNode(normWARef);
+}
+
+void ExeUtilLobUpdate::pushdownCoveredExpr(const ValueIdSet & outputExpr,
+					    const ValueIdSet & newExternalInputs,
+					    ValueIdSet & predicatesOnParent,
+					    const ValueIdSet * setOfValuesReqdByParent,
+					    Lng32 childIndex
+					    )
+{
+  ValueIdSet exprOnParent;
+
+  if (handle_) // && handle_->child(0))
+    {
+      exprOnParent += handle_->getValueId(); //child(0)->getValueId();
+    }
+
+  // ---------------------------------------------------------------------
+  RelExpr::pushdownCoveredExpr(outputExpr,
+                               newExternalInputs,
+                               predicatesOnParent,
+			       &exprOnParent,
+                               childIndex
+                               );
+
+}
 // -----------------------------------------------------------------------
 // Member functions for class ExeUtilLobShowddl
 // -----------------------------------------------------------------------



Mime
View raw message