New syntax to retrieve the LOB HDFS filename for both external and internal LOBs . Also added syntax to return starting offset of a particular LOB handle in the LOB Hdfs data file.
Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/a96968e4 Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/a96968e4 Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/a96968e4 Branch: refs/heads/master Commit: a96968e401666a99f36b1729597dab23dd87b74b Parents: 4904711 Author: Sandhya Sundaresan <[email protected]> Authored: Wed Jan 31 18:35:48 2018 +0000 Committer: Sandhya Sundaresan <[email protected]> Committed: Wed Jan 31 18:35:48 2018 +0000 ---------------------------------------------------------------------- core/sql/cli/Cli.cpp | 45 +++++++++-- core/sql/comexe/ComTdbExeUtil.h | 15 +++- core/sql/executor/ExExeUtil.h | 2 + core/sql/executor/ExExeUtilLoad.cpp | 85 +++++++++++++++++++-- core/sql/exp/ExpLOBaccess.cpp | 71 ++++++++++++++++++ core/sql/exp/ExpLOBaccess.h | 2 + core/sql/exp/ExpLOBenums.h | 4 +- core/sql/exp/ExpLOBexternal.h | 5 +- core/sql/exp/ExpLOBinterface.cpp | 115 +++++++++++++++++++++++++++++ core/sql/exp/ExpLOBinterface.h | 21 ++++++ core/sql/generator/GenRelExeUtil.cpp | 12 ++- core/sql/optimizer/RelExeUtil.h | 3 +- core/sql/parser/ParKeyWords.cpp | 1 + core/sql/parser/sqlparser.y | 54 ++++++++++++++ core/sql/regress/executor/EXPECTED130 | 96 ++++++++++++++---------- core/sql/regress/executor/TEST130 | 17 +++++ 16 files changed, 492 insertions(+), 56 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafodion/blob/a96968e4/core/sql/cli/Cli.cpp ---------------------------------------------------------------------- diff --git a/core/sql/cli/Cli.cpp b/core/sql/cli/Cli.cpp index a3ba081..d3892c6 100644 --- a/core/sql/cli/Cli.cpp +++ b/core/sql/cli/Cli.cpp @@ -9160,11 +9160,45 @@ Lng32 SQLCLI_LOBcliInterface Int64 outlen = 0;Lng32 len = 0; cliRC = cliInterface->executeImmediate(query,(char *)dataLen, &len, FALSE); - if (inoutDescPartnKey) - *inoutDescPartnKey = descPartnKey; + if (inoutDescPartnKey) + *inoutDescPartnKey = descPartnKey; - if (inoutDescSyskey) - *inoutDescSyskey = inDescSyskey; + if (inoutDescSyskey) + *inoutDescSyskey = inDescSyskey; + + Lng32 saveCliErr = cliRC; + + + if (cliRC < 0) + { + cliInterface->retrieveSQLDiagnostics(myDiags); + + goto error_return; + } + + cliRC = saveCliErr; + } + break; + case LOB_CLI_SELECT_LOBOFFSET: + { + + //Retrive offset of the first chunk + str_sprintf(query, "select c.dataOffset from table(ghost table %s) h, table(ghost table %s) c where h.descPartnKey = c.descPartnKey and h.syskey = c.descSyskey and h.descPartnKey = %ld and h.syskey = %ld and c.chunkNum = 1 for read committed access", + lobDescHandleName, lobDescChunksName, + descPartnKey, inDescSyskey); + + lobDebugInfo(query,0,__LINE__,lobTrace); + // set parserflags to allow ghost table + currContext.setSqlParserFlags(0x1); + + + Lng32 len = 0; + cliRC = cliInterface->executeImmediate(query,(char *)dataOffset, &len, FALSE); + if (inoutDescPartnKey) + *inoutDescPartnKey = descPartnKey; + + if (inoutDescSyskey) + *inoutDescSyskey = inDescSyskey; @@ -9180,8 +9214,7 @@ Lng32 SQLCLI_LOBcliInterface cliRC = saveCliErr; } - break; - + break; } // switch // normal return. Fall down to deallocate of structures. http://git-wip-us.apache.org/repos/asf/trafodion/blob/a96968e4/core/sql/comexe/ComTdbExeUtil.h ---------------------------------------------------------------------- diff --git a/core/sql/comexe/ComTdbExeUtil.h b/core/sql/comexe/ComTdbExeUtil.h index fd62fa5..fba4d7b 100644 --- a/core/sql/comexe/ComTdbExeUtil.h +++ b/core/sql/comexe/ComTdbExeUtil.h @@ -2798,7 +2798,8 @@ public: enum ExtractToType { TO_FILE_, TO_STRING_, TO_BUFFER_, TO_EXTERNAL_FROM_STRING_, - TO_EXTERNAL_FROM_FILE_, RETRIEVE_LENGTH_,NOOP_ + TO_EXTERNAL_FROM_FILE_, RETRIEVE_LENGTH_, RETRIEVE_HDFSFILENAME_, + RETRIEVE_OFFSET_,NOOP_ }; @@ -2879,7 +2880,13 @@ public: void setRetrieveLength(NABoolean v) {(v ? flags_ |= RETRIEVE_LENGTH : flags_ &= ~RETRIEVE_LENGTH); }; NABoolean retrieveLength() { return (flags_ & RETRIEVE_LENGTH) != 0; }; - + + void setRetrieveHdfsFileName(NABoolean v) + {(v ? flags_ |= RETRIEVE_HDFSFILENAME : flags_ &= ~RETRIEVE_HDFSFILENAME); }; + NABoolean retrieveHdfsFileName() { return (flags_ & RETRIEVE_HDFSFILENAME) != 0; }; + void setRetrieveOffset(NABoolean v) + {(v ? flags_ |= RETRIEVE_OFFSET : flags_ &= ~RETRIEVE_OFFSET); }; + NABoolean retrieveOffset() { return (flags_ & RETRIEVE_OFFSET) != 0; }; void setErrorIfNotExists(NABoolean v) {(v ? flags_ |= ERROR_IF_NOT_EXISTS : flags_ &= ~ERROR_IF_NOT_EXISTS); }; NABoolean errorIfNotExists() { return (flags_ & ERROR_IF_NOT_EXISTS) != 0; }; @@ -2913,7 +2920,9 @@ private: ERROR_IF_NOT_EXISTS =0x0010, ERROR_IF_EXISTS =0x0020, TRUNCATE_EXISTING = 0x0040, - APPEND_OR_CREATE = 0x0080 + APPEND_OR_CREATE = 0x0080, + RETRIEVE_HDFSFILENAME= 0x0100, + RETRIEVE_OFFSET=0x0200 }; http://git-wip-us.apache.org/repos/asf/trafodion/blob/a96968e4/core/sql/executor/ExExeUtil.h ---------------------------------------------------------------------- diff --git a/core/sql/executor/ExExeUtil.h b/core/sql/executor/ExExeUtil.h index d26f660..403f2f8 100644 --- a/core/sql/executor/ExExeUtil.h +++ b/core/sql/executor/ExExeUtil.h @@ -2943,6 +2943,8 @@ public: GET_NO_CHILD_HANDLE_, GET_LOB_HANDLE_, RETRIEVE_LOB_LENGTH_, + EXTRACT_HDFSFILENAME_, + RETRIEVE_OFFSET_, EXTRACT_LOB_DATA_, RETURN_STATUS_, SEND_REQ_TO_CHILD_, http://git-wip-us.apache.org/repos/asf/trafodion/blob/a96968e4/core/sql/executor/ExExeUtilLoad.cpp ---------------------------------------------------------------------- diff --git a/core/sql/executor/ExExeUtilLoad.cpp b/core/sql/executor/ExExeUtilLoad.cpp index 5d253cd..f311c64 100644 --- a/core/sql/executor/ExExeUtilLoad.cpp +++ b/core/sql/executor/ExExeUtilLoad.cpp @@ -3081,10 +3081,13 @@ short ExExeUtilLobExtractTcb::work() NADELETEBASIC(lobColNameList[0],getHeap()); NADELETEBASIC(lobNumList,getHeap()); NADELETEBASIC(lobTypList,getHeap()); - if (lobTdb().getToType() == ComTdbExeUtilLobExtract::TO_BUFFER_) + if (lobTdb().getToType() == ComTdbExeUtilLobExtract::RETRIEVE_HDFSFILENAME_) + step_ = EXTRACT_HDFSFILENAME_; + else if (lobTdb().getToType() == ComTdbExeUtilLobExtract::RETRIEVE_OFFSET_) + step_ = RETRIEVE_OFFSET_; + else if (lobTdb().getToType() == ComTdbExeUtilLobExtract::TO_BUFFER_) step_ = EXTRACT_LOB_DATA_; - else - if ((lobTdb().getToType() == ComTdbExeUtilLobExtract::RETRIEVE_LENGTH_) || (lobTdb().getToType() == ComTdbExeUtilLobExtract::TO_FILE_)) + else if ((lobTdb().getToType() == ComTdbExeUtilLobExtract::RETRIEVE_LENGTH_) || (lobTdb().getToType() == ComTdbExeUtilLobExtract::TO_FILE_)) step_ = RETRIEVE_LOB_LENGTH_; else { @@ -3101,6 +3104,42 @@ short ExExeUtilLobExtractTcb::work() } break; } + case EXTRACT_HDFSFILENAME_: + { + Int16 flags; + Lng32 lobNum; + Int64 uid, inDescSyskey, descPartnKey; + short schNameLen; + char schName[1024]={'\0'}; + char hdfsFileName[MAX_LOB_FILE_NAME_LEN]={'\0'}; + + Int32 fileNameLen = 0; + ExpLOBoper::extractFromLOBhandle(&flags, &lobType_, &lobNum, &uid, + &inDescSyskey, &descPartnKey, + &schNameLen, (char *)schName, + (char *)lobHandle_, (Lng32)lobHandleLen_); + + + lobName_ = ExpLOBoper::ExpGetLOBname(uid, lobNum, lobNameBuf_, 1000); + //Retrieve the filename of this lob using the handle info and return to the caller + retcode = ExpLOBInterfaceGetFileName( lobGlobs, + lobName_, + lobLoc_, + lobType_, + lobTdb().getLobHdfsServer(), + lobTdb().getLobHdfsPort(), + lobHandleLen_, lobHandle_, + hdfsFileName, + fileNameLen); + + if ((lobTdb().getBufAddr() != -1) && (lobTdb().getBufAddr() != 0)) + str_cpy_all((char *)lobTdb().getBufAddr(), (char *)&lobDataLen_,sizeof(Int64)); + str_sprintf(statusString_," LOB filename : %s", hdfsFileName); + step_ = RETURN_STATUS_; + break; + + } + break; case RETRIEVE_LOB_LENGTH_ : { Int16 flags; @@ -3108,6 +3147,7 @@ short ExExeUtilLobExtractTcb::work() Int64 uid, inDescSyskey, descPartnKey; short schNameLen; char schName[1024]; + ExpLOBoper::extractFromLOBhandle(&flags, &lobType_, &lobNum, &uid, &inDescSyskey, &descPartnKey, &schNameLen, (char *)schName, @@ -3140,6 +3180,43 @@ short ExExeUtilLobExtractTcb::work() break; } + case RETRIEVE_OFFSET_ : + { + Int16 flags; + Lng32 lobNum; + Int64 uid, inDescSyskey, descPartnKey; + short schNameLen; + char schName[1024]; + Int64 lobOffset = 0; + + ExpLOBoper::extractFromLOBhandle(&flags, &lobType_, &lobNum, &uid, + &inDescSyskey, &descPartnKey, + &schNameLen, (char *)schName, + (char *)lobHandle_, (Lng32)lobHandleLen_); + + + lobName_ = ExpLOBoper::ExpGetLOBname(uid, lobNum, lobNameBuf_, 1000); + + //Retrieve the total length of this lob using the handle info and return to the caller + + retcode = ExpLOBInterfaceGetOffset( lobGlobs, + lobName_, + lobLoc_, + lobType_, + lobTdb().getLobHdfsServer(), + lobTdb().getLobHdfsPort(), + lobHandleLen_, lobHandle_, + lobOffset); + + + if ((lobTdb().getBufAddr() != -1) && (lobTdb().getBufAddr() != 0)) + str_cpy_all((char *)lobTdb().getBufAddr(), (char *)&lobOffset,sizeof(Int64)); + str_sprintf(statusString_," LOB Offset : %ld", lobOffset); + step_ = RETURN_STATUS_; + break; + + + } case EXTRACT_LOB_DATA_ : { Int16 flags; @@ -3223,8 +3300,6 @@ short ExExeUtilLobExtractTcb::work() } break; - - case OPEN_CURSOR_: { retcode = ExpLOBInterfaceSelectCursor http://git-wip-us.apache.org/repos/asf/trafodion/blob/a96968e4/core/sql/exp/ExpLOBaccess.cpp ---------------------------------------------------------------------- diff --git a/core/sql/exp/ExpLOBaccess.cpp b/core/sql/exp/ExpLOBaccess.cpp index 6b13f86..df6b4ea 100644 --- a/core/sql/exp/ExpLOBaccess.cpp +++ b/core/sql/exp/ExpLOBaccess.cpp @@ -870,6 +870,67 @@ Ex_Lob_Error ExLob::getLength(char *handleIn, Int32 handleInLen,Int64 &outLobLen } return err; } +Ex_Lob_Error ExLob::getOffset(char *handleIn, Int32 handleInLen,Int64 &outLobOffset,LobsSubOper so, Int64 transId) +{ + char logBuf[4096]; + Int32 cliErr = 0; + Ex_Lob_Error err=LOB_OPER_OK; + char *blackBox = new(getLobGlobalHeap()) char[MAX_LOB_FILE_NAME_LEN+6]; + Int32 blackBoxLen = 0; + Int64 dummy = 0; + Int32 dummy2 = 0; + if (so != Lob_External_File) + { + + cliErr = SQL_EXEC_LOBcliInterface(handleIn, handleInLen,NULL,NULL,NULL,NULL,LOB_CLI_SELECT_LOBOFFSET,LOB_CLI_ExecImmed,&outLobOffset,0, 0, 0,0,transId,lobTrace_); + + if (cliErr < 0 ) { + str_sprintf(logBuf,"CLI SELECT_LOBOFFSET returned error %d",cliErr); + lobDebugInfo(logBuf, 0,__LINE__,lobTrace_); + + return LOB_DESC_READ_ERROR; + } + } + + return err; +} + +Ex_Lob_Error ExLob::getFileName(char *handleIn, Int32 handleInLen, char *outFileName, Int32 &outFileLen , LobsSubOper so, Int64 transId) +{ + char logBuf[4096]; + Int32 cliErr = 0; + Ex_Lob_Error err=LOB_OPER_OK; + Int64 dummy = 0; + Int32 dummy2 = 0; + if (so != Lob_External_File) + { + //Derive the filename from the LOB handle and return + str_cpy_all(outFileName, (char *)lobDataFile_.data(),lobDataFile_.length()); + } + else + { + //Get the lob external filename from the descriptor file + cliErr = SQL_EXEC_LOBcliInterface(handleIn, + handleInLen, + (char *)outFileName, &outFileLen, + NULL, 0, + LOB_CLI_SELECT_UNIQUE, LOB_CLI_ExecImmed, + &dummy, &dummy, + &dummy, &dummy, + 0, + transId,lobTrace_); + if (cliErr < 0 ) { + str_sprintf(logBuf,"CLI SELECT_FILENAME returned error %d",cliErr); + lobDebugInfo(logBuf, 0,__LINE__,lobTrace_); + + return LOB_DESC_READ_ERROR; + } + + } + return err; +} + + Ex_Lob_Error ExLob::writeDesc(Int64 &sourceLen, char *source, LobsSubOper subOper, Int64 &descNumOut, Int64 &operLen, Int64 lobMaxSize,Int64 lobMaxChunkMemSize,Int64 lobGCLimit, char * handleIn, Int32 handleInLen, char *blackBox, Int32 *blackBoxLen, char *handleOut, Int32 &handleOutLen, Int64 xnId, void *lobGlobals) { Ex_Lob_Error err=LOB_OPER_OK; @@ -2744,6 +2805,16 @@ Ex_Lob_Error ExLobsOper ( err = lobPtr->getLength(handleIn, handleInLen,retOperLen,subOperation,transId); } break; + case Lob_GetOffset: + { + err = lobPtr->getOffset(handleIn, handleInLen,retOperLen,subOperation,transId); + } + break; + case Lob_GetFileName: + { + err = lobPtr->getFileName(handleIn, handleInLen, (char *)blackBox, blackBoxLen, subOperation, transId); + } + break; case Lob_ReadDesc: // read desc only. Needed for pass thru. err = lobPtr->getDesc(desc,handleIn,handleInLen,(char *)blackBox, &blackBoxLen,handleOut,handleOutLen,transId); retOperLen = 0; http://git-wip-us.apache.org/repos/asf/trafodion/blob/a96968e4/core/sql/exp/ExpLOBaccess.h ---------------------------------------------------------------------- diff --git a/core/sql/exp/ExpLOBaccess.h b/core/sql/exp/ExpLOBaccess.h index 9604aab..47f06df 100644 --- a/core/sql/exp/ExpLOBaccess.h +++ b/core/sql/exp/ExpLOBaccess.h @@ -497,6 +497,8 @@ class ExLob : public NABasicObject ExLobStats *getStats() { return &stats_; } NAHeap *getLobGlobalHeap() { return lobGlobalHeap_;} Ex_Lob_Error getLength(char *handleIn, Int32 handleInLen,Int64 &outLobLen,LobsSubOper so, Int64 transId); + Ex_Lob_Error getOffset(char *handleIn, Int32 handleInLen,Int64 &outOffset,LobsSubOper so, Int64 transId); + Ex_Lob_Error getFileName(char *handleIn, Int32 handleInLen, char *outFileName, Int32 &outFileLen, LobsSubOper so, Int64 transId); // ExLobRequest *getRequest() { return &request_; } //The next 2 functions are not active at this point. They serve as an example http://git-wip-us.apache.org/repos/asf/trafodion/blob/a96968e4/core/sql/exp/ExpLOBenums.h ---------------------------------------------------------------------- diff --git a/core/sql/exp/ExpLOBenums.h b/core/sql/exp/ExpLOBenums.h index d04b080..9c14daf 100644 --- a/core/sql/exp/ExpLOBenums.h +++ b/core/sql/exp/ExpLOBenums.h @@ -260,7 +260,9 @@ typedef enum { Lob_PerformGC, Lob_RestoreLobDataFile, Lob_PurgeBackupLobDataFile, - Lob_GetLength + Lob_GetLength, + Lob_GetFileName, + Lob_GetOffset } LobsOper; http://git-wip-us.apache.org/repos/asf/trafodion/blob/a96968e4/core/sql/exp/ExpLOBexternal.h ---------------------------------------------------------------------- diff --git a/core/sql/exp/ExpLOBexternal.h b/core/sql/exp/ExpLOBexternal.h index 1bfd33e..657ef12 100644 --- a/core/sql/exp/ExpLOBexternal.h +++ b/core/sql/exp/ExpLOBexternal.h @@ -96,7 +96,10 @@ enum LOBcliQueryType LOB_CLI_SELECT_LOBLENGTH, // performs GC of lob file - LOB_CLI_PERFORM_LOB_GC + LOB_CLI_PERFORM_LOB_GC, + + //returns beginning offset of a lob + LOB_CLI_SELECT_LOBOFFSET }; http://git-wip-us.apache.org/repos/asf/trafodion/blob/a96968e4/core/sql/exp/ExpLOBinterface.cpp ---------------------------------------------------------------------- diff --git a/core/sql/exp/ExpLOBinterface.cpp b/core/sql/exp/ExpLOBinterface.cpp index 718538e..8e73864 100644 --- a/core/sql/exp/ExpLOBinterface.cpp +++ b/core/sql/exp/ExpLOBinterface.cpp @@ -1050,6 +1050,121 @@ Lng32 ExpLOBInterfaceGetLobLength(ExLobGlobals * exLobGlob, return LOB_ACCESS_SUCCESS; } + +Lng32 ExpLOBInterfaceGetOffset(ExLobGlobals * exLobGlob, + char * lobName, + char * lobLoc, + Lng32 lobType, + char * lobHdfsServer, + Lng32 lobHdfsPort, + Int32 handleLen, + char * lobHandle, + Int64 &outLobOffset + + ) +{ + Ex_Lob_Error err; + + Int64 dummyParam = 0; + Int32 dummyParam2 = 0; + Ex_Lob_Error status; + Int64 cliError=0; + + LobsOper lo; + LobsSubOper so; + LobsStorage ls = (LobsStorage)lobType; + if (ls == Lob_External_HDFS_File) + { + so = Lob_External_File; + outLobOffset = 0; + return LOB_ACCESS_SUCCESS; + } + else + so = Lob_Buffer; + err = ExLobsOper(lobName, + lobHandle, handleLen, + lobHdfsServer, lobHdfsPort, + NULL, dummyParam2, + dummyParam, dummyParam, + outLobOffset, + dummyParam, dummyParam, + status, cliError, + lobLoc, ls, //Lob_HDFS_File, + NULL, 0, + dummyParam,NULL, + Lob_GetOffset, + so, + TRUE, + exLobGlob, + 0, + 0, 0,0,0,0,0,0,0, + 0 + ); + + if (err != LOB_OPER_OK) + { + return -err; + } + + return LOB_ACCESS_SUCCESS; +} + +Lng32 ExpLOBInterfaceGetFileName(ExLobGlobals * exLobGlob, + char * lobName, + char * lobLoc, + Lng32 lobType, + char * lobHdfsServer, + Lng32 lobHdfsPort, + Int32 handleLen, + char * lobHandle, + char * fileName, + Int32 &outFileLen + + ) +{ + Ex_Lob_Error err; + + Int64 dummyParam = 0; + Int32 dummyParam2 = 0; + Ex_Lob_Error status; + Int64 cliError=0; + Int64 hdfsFileLen = 0; + LobsOper lo; + LobsSubOper so; + LobsStorage ls = (LobsStorage)lobType; + if (ls == Lob_External_HDFS_File) + so = Lob_External_File; + else + so = Lob_Buffer; + err = ExLobsOper(lobName, + lobHandle, handleLen, + lobHdfsServer, lobHdfsPort, + NULL, dummyParam2, + dummyParam, dummyParam, + dummyParam, + dummyParam, dummyParam, + status, cliError, + lobLoc, ls, //Lob_HDFS_File, + NULL, 0, + dummyParam,NULL, + Lob_GetFileName, + so, + TRUE, + exLobGlob, + 0, + fileName, outFileLen, + 0,0,0,0,0,0, + 0 + ); + + if (err != LOB_OPER_OK) + { + return -err; + } + + + return LOB_ACCESS_SUCCESS; +} Lng32 ExpLOBinterfaceStats( ExLobGlobals * exLobGlob, ExLobStats * lobStats, http://git-wip-us.apache.org/repos/asf/trafodion/blob/a96968e4/core/sql/exp/ExpLOBinterface.h ---------------------------------------------------------------------- diff --git a/core/sql/exp/ExpLOBinterface.h b/core/sql/exp/ExpLOBinterface.h index fa4694d..c8a8591 100644 --- a/core/sql/exp/ExpLOBinterface.h +++ b/core/sql/exp/ExpLOBinterface.h @@ -342,7 +342,28 @@ Lng32 ExpLOBInterfaceGetLobLength(ExLobGlobals * exLobGlob, Int64 &outLobLen ); +Lng32 ExpLOBInterfaceGetFileName(ExLobGlobals * exLobGlob, + char * lobName, + char * lobLoc, + Lng32 lobType, + char * lobHdfsServer, + Lng32 lobHdfsPort, + Int32 handleLen, + char * lobHandle, + char * outFileName, + Int32 &outFileLen); +Lng32 ExpLOBInterfaceGetOffset(ExLobGlobals * exLobGlob, + char * lobName, + char * lobLoc, + Lng32 lobType, + char * lobHdfsServer, + Lng32 lobHdfsPort, + Int32 handleLen, + char * lobHandle, + Int64 &outLobOffset + + ); /* class HdfsFileInfo http://git-wip-us.apache.org/repos/asf/trafodion/blob/a96968e4/core/sql/generator/GenRelExeUtil.cpp ---------------------------------------------------------------------- diff --git a/core/sql/generator/GenRelExeUtil.cpp b/core/sql/generator/GenRelExeUtil.cpp index 21275d1..c667f99 100644 --- a/core/sql/generator/GenRelExeUtil.cpp +++ b/core/sql/generator/GenRelExeUtil.cpp @@ -4165,11 +4165,13 @@ short ExeUtilLobExtract::codeGen(Generator * generator) handleLen, (toType_ == TO_BUFFER_ ? ComTdbExeUtilLobExtract::TO_BUFFER_ : (toType_ == RETRIEVE_LENGTH_ ? ComTdbExeUtilLobExtract::RETRIEVE_LENGTH_ : + (toType_ == RETRIEVE_HDFSFILENAME_ ? ComTdbExeUtilLobExtract::RETRIEVE_HDFSFILENAME_ : + (toType_ == RETRIEVE_OFFSET_ ? ComTdbExeUtilLobExtract::RETRIEVE_OFFSET_ : (toType_ == TO_STRING_ ? ComTdbExeUtilLobExtract::TO_STRING_ : (toType_ == TO_FILE_ ? ComTdbExeUtilLobExtract::TO_FILE_ : (toType_ == TO_EXTERNAL_FROM_STRING_ ? ComTdbExeUtilLobExtract::TO_EXTERNAL_FROM_STRING_ : (toType_ == TO_EXTERNAL_FROM_FILE_ ? ComTdbExeUtilLobExtract::TO_EXTERNAL_FROM_FILE_ : - ComTdbExeUtilLobExtract::NOOP_)))))), + ComTdbExeUtilLobExtract::NOOP_)))))))), bufAddr_, extractSizeAddr_, intParam_, @@ -4226,6 +4228,14 @@ if (handleInStringFormat_) { exe_util_tdb->setRetrieveLength(TRUE); } + if (toType_ == RETRIEVE_HDFSFILENAME_) + { + exe_util_tdb->setRetrieveHdfsFileName(TRUE); + } + if (toType_ == RETRIEVE_OFFSET_) + { + exe_util_tdb->setRetrieveOffset(TRUE); + } exe_util_tdb->setTotalBufSize(CmpCommon::getDefaultNumeric(LOB_MAX_CHUNK_MEM_SIZE)*1024*1024); generator->setCriDesc(givenDesc, Generator::DOWN); http://git-wip-us.apache.org/repos/asf/trafodion/blob/a96968e4/core/sql/optimizer/RelExeUtil.h ---------------------------------------------------------------------- diff --git a/core/sql/optimizer/RelExeUtil.h b/core/sql/optimizer/RelExeUtil.h index db5855a..73d6ed7 100644 --- a/core/sql/optimizer/RelExeUtil.h +++ b/core/sql/optimizer/RelExeUtil.h @@ -2089,7 +2089,8 @@ public: enum ExtractToType { TO_FILE_, TO_STRING_, TO_BUFFER_, TO_EXTERNAL_FROM_STRING_, - TO_EXTERNAL_FROM_FILE_, RETRIEVE_LENGTH_, NOOP_ + TO_EXTERNAL_FROM_FILE_, RETRIEVE_LENGTH_, RETRIEVE_HDFSFILENAME_, + RETRIEVE_OFFSET_,NOOP_ }; enum ExtractFileActionType { http://git-wip-us.apache.org/repos/asf/trafodion/blob/a96968e4/core/sql/parser/ParKeyWords.cpp ---------------------------------------------------------------------- diff --git a/core/sql/parser/ParKeyWords.cpp b/core/sql/parser/ParKeyWords.cpp index f604c23..9b07316 100644 --- a/core/sql/parser/ParKeyWords.cpp +++ b/core/sql/parser/ParKeyWords.cpp @@ -428,6 +428,7 @@ ParKeyWord ParKeyWords::keyWords_[] = { ParKeyWord("FEATURE_VERSION_INFO",TOK_FEATURE_VERSION_INFO, NONRESTOKEN_), ParKeyWord("FETCH", TOK_FETCH, ANS_|RESWORD_|MPWORD_), ParKeyWord("FILE", TOK_FILE, NONRESTOKEN_), + ParKeyWord("FILENAME", TOK_FILENAME, NONRESTOKEN_), ParKeyWord("FILETOLOB", TOK_FILETOLOB, NONRESTOKEN_), ParKeyWord("FILETOEXTERNAL", TOK_FILETOEXTERNAL, NONRESTOKEN_), ParKeyWord("FINAL", TOK_FINAL, NONRESTOKEN_), http://git-wip-us.apache.org/repos/asf/trafodion/blob/a96968e4/core/sql/parser/sqlparser.y ---------------------------------------------------------------------- diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y index 2c805da..0c3cddf 100755 --- a/core/sql/parser/sqlparser.y +++ b/core/sql/parser/sqlparser.y @@ -750,6 +750,7 @@ static void enableMakeQuotedStringISO88591Mechanism() %token <tokval> TOK_EXTERNALTOSTRING %token <tokval> TOK_EMPTY_BLOB %token <tokval> TOK_EMPTY_CLOB +%token <tokval> TOK_FILENAME %token <tokval> TOK_INSERT %token <tokval> TOK_INSERT_ONLY %token <tokval> TOK_INS @@ -15930,6 +15931,59 @@ exe_util_lob_extract : TOK_EXTRACT TOK_LOBLENGTH '(' TOK_LOB QUOTED_STRING ')' $$ = lle; } +/* type relx */ +exe_util_lob_extract : TOK_EXTRACT TOK_FILENAME'(' TOK_LOB QUOTED_STRING ')' TOK_LOCATION NUMERIC_LITERAL_EXACT_NO_SCALE + { + ConstValue * handle = new(PARSERHEAP()) ConstValue(*$5); + Int64 returnFilenameAddr = atoInt64($8->data()); + ExeUtilLobExtract * lle = + new (PARSERHEAP ()) ExeUtilLobExtract + (handle, + ExeUtilLobExtract::RETRIEVE_HDFSFILENAME_, + returnFilenameAddr, 0, 0, 0); + + $$ = lle; + } +/* type relx */ +exe_util_lob_extract : TOK_EXTRACT TOK_FILENAME '(' TOK_LOB QUOTED_STRING ')' + { + ConstValue * handle = new(PARSERHEAP()) ConstValue(*$5); + + ExeUtilLobExtract * lle = + new (PARSERHEAP ()) ExeUtilLobExtract + (handle, + ExeUtilLobExtract::RETRIEVE_HDFSFILENAME_, + -1, 0, 0, 0); + + $$ = lle; + } +/* type relx */ +exe_util_lob_extract : TOK_EXTRACT TOK_OFFSET'(' TOK_LOB QUOTED_STRING ')' TOK_LOCATION NUMERIC_LITERAL_EXACT_NO_SCALE + { + ConstValue * handle = new(PARSERHEAP()) ConstValue(*$5); + Int64 returnOffsetAddr = atoInt64($8->data()); + ExeUtilLobExtract * lle = + new (PARSERHEAP ()) ExeUtilLobExtract + (handle, + ExeUtilLobExtract::RETRIEVE_OFFSET_, + returnOffsetAddr, 0, 0, 0); + + $$ = lle; + } +/* type relx */ +exe_util_lob_extract : TOK_EXTRACT TOK_OFFSET '(' TOK_LOB QUOTED_STRING ')' + { + ConstValue * handle = new(PARSERHEAP()) ConstValue(*$5); + + ExeUtilLobExtract * lle = + new (PARSERHEAP ()) ExeUtilLobExtract + (handle, + ExeUtilLobExtract::RETRIEVE_OFFSET_, + -1, 0, 0, 0); + + $$ = lle; + } + | TOK_EXTRACT TOK_LOBTOSTRING '(' TOK_LOB QUOTED_STRING ',' TOK_SIZE NUMERIC_LITERAL_EXACT_NO_SCALE ')' {
