You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by an...@apache.org on 2016/10/07 23:05:39 UTC
[2/8] incubator-trafodion git commit: similarity check changes,
commit #1
similarity check changes, commit #1
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/074428ed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/074428ed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/074428ed
Branch: refs/heads/master
Commit: 074428ed74a9b90a3c131007e7ecdeac6720ea99
Parents: 70f7fc0
Author: Anoop Sharma <an...@esgyn.com>
Authored: Mon Oct 3 18:55:39 2016 +0000
Committer: Anoop Sharma <an...@esgyn.com>
Committed: Mon Oct 3 18:55:39 2016 +0000
----------------------------------------------------------------------
core/sql/arkcmp/CmpContext.cpp | 1 -
core/sql/arkcmp/CmpContext.h | 8 -
core/sql/arkcmp/CmpStatement.cpp | 5 +-
core/sql/cli/Cli.cpp | 99 --
core/sql/cli/Cli.h | 16 -
core/sql/cli/CliExtern.cpp | 51 -
core/sql/cli/ExSqlComp.cpp | 8 +-
core/sql/cli/Statement.cpp | 1310 ++--------------------
core/sql/cli/Statement.h | 44 +-
core/sql/comexe/CmpMessage.cpp | 28 +-
core/sql/comexe/CmpMessage.h | 7 +-
core/sql/comexe/ComTdbRoot.cpp | 9 +-
core/sql/comexe/ComTdbRoot.h | 9 +-
core/sql/comexe/LateBindInfo.cpp | 391 ++-----
core/sql/comexe/LateBindInfo.h | 679 ++---------
core/sql/executor/ExExeUtilMisc.cpp | 5 +-
core/sql/executor/ExFastTransport.cpp | 13 +-
core/sql/executor/ExFastTransport.h | 4 +-
core/sql/executor/ExHdfsScan.cpp | 5 +-
core/sql/executor/Ex_esp_msg.h | 40 -
core/sql/executor/ex_control.cpp | 2 +-
core/sql/executor/ex_ddl.cpp | 3 -
core/sql/executor/ex_esp_frag_dir.cpp | 11 -
core/sql/executor/ex_esp_msg.cpp | 243 ----
core/sql/executor/ex_frag_rt.cpp | 33 -
core/sql/executor/ex_globals.cpp | 2 +
core/sql/exp/ExpLOBaccess.cpp | 119 +-
core/sql/exp/ExpLOBaccess.h | 14 +-
core/sql/exp/ExpLOBinterface.cpp | 31 +-
core/sql/exp/ExpLOBinterface.h | 9 +-
core/sql/generator/GenExplain.cpp | 2 +-
core/sql/generator/GenFastTransport.cpp | 25 +-
core/sql/generator/GenRelExeUtil.cpp | 7 +-
core/sql/generator/GenRelMisc.cpp | 102 +-
core/sql/generator/GenRelScan.cpp | 45 +-
core/sql/generator/Generator.cpp | 16 +
core/sql/generator/Generator.h | 10 +
core/sql/optimizer/RelExeUtil.h | 2 +-
core/sql/optimizer/RelMisc.h | 3 +-
core/sql/parser/SqlParserAux.cpp | 21 -
core/sql/parser/SqlParserAux.h | 4 -
core/sql/parser/sqlparser.y | 90 +-
core/sql/regress/tools/regress-filter-linux | 2 +-
core/sql/sqlcomp/DefaultConstants.h | 6 +-
core/sql/sqlcomp/nadefaults.cpp | 16 +-
45 files changed, 583 insertions(+), 2967 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/074428ed/core/sql/arkcmp/CmpContext.cpp
----------------------------------------------------------------------
diff --git a/core/sql/arkcmp/CmpContext.cpp b/core/sql/arkcmp/CmpContext.cpp
index 33da08b..1ff5c9c 100644
--- a/core/sql/arkcmp/CmpContext.cpp
+++ b/core/sql/arkcmp/CmpContext.cpp
@@ -175,7 +175,6 @@ CmpContext::CmpContext(UInt32 f, CollHeap * h)
diags_ = ComDiagsArea::allocate(heap_);
SqlParser_Diags = diags_;
- recompLateNameInfoList_ = NULL;
char* streamName;
outFstream_ = NULL;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/074428ed/core/sql/arkcmp/CmpContext.h
----------------------------------------------------------------------
diff --git a/core/sql/arkcmp/CmpContext.h b/core/sql/arkcmp/CmpContext.h
index eaed39a..37d2df7 100644
--- a/core/sql/arkcmp/CmpContext.h
+++ b/core/sql/arkcmp/CmpContext.h
@@ -351,8 +351,6 @@ public :
CursorSelectColumns staticCursors_;
CollIndex saveRetrievedCols_;
- void * &recompLateNameInfoList() { return recompLateNameInfoList_; };
-
// get/set storage for SQLMX_REGRESS environment variable
Int32 getSqlmxRegress() const { return sqlmxRegress_; }
void setSqlmxRegress(Int32 regressEnvVar) { sqlmxRegress_ = regressEnvVar; }
@@ -535,12 +533,6 @@ private:
// See methods isInternalMdf and isInternalModName in arkcmp/StaticCompiler.C.
InternalCompileEnum internalCompile_;
- // pointer to class executor/ex_latebind.h/RecompLateNameInfoList.
- // Used to get to the actual name of a host/env var at recomp time
- // that was originally specified
- // as a PROTOTYPE value for table name at compile time.
- void * recompLateNameInfoList_;
-
// Node and Disk autonomy must distinguish run-time compiles.
NABoolean isRuntimeCompile_;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/074428ed/core/sql/arkcmp/CmpStatement.cpp
----------------------------------------------------------------------
diff --git a/core/sql/arkcmp/CmpStatement.cpp b/core/sql/arkcmp/CmpStatement.cpp
index 070a1a5..5067d41 100644
--- a/core/sql/arkcmp/CmpStatement.cpp
+++ b/core/sql/arkcmp/CmpStatement.cpp
@@ -326,13 +326,10 @@ static NABoolean processRecvdCmpCompileInfo(CmpStatement *cmpStmt,
NABoolean &aqrPrepare,
NABoolean &standaloneQuery)
{
- RecompLateNameInfoList * rlnil = NULL;
char * catSchStr = NULL;
- cmpInfo->getUnpackedFields(sqlStr, rlnil, catSchStr, recompControlInfo);
+ cmpInfo->getUnpackedFields(sqlStr, catSchStr, recompControlInfo);
sqlStrLen = cmpInfo->getSqlTextLen();
- context->recompLateNameInfoList() = rlnil;
-
catSchNameRecvd = FALSE;
nametypeNsk = FALSE;
odbcProcess = FALSE;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/074428ed/core/sql/cli/Cli.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/Cli.cpp b/core/sql/cli/Cli.cpp
index 8f2189b..c57f650 100644
--- a/core/sql/cli/Cli.cpp
+++ b/core/sql/cli/Cli.cpp
@@ -11000,105 +11000,6 @@ Lng32 SQLCLI_LOBddlInterface
return 0;
}
-#ifdef __ignore
-Lng32 SQLCLI_LOBloader2sqlInterface
-(
- /*IN*/ CliGlobals *cliGlobals,
- /*IN*/ char * lobHandle,
- /*IN*/ Lng32 lobHandleLen,
- /*IN*/ char * lobInfo,
- /*IN*/ Lng32 lobInfoLen,
- /*IN*/ LOBcliQueryType qType,
- /*INOUT*/ char * dataLoc, /* IN: for load, OUT: for extract */
- /*INOUT*/ Int64 &dataLen, /* length of data. 0 indicates EOD */
- /*INOUT*/ void* *cliInterface /* INOUT: if returned, save it and
- pass it back in on the next call */
-
- )
-{
- ContextCli & currContext = *(cliGlobals->currContext());
- ComDiagsArea & diags = currContext.diags();
-
- if (! currContext.currLobGlobals())
- {
- currContext.currLobGlobals() =
- new(currContext.exHeap()) LOBglobals(currContext.exHeap());
- ExpLOBoper::initLOBglobal
- (currContext.currLobGlobals()->lobAccessGlobals(), currContext.exHeap(),currContext);
- }
- void * lobGlobs = currContext.currLobGlobals()->lobAccessGlobals();
- Int16 flags;
- Lng32 lobType, lobNum;
- Int64 uid, inDescSyskey, descPartnKey;
- short schNameLen;
- char schName[512];
- ExpLOBoper::extractFromLOBhandle(&flags, &lobType, &lobNum, &uid,
- &inDescSyskey, &descPartnKey,
- &schNameLen, schName,
- lobHandle);
-
- char tgtLobNameBuf[100];
- char * tgtLobName =
- ExpLOBoper::ExpGetLOBname(uid, lobNum, tgtLobNameBuf, 100);
-
- Lng32 cliRC = 0;
-
- LOBcliQueryType saveQtype = qType;
-
- switch (qType)
- {
- case LOB_DATA_LOAD:
- {
- // temp until lobStorageLocation is passed in.
- char llb[100];
- strcpy(llb, lobInfo);
- char * lobLoc = llb;
-
- Int64 descSyskey = -1;
- Int64 requestTag = -1;
- Lng32 cliError = 0;
- cliRC = ExpLOBInterfaceInsert(lobGlobs,
- tgtLobName,
- lobLoc,
- lobType,
- NULL, 0,
-
- lobHandleLen, lobHandle,
- NULL, NULL,
- 0, NULL,
- requestTag,
- 0,
- inDescSyskey,
- Lob_InsertDataSimple,
- &cliError,
- Lob_Memory,
-
- 1, // waited
- dataLoc,
- dataLen);
-
- if (cliRC < 0)
- {
- Lng32 intParam1 = -cliRC;
- ComDiagsArea * da = &diags;
- ExRaiseSqlError(currContext.exHeap(), &da,
- (ExeErrorCode)(8442), NULL, &intParam1,
- &cliError, NULL, (char*)"ExpLOInterfaceInsert",
- getLobErrStr(intParam1));
- goto error_return;
- }
-
- }
- break;
-
- } // switch
-
- // normal return. Fall down to deallocate of structures.
-
- error_return:
- return (cliRC < 0 ? cliRC : 0);
-}
-#endif
/*
Int32 SQLCLI_SWITCH_TO_COMPILER_TYPE(CliGlobals * cliGlobals,
Int32 compiler_class_type)
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/074428ed/core/sql/cli/Cli.h
----------------------------------------------------------------------
diff --git a/core/sql/cli/Cli.h b/core/sql/cli/Cli.h
index 1e48be1..86ddaca 100644
--- a/core/sql/cli/Cli.h
+++ b/core/sql/cli/Cli.h
@@ -940,22 +940,6 @@ Lng32 SQLCLI_LOBddlInterface
/*IN*/ NABoolean lobTrace
);
-#ifdef __ignore
-Lng32 SQLCLI_LOBloader2sqlInterface
-(
- /*IN*/ CliGlobals *cliGlobals,
- /*IN*/ char * lobHandle,
- /*IN*/ Lng32 lobHandleLen,
- /*IN*/ char * lobInfo,
- /*IN*/ Lng32 lobInfoLen,
- /*IN*/ LOBcliQueryType qType,
- /*INOUT*/ char * dataLoc, /* IN: for load, OUT: for extract */
- /*INOUT*/ Int64 &dataLen, /* length of data. 0 indicates EOD */
- /*INOUT*/ void* *cliInterface /* INOUT: if returned, save it and
- pass it back in on the next call */
-
- );
-#endif
Int32 SQLCLI_SWITCH_TO_COMPILER_TYPE
(
/*IN*/ CliGlobals* cliGlobals,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/074428ed/core/sql/cli/CliExtern.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/CliExtern.cpp b/core/sql/cli/CliExtern.cpp
index 380b0fc..b635e66 100644
--- a/core/sql/cli/CliExtern.cpp
+++ b/core/sql/cli/CliExtern.cpp
@@ -7483,57 +7483,6 @@ Lng32 SQL_EXEC_LOBddlInterface
return retcode;
}
-#ifdef __ignore
-Lng32 SQL_EXEC_LOBloader2sqlInterface
-(
- /*IN*/ char * lobHandle,
- /*IN*/ Lng32 lobHandleLen,
- /*IN*/ char * lobInfo,
- /*IN*/ Lng32 lobInfoLen,
- /*IN*/ LOBcliQueryType qType,
- /*INOUT*/ char * dataLoc, /* IN: for load, OUT: for extract */
- /*INOUT*/ Int64 &dataLen, /* length of data. 0 indicates EOD */
- /*INOUT*/ void* *cliInterface /* INOUT: if returned, save it and
- pass it back in on the next call */
- )
-{
- Lng32 retcode;
- CLISemaphore *tmpSemaphore;
- ContextCli *threadContext;
- CLI_NONPRIV_PROLOGUE(retcode);
- try
- {
- tmpSemaphore = getCliSemaphore(threadContext);
- tmpSemaphore->get();
- threadContext->incrNumOfCliCalls();
- retcode = SQLCLI_LOBloader2sqlInterface(GetCliGlobals(),
- lobHandle,
- lobHandleLen,
- lobInfo,
- lobInfoLen,
- qType,
- dataLoc,
- dataLen,
- cliInterface);
- }
- catch(...)
- {
- retcode = -CLI_INTERNAL_ERROR;
-#if defined(_THROW_EXCEPTIONS)
- if (cliWillThrow())
- {
- threadContext->decrNumOfCliCalls();
- tmpSemaphore->release();
- throw;
- }
-#endif
- }
- threadContext->decrNumOfCliCalls();
- tmpSemaphore->release();
- RecordError(NULL, retcode);
- return retcode;
-}
-#endif
Int32 SQL_EXEC_SWITCH_TO_COMPILER_TYPE
(
/*IN*/ Int32 cmpCntxtType
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/074428ed/core/sql/cli/ExSqlComp.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/ExSqlComp.cpp b/core/sql/cli/ExSqlComp.cpp
index c1650aa..6f7f97a 100644
--- a/core/sql/cli/ExSqlComp.cpp
+++ b/core/sql/cli/ExSqlComp.cpp
@@ -581,7 +581,7 @@ ExSqlComp::ReturnStatus ExSqlComp::resetAllDefaults(){
Lng32 len = str_len(buf[i])+1;
CmpCompileInfo c((char *)buf[i], len,
(Lng32)SQLCHARSETCODE_UTF8
- , NULL, 0, NULL, 0, NULL, 0, 0, 0);
+ , NULL, 0, NULL, 0, 0, 0);
size_t dataLen = c.getLength();
char * data = new(h_) char[dataLen];
c.pack(data);
@@ -607,7 +607,7 @@ ExSqlComp::ReturnStatus ExSqlComp::resetRemoteDefaults(){
Lng32 len = str_len(buf[i])+1;
CmpCompileInfo c((char *)buf[i], len,
(Lng32)SQLCHARSETCODE_UTF8
- , NULL, 0, NULL, 0,NULL,0, 0, 0);
+ , NULL, 0,NULL,0, 0, 0);
size_t dataLen = c.getLength();
char * data = new(h_) char[dataLen];
c.pack(data);
@@ -745,7 +745,7 @@ ExSqlComp::ReturnStatus ExSqlComp::resendControls(NABoolean ctxSw) // Genesis
str_len(GetControlDefaults::GetExternalizedDefaultsStmt())+1;
CmpCompileInfo c(buf, len,
(Lng32)SQLCHARSETCODE_UTF8
- , NULL, 0, NULL, 0, NULL, 0, 0, 0);
+ , NULL, 0, NULL, 0, 0, 0);
size_t dataLen = c.getLength();
char * data = new(h_) char[dataLen];
c.pack(data);
@@ -825,7 +825,7 @@ ExSqlComp::ReturnStatus ExSqlComp::resendControls(NABoolean ctxSw) // Genesis
Lng32 len = ctl->getSqlTextLen()+1;
CmpCompileInfo c(buf, len,
(Lng32)SQLCHARSETCODE_UTF8
- , NULL, 0, NULL, 0, NULL, 0, 0, 0);
+ , NULL, 0, NULL, 0, 0, 0);
size_t dataLen = c.getLength();
char * data = new(h_) char[dataLen];
c.pack(data);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/074428ed/core/sql/cli/Statement.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/Statement.cpp b/core/sql/cli/Statement.cpp
index 8502e76..c38cd0a 100644
--- a/core/sql/cli/Statement.cpp
+++ b/core/sql/cli/Statement.cpp
@@ -79,6 +79,7 @@
#include "logmxevent.h"
+#include "ExpLOBinterface.h"
#include "ExUdrServer.h"
#include "wstr.h"
@@ -1631,8 +1632,6 @@ RETCODE Statement::prepare2(char *source, ComDiagsArea &diagsArea,
char * data = NULL;
ULng32 dataLen = 0;
ExSqlComp::Operator op;
- char * rlnilBuf = NULL;
- ULng32 rlnilLen = 0;
while (retry)
{
if (newOperation)
@@ -1641,36 +1640,9 @@ RETCODE Statement::prepare2(char *source, ComDiagsArea &diagsArea,
// Build request and send to arkcmp.
if ((reComp) || (aqRetry && deCache))
{
- if ((reComp) && (root_tdb))
- {
- if (root_tdb->getLateNameInfoList())
- if ((root_tdb->getPlanVersion() < COM_VERS_R2_3) ||
- (versionToUse_ < COM_VERS_R2_3))
-
- {
- rlnilLen= root_tdb->getLateNameInfoList()->
- getRecompLateNameInfoListLenPre1800();
-
- rlnilBuf = new(&heap_) char[rlnilLen];
- root_tdb->getLateNameInfoList()->
- getRecompLateNameInfoListPre1800(rlnilBuf);
- }
- else
- {
- rlnilLen =
- root_tdb->getLateNameInfoList()->getRecompLateNameInfoListLen();
-
- rlnilBuf = new(&heap_) char[rlnilLen];
- root_tdb->getLateNameInfoList()->
- getRecompLateNameInfoList(rlnilBuf);
- }
- }
-
CmpCompileInfo c((reComp ? source_str : source),
(reComp ? sourceLenplus1() : octetLenplus1(source, charset)),
(Lng32) (reComp ? charset_ : charset),
- (RecompLateNameInfoList *)rlnilBuf,
- (Lng32) rlnilLen,
schemaName_, schemaNameLength_+1,
recompControlInfo_, recompControlInfoLen_,
getInputArrayMaxsize(), (short)rsa);
@@ -1700,9 +1672,6 @@ RETCODE Statement::prepare2(char *source, ComDiagsArea &diagsArea,
data = (char *)dealloc.getAddr
(new(dealloc.setHeap(&heap_)) char[dataLen]);
c.pack(data);
- if (rlnilBuf)
- NADELETEBASIC(rlnilBuf, &heap_);
- rlnilBuf = NULL;
// Release the existing TDB tree if one exists
assignRootTdb(NULL);
@@ -1728,7 +1697,7 @@ RETCODE Statement::prepare2(char *source, ComDiagsArea &diagsArea,
else
{
CmpCompileInfo c(source, octetLenplus1(source, charset), (Lng32) charset,
- NULL, 0, NULL, 0, NULL, 0,
+ NULL, 0, NULL, 0,
getInputArrayMaxsize(), (short)rsa);
if (aqRetry)
@@ -2102,526 +2071,60 @@ Statement * Statement::getCurrentOfCursorStatement(char * cursorName)
}
-///////////////////////////////////////////////////////////////////////
-// RETURN: doSimCheck: if true, do similarity check.
-// doFixup: if true and doSimCheck is false, do fixup again.
-// Note: fixup is always done after sim check so if
-// doSimCheck is returned as true, then doFixup
-// is ignored.
-///////////////////////////////////////////////////////////////////////
-RETCODE Statement::resolveNames(LateNameInfoList * lnil,
- Descriptor * inputDesc,
- ComDiagsArea &diagsArea,
- NABoolean &doSimCheck,
- NABoolean &doFixup)
+RETCODE Statement::doHiveTableSimCheck(TrafSimilarityTableInfo *si,
+ void * lobGlob,
+ NABoolean &simCheckFailed,
+ ComDiagsArea &diagsArea)
{
- doSimCheck = FALSE;
- doFixup = FALSE;
- Lng32 curAnsiNameLen = 0;
- char * curAnsiName = 0;
- NABoolean contextChanged = FALSE;
- AnsiOrNskName *curName = NULL;
- Int16 retCode;
- char * parts[4];
- Lng32 numParts;
- bool isNskName = FALSE;
- char * fullyQualifiedSchemaName = schemaName_;
-
- if (lnil->definePresent())
- {
- // if this is the first time names are being resolved, then
- // do it even if the define context has not changed.
- unsigned short defcon = context_->getCurrentDefineContext();
- if ((NOT firstResolveDone()) ||
- (defcon != defineContext()))
- {
- contextChanged = TRUE;
- }
- defineContext() = defcon;
- }
-
- for (Int32 l = 0; l < (Int32) (lnil->getNumEntries()); l++)
- {
- LateNameInfo * lni = &(lnil->getLateNameInfo(l));
-
- lni->setAnsiNameChange(0);
-
-
- if (lni->isVariable())
- {
-
- if (lni->isDefine())
- {
- }
- else if (lni->isEnvVar())
- {
- // get name from env var.
- char envName[ComMAX_3_PART_EXTERNAL_UTF8_NAME_LEN_IN_BYTES+1];
- curAnsiName = cliGlobals_->getEnv(lni->variableName());
-
- if ((! curAnsiName)||
- ((curAnsiNameLen = str_len(curAnsiName)) >
- ComMAX_3_PART_EXTERNAL_UTF8_NAME_LEN_IN_BYTES))
- {
-
- diagsArea << DgSqlCode(-EXE_INVALID_DEFINE_OR_ENVVAR)
- <<DgString0(lni->variableName());
- return ERROR;
- }
- str_cpy_all(envName,curAnsiName,str_len(curAnsiName));
- envName[curAnsiNameLen] = '\0';
-
- curName = new (&heap_) AnsiOrNskName(envName);
- if (curName->convertAnsiOrNskName())
- {
- diagsArea << DgSqlCode(-CLI_INVALID_SQL_ID)<<DgString0(envName);
- delete curName;
- return ERROR;
- }
- } //endif env var
-
- else if (lni->isCachedParam())
- {
- // cached params are only resolved on the first execute after
- // prepare. These values are set from constants and
- // cannot change for multiple executions of the same stmt.
- if (firstResolveDone())
- continue; // Go back to the for loop to continue with the next lni
-
- curAnsiName =
- &root_tdb->getParameterBuffer()
- [lni->getCachedParamOffset()];
- curName = new (&heap_) AnsiOrNskName(curAnsiName);
- if (curName->convertAnsiOrNskName())
- {
- diagsArea << DgSqlCode(-CLI_INVALID_SQL_ID)<<DgString0(curAnsiName);
- delete curName;
- return ERROR;
- }
-
- } //endif cached param
- else // hvar or param
- {
- // Here we need to validate what the hvar contains
- // We need to make sure it is a string hvar and we call
- // convDoIt so that we only get the length of the
- // string that we need.
-
- char *source= 0;
- Lng32 sourceLen = 0;
- Lng32 sourceType = 0;
- Lng32 sourceCharset = CharInfo::UnknownCharSet;
- void *var_ptr = 0;
-
- inputDesc->getDescItem(lni->getInputListIndex(),
- SQLDESC_VAR_PTR, &var_ptr,
- 0, 0, 0, 0);
- inputDesc->getDescItem(lni->getInputListIndex(),
- SQLDESC_LENGTH, &sourceLen,
- 0,0,0,0);
-
- inputDesc->getDescItem(lni->getInputListIndex(),
- SQLDESC_TYPE_FS, &sourceType,
- 0,0,0,0);
-
- // Check if input is a string type
-
- if ((sourceType>=REC_MIN_CHARACTER) &&
- (sourceType <= REC_MAX_CHARACTER))
- {
- inputDesc->getDescItem(lni->getInputListIndex(),
- SQLDESC_CHAR_SET, &sourceCharset,
- 0,0,0,0);
-
- if (sourceCharset == CharInfo::UnknownCharSet &&
- (sourceType == REC_BYTE_F_ASCII ||
- sourceType == REC_BYTE_V_ASCII ||
- sourceType == REC_BYTE_V_ANSI))
- {
- // some clients aren't accustomed yet to setting the
- // charset of the SQL statement, treat those as ISO88591
- // for single-byte based data types
- sourceCharset = CharInfo::ISO88591;
- }
-
- if (stmt_type == STATIC_STMT &&
- sourceCharset == CharInfo::ISO88591)
- {
- // our convention is to pass UTF-8 or UCS2 for
- // names in embedded programs. However, embedded
- // SQL does not support UTF-8 at this time.
- // Temporary fix: Set input charset to UTF-8
- // here until UTF-8 host varables are supported
- // in embedded programs (if that ever happens)
- sourceCharset = CharInfo::UTF8;
- }
- }
- else
- {
- diagsArea << DgSqlCode(-CLI_INVALID_OBJECTNAME);
- return ERROR;
- }
- source = (char *)var_ptr;
-
- if (DFS2REC::isSQLVarChar(sourceType))
- {
- // the first 2 bytes of data are actually the variable
- // length indicator
- short VCLen;
- str_cpy_all((char *) &VCLen, source, sizeof(short));
- sourceLen = (Lng32) VCLen;
- source = &source[sizeof(short)];
- }
-
- ComDiagsArea *diagsPtr = NULL;
- char targetName[ComMAX_3_PART_EXTERNAL_UTF8_NAME_LEN_IN_BYTES + 1];
- short retcode = convDoIt(source,
- sourceLen,
- (short) sourceType,
- 0,
- sourceCharset, // passed in as scale
- targetName,
- sizeof(targetName) - 1,
- REC_BYTE_V_ANSI, // short targetType
- 0, // Lng32 targetPrecision
- (Lng32) SQLCHARSETCODE_UTF8, // Lng32 targetScale - also used as targetCharSet for CharType
- 0,
- 0,
- &heap_,
- &diagsPtr);
- if (diagsPtr)
- {
- diagsArea.mergeAfter(*diagsPtr);
- diagsPtr->decrRefCount();
- diagsPtr = NULL;
- }
- if (retcode != ex_expr::EXPR_OK)
- {
- diagsArea << DgSqlCode(-EXE_CONVERT_STRING_ERROR);
- char hexstr[MAX_OFFENDING_SOURCE_DATA_DISPLAY_LEN];
- memset(hexstr, 0 , sizeof(hexstr) );
- diagsArea << DgString0(stringToHex(hexstr, sizeof(hexstr), source, sourceLen ));
-
- return ERROR;
- }
-
- if (! fullyQualifiedSchemaName)
- fullyQualifiedSchemaName = lni->compileTimeAnsiName();
-
- curName = new (&heap_) AnsiOrNskName(targetName);
- if (curName->convertAnsiOrNskName())
- {
- diagsArea << DgSqlCode(-CLI_INVALID_SQL_ID)
- <<DgString0(targetName);
- delete curName;
- return ERROR;
-
- }
- } // end if hvar
-
- if (NOT lni->isMPalias())
- {
- if (lni->isAvoidSimCheck()) // Host Variable in SET TABLE TIMEOUT command without
- // Prototype clause will have the NAME_ONLY and VARIABLE bit is set
- // So,we will need at least 3 parts
- // If nsk name, system name will be filled in
- {
- if (curName->extractParts(numParts, parts))
- {
- diagsArea << DgSqlCode(-CLI_INVALID_SQL_ID)
- << DgString0(curName->getExternalName());
- delete curName;
- return ERROR;
- }
- if (numParts < 3)
- {
- diagsArea << DgSqlCode(-CLI_INVALID_SQL_ID)
- << DgString0(curName->getExternalName());
- delete curName;
- return ERROR;
- }
- isNskName = curName->isNskName(); // will be set to False
- }
- else
- isNskName = TRUE;
- if (isNskName)
- {
- curAnsiName = curName->getInternalName();
- curAnsiNameLen = str_len(curAnsiName);
- if (curAnsiName[0] != '\\')
- {
-
- }
- }
- }
-
- if (lni->isMPalias() && NOT (lni->isAnsiPhySame())) {
- // if MPAlias flag is set, then we compiled for an MX table, or an MP table with
- // a MPAlias defined on it See comment in GenRelMisc.cpp PartitionAccess::codeGen
- // method where the mpalias flag is set. If that flag is set only for an MPAlias
- // and not for MX tables then this else statement condition will have to be modified.
- // The code below should be executed for MX tables and for MP tables access through
- // their MPAlias. The code below is also not needed for accessing resource forks whose
- // ansi name is same as their physical name.
-
- if (curName->extractParts(numParts, parts))
- {
- diagsArea << DgSqlCode(-CLI_INVALID_SQL_ID)
- << DgString0(curName->getExternalName());
- delete curName;
- return ERROR;
- }
- if (numParts != 3) {
- if (curName->fillInMissingParts(fullyQualifiedSchemaName) == -1)
- {
- diagsArea << DgSqlCode(-CLI_INVALID_SQL_ID)
- << DgString0(curName->getExternalName());
- delete curName;
- return ERROR;
- }
- } // end if numParts != 3
-
- } // end isMPAlias && isAnsiPhySame
-
- // if current ansi name is different than the last ansi name,
- // resolve the current ansi name. Remember this in lni.
- retCode = lni->getLastUsedName(&heap_)->equals(curName);
- if (retCode == -1)
- {
- diagsArea << DgSqlCode(-CLI_INTERNAL_ERROR);
- delete curName;
- return ERROR;
- }
- else
- if (retCode == 0)
- {
- lni->setAnsiNameChange(1);
- lni->setLastUsedName(curName);
- // If similarity check is to be avoided: Map the physical name
- // right here (otherwise done during the similarity check.)
- if ( lni->isAvoidSimCheck() )
- {
- if (! isNskName)
- {
- if (mapAnsiToGuaName(lni, diagsArea) == ERROR)
- return ERROR;
- }
- else
- strcpy(lni->resolvedPhyName(), curName->getInternalName());
- doFixup = TRUE; // fixup needs to be done again to
- // be able to use the new name.
- }
- else
- if (NOT doSimCheck)
- {
- doSimCheck = TRUE;
-
- // if this is a view name that has changed, mark it
- // in the latenameinfo struct. This will be used later
- // when similarity check is done in doQuerySimilarityCheck.
- if (lni->isView())
- {
- lni->setViewNameChange(1);
- }
- }
- }
- else
- {
- if (curName)
- {
- delete curName;
- curName = NULL;
- }
-
-
- }
-
- } // variable
-
- } // for
-
- if (NOT firstResolveDone())
- {
- setFirstResolveDone(TRUE);
- }
-
- return SUCCESS;
-}
-
-
-////////////////////////////////////////////////////////////////////
-// This method performs similarity check between the information
-// generated at compile time (si) and the information retrieved at
-// runtime for table specified via tableName.
-// RETURNS: ERROR: if an error occured.
-// SUCCESS, otherwise.
-// if sim check fails, then this is indicated by
-// the return param, simCheckFailed, set to TRUE.
-/////////////////////////////////////////////////////////////////////
-RETCODE Statement::doSimilarityCheck(SimilarityInfo * si,
- LateNameInfo * lni,
- char * tableName,
- NABoolean &simCheckFailed,
- ComDiagsArea &diagsArea
- )
-{
- return SUCCESS;
-}
+ simCheckFailed = FALSE;
+ Lng32 retcode = 0;
-RETCODE Statement::doIUDSimilarityCheck(SimilarityInfo * si,
- LateNameInfo * lni,
- char * tableName,
- Queue * indexInfoList,
- NABoolean &simCheckFailed,
- ComDiagsArea &diagsArea)
-{
- return SUCCESS;
-}
+ if ((si->hdfsRootDir() == NULL) || (si->modTS() == -1))
+ return SUCCESS;
-RETCODE Statement::getMatchingIndex(Queue * indexInfoList,
- char * indexAnsiName,
- char * indexPhyName,
- ComDiagsArea &diagsArea)
-{
- indexInfoList->position();
- for (Int32 i = 0; i < indexInfoList->numEntries(); i++)
+ Int64 failedModTS = -1;
+ Lng32 failedLocBufLen = 1000;
+ char failedLocBuf[failedLocBufLen];
+ retcode = ExpLOBinterfaceDataModCheck
+ (lobGlob,
+ si->hdfsRootDir(),
+ si->hdfsHostName(),
+ si->hdfsPort(),
+ si->modTS(),
+ si->numPartnLevels(),
+ failedModTS,
+ failedLocBuf, failedLocBufLen);
+ if (retcode < 0)
{
- IndexInfo * ii = (IndexInfo*)(indexInfoList->getNext());
-
- if (str_cmp(indexAnsiName, ii->indexAnsiName(),
- str_len(indexAnsiName)) == 0)
- {
- strcpy(indexPhyName, ii->indexPhyName());
- return SUCCESS;
- }
+ Lng32 intParam1 = -retcode;
+ diagsArea << DgSqlCode(-EXE_ERROR_FROM_LOB_INTERFACE)
+ << DgString0("HDFS")
+ << DgString1("ExpLOBInterfaceDataModCheck")
+ << DgString2(getLobErrStr(intParam1))
+ << DgInt0(intParam1)
+ << DgInt1(0);
+ return ERROR;
}
- return SUCCESS;
-}
-
-RETCODE Statement::mapAnsiToGuaName(LateNameInfo * lni,
- ComDiagsArea &diagsArea)
-{
- return ERROR;
-}
-
-// this method resolves all table names that are used in this query.
-RETCODE Statement::forceMapAllNames(LateNameInfoList * lnil,
- ComDiagsArea &diagsArea)
-{
- for (Int32 i = 0; i < (Int32) (lnil->getNumEntries()); i++)
+ if (retcode == 1) // check failed
{
- LateNameInfo * lni = &(lnil->getLateNameInfo(i));
-
- lni->setAnsiNameChange(1);
-
- char *lastUsedAnsiName = lni->lastUsedAnsiName();
-
- // NA_NSK_REL1 - need to change for ansi names
- NABoolean isGuardianName =
- (lastUsedAnsiName && lastUsedAnsiName[0] == '\\') ? TRUE : FALSE;
-
- if (lni->isAnsiPhySame() || isGuardianName)
- {
-
- // If ansi name is really a phys name, copy it to resolvedPhyName.
- // For the first release on NSK, all internal table names, such as
- // histograms, histints, etc, will have resolved physical names as
- // their ANSI name.
- str_cpy(lni->resolvedPhyName(), lni->lastUsedAnsiName(),
- str_len(lni->lastUsedAnsiName()) + 1, '\0');
- }
- else
- {
- // VO, Metadata indexes
- // If all of the following is true:
- // - the lni represents an index
- // - the query is from a system module,
- // THEN the generator has set the last used ansi name to the
- // compile time name of the base table. We will use that to find
- // the index runtime ANSI name.
- LateNameInfo * baseTableLni = NULL;
- if ( (lni->getNameSpace() == COM_INDEX_NAME) &&
- (systemModuleStmt())
- )
- {
- if (lni->isVariable())
- {
- // resolve names has put the runtime name of the table in this lni
- baseTableLni = lni;
- }
- else
- {
- // iterate over the lnil to find the entry for the index' base table
- for (Int32 ix = 0; ix < (Int32) (lnil->getNumEntries()); ix++)
- {
- LateNameInfo * lni2 = &(lnil->getLateNameInfo(ix));
- if (!strcmp (lni2->compileTimeAnsiName(), lni->lastUsedAnsiName()))
- {
- baseTableLni = lni2;
- break;
- }
- }
- }
-
- if (baseTableLni == NULL)
- {
- // didn't find the base table in the lnil - quit!
- diagsArea << DgSqlCode(-CLI_INTERNAL_ERROR);
- return ERROR;
- }
-
- // Construct the runtime index name from
- // - the runtime catalog and schema name parts of the base table
- // - the compile time object name part of the index
- char * indexParts[4];
- char * tableParts[4];
- Lng32 numIndexParts = -1, numTableParts = -1;
- AnsiOrNskName * indexCompileTimeAnsiName = new (&heap_) AnsiOrNskName(lni->compileTimeAnsiName());
- baseTableLni->getLastUsedName(&heap_)->extractParts (numTableParts, tableParts);
- indexCompileTimeAnsiName->extractParts (numIndexParts, indexParts);
-
- if ( (numIndexParts != 3) || (numTableParts != 3))
- {
- // Something rotten here ...
- delete indexCompileTimeAnsiName;
- diagsArea << DgSqlCode(-CLI_INTERNAL_ERROR);
- return ERROR;
- }
-
- char indexExtName[ComMAX_3_PART_EXTERNAL_UTF8_NAME_LEN_IN_BYTES + 1];
- ComBuildANSIName (tableParts[0], tableParts[1], indexParts[2], indexExtName);
- delete indexCompileTimeAnsiName;
-
- AnsiOrNskName * indexName = new (&heap_) AnsiOrNskName(indexExtName);
- lni->setLastUsedName (indexName);
- }
+ char errStr[200];
+ str_sprintf(errStr, "compiledModTS = %Ld, failedModTS = %Ld, failedLoc = %s",
+ si->modTS(), failedModTS,
+ (failedLocBufLen > 0 ? failedLocBuf : si->hdfsRootDir()));
+
+ diagsArea << DgSqlCode(-EXE_HIVE_DATA_MOD_CHECK_ERROR)
+ << DgString0(errStr);
- RETCODE retcode = mapAnsiToGuaName(lni, diagsArea);
- if (baseTableLni != NULL && !lni->isVariable())
- // need to reset the last used ANSI name for a metadata index to that of the
- // compile time base table. Otherwise, the next name mapping will fail.
- lni->setLastUsedName (new (&heap_) AnsiOrNskName (baseTableLni->compileTimeAnsiName()));
+ simCheckFailed = TRUE;
- if (retcode != SUCCESS)
- return ERROR;
-
- }
+ return ERROR;
}
-
+
return SUCCESS;
}
-/////////////////////////////////////////////////////////////////////////
-// This method does similarity checks on all tables for which
-// the flag, doSimCheck(), is set.
-// RETURNS: ERROR: if an error occured.
-// SUCCESS, otherwise.
-// if sim check fails, then this is indicated by
-// the return param, simCheckFailed, set to TRUE.
-/////////////////////////////////////////////////////////////////////////
-RETCODE Statement::doQuerySimilarityCheck(QuerySimilarityInfo * qsi,
- LateNameInfoList * lnil,
+RETCODE Statement::doQuerySimilarityCheck(TrafQuerySimilarityInfo * qsi,
NABoolean &simCheckFailed,
ComDiagsArea &diagsArea
)
@@ -2629,248 +2132,48 @@ RETCODE Statement::doQuerySimilarityCheck(QuerySimilarityInfo * qsi,
RETCODE retcode;
simCheckFailed = FALSE;
+ if ((! qsi) ||
+ (qsi->disableSimCheck()) ||
+ (! qsi->siList()) ||
+ (qsi->siList()->numEntries() == 0))
+ return SUCCESS;
- if (! qsi)
- return ERROR;
-
- NABoolean aqr = root_tdb->aqrEnabled();
- if (aqr)
- {
- diagsArea << DgSqlCode(-EXE_SIM_CHECK_FAILED)
- << DgString0("Similarity check should not be reached with aqr enabled.");
-
- return ERROR;
- }
-
- // if similarity check is being done due to a view name change that
- // was passed thru an identifier, then recompile.
- if (lnil->viewPresent())
- {
- CollIndex i = 0;
- while (i < (Int32) lnil->getNumEntries())
- {
-#pragma nowarn(1506) // warning elimination
- LateNameInfo * lni = &(lnil->getLateNameInfo(i));
-#pragma warn(1506) // warning elimination
-
- if (lni->isViewNameChange())
- {
- lni->setViewNameChange(0);
-
- simCheckFailed = TRUE;
- return SUCCESS;
-
- }
- i++;
- }
- }
-
- switch (qsi->getSimilarityCheckOption())
- {
- case QuerySimilarityInfo::INTERNAL_SIM_CHECK:
- {
- // accessing internal tables(catalog). Just resolve names. Similarity
- // check always passes for these tables.
- retcode = forceMapAllNames(lnil, diagsArea);
- if (retcode == ERROR)
- return ERROR;
-
- for (Int32 i = 0; i < (Int32) (lnil->getNumEntries()); i++)
- {
- // ignore TS mismatch on the next open since similarity
- // check has succeeded.
- lnil->getLateNameInfo(i).setIgnoreTS(1);
- }
-
- return SUCCESS;
- }
- break;
-
- case QuerySimilarityInfo::RECOMP_ON_TS_MISMATCH:
- {
- if (aqr)
- {
- diagsArea << DgSqlCode(-EXE_SIM_CHECK_FAILED)
- << DgString0("Similarity check should not be reached.");
-
- return ERROR;
- }
-
- simCheckFailed = TRUE;
- return SUCCESS;
- }
- break;
-
- case QuerySimilarityInfo::ERROR_ON_TS_MISMATCH:
- {
- diagsArea << DgSqlCode(-EXE_SIM_CHECK_FAILED)
- << DgString0("Similarity check disabled.");
-
- return ERROR;
- }
- break;
-
- case QuerySimilarityInfo::SIM_CHECK_AND_RECOMP_ON_FAILURE:
- case QuerySimilarityInfo::SIM_CHECK_AND_ERROR_ON_FAILURE:
- {
- if (aqr)
- {
- diagsArea << DgSqlCode(-EXE_SIM_CHECK_FAILED)
- << DgString0("Similarity check should not be reached.");
-
- return ERROR;
- }
-
- // do sim check in both these cases. If it passes, do
- // nothing. If it fails, then recompile or return error.
- }
- break;
- }
-
- qsi->siList()->position();
- SimilarityInfo * si;
-
- // index info list is set up for the target IUD'd table in an
- // IUD(Insert/Update/Delete) query. There may not be any indices
- // on the IUD'd table at compile time. In that case, the method
- // doIUDSimilarityCheck validates that there are no indices on the
- // runtime IUD's table as well.
-#pragma warning( disable : 4018 )
- if (qsi->indexInfoList() &&
- (qsi->namePosition() < lnil->getNumEntries()))
-#pragma warning( default: 4018 )
- {
- si = (SimilarityInfo *)(qsi->siList()->get(qsi->namePosition()));
- LateNameInfo * lni = &lnil->getLateNameInfo(qsi->namePosition());
-
- retcode = mapAnsiToGuaName(lni, diagsArea);
- if (retcode == ERROR)
- return ERROR;
-
- simCheckFailed = FALSE;
- if (NOT si->simCheckDisable())
- {
- if (doIUDSimilarityCheck(si,
- lni,
- lni->resolvedPhyName(),
- qsi->indexInfoList(),
- simCheckFailed, diagsArea) == ERROR)
- return ERROR;
- }
-
- if (simCheckFailed)
- {
- if (qsi->getSimilarityCheckOption() ==
- QuerySimilarityInfo::SIM_CHECK_AND_ERROR_ON_FAILURE)
- {
- diagsArea << DgSqlCode(-EXE_SIM_CHECK_FAILED)
- << DgString0("Automatic recompilation disabled.");
-
- return ERROR;
- }
- else
- return SUCCESS;
- }
-
- // at this point we have validated that the runtime table and the
- // compile time table have matching indices which are in the same
- // order.
- lni->setIgnoreTS(1);
- }
-
- Int32 i = 0;
+ void * lobGlob = NULL; //getRootTcb()->getGlobals()->getExLobGlobal();
+ NABoolean lobGlobInitialized = FALSE;
qsi->siList()->position();
-#pragma warning( disable: 4018 )
- while (((si = (SimilarityInfo *)(qsi->siList()->getNext())) != NULL) &&
- (i < lnil->getNumEntries()))
-#pragma warning( default: 4018 )
+ for (Lng32 i = 0; i < qsi->siList()->numEntries(); i++)
{
- LateNameInfo * lni = &lnil->getLateNameInfo(i);
+ TrafSimilarityTableInfo *si =
+ (TrafSimilarityTableInfo *)qsi->siList()->getCurr();
- if (si->internalSimCheck())
- {
- // do nothing. An internal system table is being accessed(a metadata
- // table) and the timestamp info on those tables is not maintained.
- // Consider the similarity check to pass in this case.
- lni->setIgnoreTS(1);
- }
- else if (si->simCheckDisable())
- {
- lni->setIgnoreTS(0);
- simCheckFailed = TRUE;
- }
- else if (si->getMatchingIndex())
- {
- if (getMatchingIndex(qsi->indexInfoList(),
- lni->compileTimeAnsiName(),
- lni->resolvedPhyName(), diagsArea) == ERROR)
- return ERROR;
-
- // ignore TS mismatch on the next open since similarity
- // check has succeeded.
- lni->setIgnoreTS(1);
- }
- else if ((qsi->indexInfoList()) &&
- (i == qsi->namePosition()))
- {
- // This is the target IUD'd table.
- // Nothing needs to be done here, this check has already
- // been done before.
- lni->setIgnoreTS(1);
- }
- else
- {
- retcode = mapAnsiToGuaName(lni, diagsArea);
- if (retcode == ERROR)
- return ERROR;
-
- retcode = doSimilarityCheck(si, lni, lni->resolvedPhyName(),
- simCheckFailed, diagsArea);
-#ifdef _DEBUG
- {
- char * envPtr = getenv ("SQLMX_DISPLAY_CATMAP");
- if (envPtr && *envPtr == '1')
+ simCheckFailed = FALSE;
+ if (si->isHive())
+ {
+ if ((NOT lobGlobInitialized) &&
+ (lobGlob == NULL))
{
- diagsArea << DgSqlCode (DISTRIBUTION_DEBUG_WARNING)
- << DgString0 (lni->lastUsedAnsiName())
- << DgString1 ("maps to")
- << DgString2 (lni->resolvedPhyName());
+ ExpLOBinterfaceInit
+ (lobGlob, &heap_, context_,
+ TRUE, si->hdfsHostName(), si->hdfsPort());
+ lobGlobInitialized = TRUE;
}
- }
-
-#endif
- if (retcode == ERROR)
- return ERROR;
-
- if (simCheckFailed)
- {
- if (qsi->getSimilarityCheckOption() ==
- QuerySimilarityInfo::SIM_CHECK_AND_ERROR_ON_FAILURE)
- {
- diagsArea << DgSqlCode(-EXE_SIM_CHECK_FAILED)
- << DgString0("Automatic recompilation disabled.");
-
- return ERROR;
- }
- else
- return SUCCESS;
- }
-
- // ignore TS mismatch on the next open since similarity
- // check has succeeded.
- lni->setIgnoreTS(1);
- }
- // Fix for 10-010614-3437: When we get here, we have found and
- // restored similar index information for the IUD stmt, so
- // don't compare the timestamps.
- //if (qsi->indexInfoList() && lni->isIndex())
- // lni->setIgnoreTS(1);
+ retcode = doHiveTableSimCheck(si, lobGlob, simCheckFailed, diagsArea);
+ if (retcode == ERROR)
+ {
+ goto error_return; // diagsArea is set
+ }
+ }
+ } // for
- i++;
- }
-
+ if (lobGlob)
+ ExpLOBinterfaceCleanup(lobGlob, &heap_);
return SUCCESS;
+
+ error_return:
+ if (lobGlob)
+ ExpLOBinterfaceCleanup(lobGlob, &heap_);
+ return ERROR;
}
RETCODE Statement::fixup(CliGlobals * cliGlobals, Descriptor * input_desc,
@@ -2890,24 +2193,7 @@ RETCODE Statement::fixup(CliGlobals * cliGlobals, Descriptor * input_desc,
if (fixupState() != 0)
return ERROR;
- if (!donePrepare)
- {
- // Don't check visibility if the statement has just been prepared
- switch (doVisibilityCheck ( root_tdb->getLateNameInfoList(), diagsArea))
- {
- case WARNING:
- doSimCheck = TRUE;
- return SUCCESS;
- case ERROR:
- return ERROR;
- default:
- break;
- }
- }
-
/* fixup the generated code */
- // statementGlobals_->resolvedNameList() =
- // (lnil_ ? lnil_ : root_tdb->getLateNameInfoList());
statementGlobals_->setStartAddr((void *)root_tdb);
statementGlobals_->setCliGlobals(cliGlobals_);
@@ -2992,10 +2278,7 @@ RETCODE Statement::fixup(CliGlobals * cliGlobals, Descriptor * input_desc,
// fixup time.
if (((diagsArea.contains(-EXE_TIMESTAMP_MISMATCH)) &&
(NOT tsMismatched()))
- || ((diagsArea.contains(-EXE_TABLE_NOT_FOUND)) &&
- (root_tdb->querySimilarityInfo()->getSimilarityCheckOption() !=
- QuerySimilarityInfo::INTERNAL_SIM_CHECK)))
-
+ || (diagsArea.contains(-EXE_TABLE_NOT_FOUND)))
{
setTsMismatched(TRUE);
doSimCheck = TRUE;
@@ -3033,14 +2316,6 @@ RETCODE Statement::fixup(CliGlobals * cliGlobals, Descriptor * input_desc,
return ERROR;
}
}
-
- // clear all runtime flags in statementGlobals_->latenameinfolist()->
- // getLateNameInfo(i)
- if (root_tdb->getLateNameInfoList())
- {
- // statementGlobals_->resolvedNameList()->resetFlags();
- root_tdb->getLateNameInfoList()->resetRuntimeFlags();
- }
setFixupState(-1);
@@ -3187,11 +2462,7 @@ RETCODE Statement::execute(CliGlobals * cliGlobals, Descriptor * input_desc,
while (readyToReturn == FALSE)
{
#ifdef _DEBUG
- if ((getenv("SHOW_STATE")) &&
- ((! root_tdb) ||
- ((root_tdb) &&
- (root_tdb->querySimilarityInfo()->getSimilarityCheckOption() !=
- QuerySimilarityInfo::INTERNAL_SIM_CHECK))))
+ if (getenv("SHOW_STATE"))
{
char buf[40];
@@ -3468,234 +2739,37 @@ RETCODE Statement::execute(CliGlobals * cliGlobals, Descriptor * input_desc,
}
setTsMismatched(FALSE);
- state_ = RESOLVE_NAMES_;
+ state_ = DO_SIM_CHECK_;
}
break;
- case RESOLVE_NAMES_:
- {
- NABoolean doSimCheck = FALSE;
- NABoolean doFixup = FALSE;
-
- retcode = resolveNames(root_tdb->getLateNameInfoList(),
- input_desc, diagsArea,
- doSimCheck, doFixup);
- if (retcode == ERROR)
- {
- statementGlobals_->takeGlobalDiagsArea(diagsArea);
- state_ = ERROR_;
- break;
- }
-
- if (doSimCheck) // do sim check due to name change
- {
- state_ = DO_SIM_CHECK_;
- }
- else
- {
- if (doFixup)
- {
- setFixupState(0);
- }
- state_ = CHECK_DYNAMIC_SETTINGS_;
- }
- }
- break;
-
- case DO_SIM_CHECK_:
- {
- // This DO_SIM_CHECK_ state handles two distinct
- // tasks. One task is metadata lookups to discover
- // available partition names following a "partition not
- // available" error. The other task is the similarity
- // check. Right now the code does only one of these tasks
- // but never both. Might be best to break these two tasks
- // out into separate states.
-
- if (partitionUnavailable)
- {
- // We are getting ready to call catman code, and that code
- // will recur into this CLI code. The recursion doesn't work
- // if any errors are in the context Diags Area - i.e, formal
- // parameter diagsArea. So we will clear the context
- // diagsArea, but before clearing, we save off the conditions
- // for two reasons:
- // 1. If error is not fixed by catman, we want to return the
- // original conditions (and any new conditions raise by catman)
- // in the proper chronological order.
- // 2. Also, in case a warning was raised before the availability
- // error (especially, EXE_RECOMPILE), we need to report that,
- // even if catman is able to find an available partition.
- //
- ComDiagsArea *saveContextDiagsArea = diagsArea.copy();
- diagsArea.clear();
-
- // Make a new diags area for catman to accumulate new conditions
- // into.
- ComDiagsArea *catmanDiagsArea =
- ComDiagsArea::allocate(context_->exHeap());
- retcode = forceMapAllNames( lnil_ ?
- lnil_ :
- root_tdb->getLateNameInfoList(), *catmanDiagsArea);
-
- // Clear any new conditions have been added to the context diagsArea
- // They will have copies in the catmanDiagsArea.
- diagsArea.clear();
-
- // Now, construct a final diagsArea, with the pre-catman
- // Conditions first, followed by the Conditions raised by the
- // catman. But if there is no error from the catman, clear the
- // pre-catman errors, because they are no longer relevant.
-
- if (retcode != ERROR)
- {
- Lng32 numErrors = saveContextDiagsArea->getNumber(DgSqlCode::ERROR_);
- while (numErrors--)
- {
- saveContextDiagsArea->deleteError(numErrors);
- }
- }
-
- diagsArea.mergeAfter(*saveContextDiagsArea);
- saveContextDiagsArea->deAllocate();
- diagsArea.mergeAfter(*catmanDiagsArea);
- catmanDiagsArea->deAllocate();
-
- if (retcode == ERROR)
- {
- partitionAvailabilityChecked = TRUE;
-
- // If this is the first time the name lookups failed,
- // continue with a recompile. Otherwise stop working
- // and report the error.
- NABoolean reportTheError = FALSE;
- if (partitionNameLookupsFailed)
- reportTheError = TRUE;
-
-#ifdef NA_DEBUG_C_RUNTIME
- // In the debug build an environment setting can force
- // us to report the error here
- if (getenv("NO_RECOMP_WHEN_PART_UNAVAIL"))
- reportTheError = TRUE;
-#endif
-
- partitionNameLookupsFailed = TRUE;
- if (reportTheError)
- {
- state_ = ERROR_;
- }
- else
- {
- // Clear earlier errors from diags area, but leave warnings.
- Lng32 numErrors = diagsArea.getNumber(DgSqlCode::ERROR_);
- while (numErrors--)
- {
- diagsArea.deleteError(numErrors);
- }
- state_ = RECOMPILE_;
- }
-
- // This breaks us out of the DO_SIM_CHECK_ state
- break;
- }
- else
+ case DO_SIM_CHECK_:
+ {
+ if ((! root_tdb) || (! root_tdb->querySimilarityInfo()))
{
- // At this point, all names are resolved to available
- // partitions, if at all possible. If some names
- // still have no available partitions, we must
- // remember this fact so that the error (to be
- // discovered in the FIXUP_ state) will be returned to
- // the user.
- partitionAvailabilityChecked = TRUE;
- partitionUnavailable = FALSE;
state_ = CHECK_DYNAMIC_SETTINGS_;
-
- } // if (retcode == ERROR) else ...
- } // if (partitionUnavailable)
-
- else
- {
- NABoolean simCheckFailed = FALSE;
-
- if (root_tdb->querySimilarityInfo()->getSimilarityCheckOption() !=
- QuerySimilarityInfo::ERROR_ON_TS_MISMATCH)
- {
- // Clear earlier errors from diags area, but leave warnings.
- Lng32 numErrors = diagsArea.getNumber(DgSqlCode::ERROR_);
- while (numErrors--)
- {
- diagsArea.deleteError(numErrors);
- }
- }
-
- ComDiagsArea * diagsCopy = NULL;
- // If the diagsArea is populated, and this is not a recursive call into CLI,
- // then save a copy and re-instate after doQuerySimilarityCheck.
- // Clear the original diags area to avoid duplicate errors/warnings.
- if ((diagsArea.mainSQLCODE()) &&
- (context_->getNumOfCliCalls() == 1)
- )
- {
- diagsCopy = diagsArea.copy();
- diagsArea.clear();
+ break;
}
- retcode =
- doQuerySimilarityCheck(root_tdb->querySimilarityInfo(),
- (lnil_ ? lnil_ : root_tdb->
- getLateNameInfoList()),
- simCheckFailed, diagsArea);
-
- if (diagsCopy)
+ NABoolean simCheckFailed = FALSE;
+ retcode =
+ doQuerySimilarityCheck(root_tdb->querySimilarityInfo(),
+ simCheckFailed, diagsArea);
+ if (retcode == ERROR)
{
- // We saved something ...
- if (diagsArea.mainSQLCODE())
- {
- // ... and doQuerySimilarityCheck also produced something, add to diagsCopy
- diagsCopy->mergeAfter (diagsArea);
- diagsArea.clear();
- }
- // Put things back where they belong and get rid of the copy
- diagsArea.mergeAfter (*diagsCopy);
- diagsCopy->deAllocate();
+ state_ = ERROR_;
+ break;
}
+
+ state_ = CHECK_DYNAMIC_SETTINGS_;
+ }
+ break;
- if (retcode == ERROR)
- {
- state_ = ERROR_;
- break;
- }
-
- setFixupState(0);
-
- if (simCheckFailed)
- {
- state_ = RECOMPILE_;
- recompileReason[0] = EXE_SIM_CHECK_FAILED;
- }
- else
- {
- recompWarn = returnRecompWarn();
- if (recompWarn &&
- ((root_tdb->querySimilarityInfo()->getSimilarityCheckOption()
- == QuerySimilarityInfo::SIM_CHECK_AND_RECOMP_ON_FAILURE) ||
- (root_tdb->querySimilarityInfo()->getSimilarityCheckOption()
- == QuerySimilarityInfo::SIM_CHECK_AND_ERROR_ON_FAILURE)))
-
- {
- // similarity check passed. Return a warning indicating
- // this. This is a temporary warning for testing.
- diagsArea << DgSqlCode(EXE_SIM_CHECK_PASSED);
- }
- state_ = CHECK_DYNAMIC_SETTINGS_;
- }
- }
- }
- break;
-
case COMPILE_:
case RECOMPILE_:
{
+ ex_assert(0, " COMPILE_ and RECOMPILE_ are obsolete");
+
// We want to ignore any errors that occur as part of dealloc
// when called from here.
// So, we mark the DiagsArea before making the call to dealloc(),
@@ -3894,70 +2968,6 @@ RETCODE Statement::execute(CliGlobals * cliGlobals, Descriptor * input_desc,
setFixupState(0);
- // move resolved names from LateNameInfoList to
- // ResolvedNameList which will be shipped to PA's
- if (root_tdb->getLateNameInfoList())
- {
- ResolvedNameList *&rnl =
- statementGlobals_->resolvedNameList();
- if (rnl && (rnl->numEntries() < root_tdb->getLateNameInfoList()->getNumEntries()))
- {
- // deallocate the previously allocated rnl
- heap_.deallocateMemory(rnl);
- rnl = NULL;
- }
-
- if (! rnl)
- rnl =
- (ResolvedNameList *)
- (new(&heap_)
- char[sizeof(ResolvedNameList) +
- ((root_tdb->getLateNameInfoList()->
- getNumEntries() > 0 ) ?
- ((root_tdb->getLateNameInfoList()->
- getNumEntries() - 1) * sizeof(ResolvedName)):
- 0)]);
-
- rnl->numEntries() =
- root_tdb->getLateNameInfoList()->getNumEntries();
- rnl->resetFlags();
-
- for (Int32 i = 0;
- i < (Int32) (root_tdb->getLateNameInfoList()->
- getNumEntries());
- i++)
- {
- strcpy(rnl->getResolvedName(i).resolvedGuardianName(),
- root_tdb->getLateNameInfoList()->
- getLateNameInfo(i).resolvedPhyName());
-
- short ignore = (short) root_tdb->getLateNameInfoList()->
- getLateNameInfo(i).ignoreTS();
- rnl->getResolvedName(i).setIgnoreTS(ignore);
-
- rnl->getResolvedName(i).setResolvedAnsiName(
- root_tdb->getLateNameInfoList()->
- getLateNameInfo(i).getLastUsedName(&heap_)->getExternalName());
- }
-
- // if this is an IUD query,
- // move the number of indices defined on the target
- // table to the latenameinfo entry for that table.
- // At open time, if this is an sql/mp table and no timestamp
- // mismatch is detected, the number of indices will be
- // validate. See call to doArkOpen in file ex_sql_table.cpp,
- // method SqlTable::SqlTable.
- QuerySimilarityInfo * qsi = root_tdb->querySimilarityInfo();
- if ((qsi->getSimilarityCheckOption() != QuerySimilarityInfo::INTERNAL_SIM_CHECK) &&
- (qsi->indexInfoList()))
- {
- rnl->getResolvedName(qsi->namePosition()).setValidateNumIndexes(TRUE);
- rnl->getResolvedName(
- qsi->namePosition()).setNumIndexes(
- (short)qsi->indexInfoList()->numEntries());
- }
- } // lateNameInfoList present
-
StmtDebug1("[BEGIN fixup] %p", this);
NABoolean doSimCheck = FALSE;
@@ -4108,6 +3118,7 @@ RETCODE Statement::execute(CliGlobals * cliGlobals, Descriptor * input_desc,
state_ = EXECUTE_;
}
break;
+
case EXECUTE_:
{
if (masterStats != NULL)
@@ -4154,8 +3165,6 @@ RETCODE Statement::execute(CliGlobals * cliGlobals, Descriptor * input_desc,
}
}
-
- // BertBert VV
// in case this is a holdable cursor propagate flag to master executor
// leaf nodes
if (isPubsubHoldable() &&
@@ -5268,10 +4277,10 @@ RETCODE Statement::doOltExecute(CliGlobals *cliGlobals,
if (stmt_state != CLOSE_)
{
- // trying to execute a statement which is already in open
- // state
- diagsArea << DgSqlCode(- CLI_STMT_NOT_CLOSE);
- return ERROR;
+ // trying to execute a statement which is already in open
+ // state
+ diagsArea << DgSqlCode(- CLI_STMT_NOT_CLOSE);
+ return ERROR;
}
ExMasterStats * masterStats = NULL;
@@ -5296,7 +4305,7 @@ RETCODE Statement::doOltExecute(CliGlobals *cliGlobals,
masterStats-> setElapsedStartTime(jts);
masterStats->setFixupStartTime(-1);
masterStats->setFreeupStartTime(-1);
- masterStats->setExeStartTime(aqrInitialExeStartTime_ == -1 ? jts :
+ masterStats->setExeStartTime(aqrInitialExeStartTime_ == -1 ? jts :
aqrInitialExeStartTime_);
masterStats->setSqlErrorCode(0);
masterStats->setStmtState(STMT_EXECUTE_);
@@ -5336,7 +4345,7 @@ RETCODE Statement::doOltExecute(CliGlobals *cliGlobals,
if (root_tdb->aqrEnabled())
{
// return error. AQR will handle recompile and retry.
- return(ERROR);
+ return(ERROR);
}
else
{
@@ -5385,7 +4394,20 @@ RETCODE Statement::doOltExecute(CliGlobals *cliGlobals,
statsArea->restoreDop();
}
}
-
+
+ // do similarity check
+ if (root_tdb && root_tdb->querySimilarityInfo())
+ {
+ NABoolean simCheckFailed = FALSE;
+ retcode =
+ doQuerySimilarityCheck(root_tdb->querySimilarityInfo(),
+ simCheckFailed, diagsArea);
+
+ if (retcode == ERROR)
+ {
+ return ERROR;
+ }
+ }
ComDiagsArea* diagsPtr = NULL;
if (! fixupState()) // first time
@@ -5406,55 +4428,6 @@ RETCODE Statement::doOltExecute(CliGlobals *cliGlobals,
setFixupState(0);
- // move resolved names from LateNameInfoList to
- // ResolvedNameList which will be shipped to PA's
- if (root_tdb->getLateNameInfoList())
- {
- ResolvedNameList *&rnl =
- statementGlobals_->resolvedNameList();
- if (rnl && (rnl->numEntries() < root_tdb->getLateNameInfoList()->getNumEntries()))
- {
- // deallocate the previously allocated rnl
- heap_.deallocateMemory(rnl);
- rnl = NULL;
- }
-
- if (! rnl)
- rnl =
- (ResolvedNameList *)
- (new(&heap_)
- char[sizeof(ResolvedNameList) +
- ((root_tdb->getLateNameInfoList()->
- getNumEntries() > 0 ) ?
- ((root_tdb->getLateNameInfoList()->
- getNumEntries() - 1) * sizeof(ResolvedName)):
- 0)]);
-
- rnl->numEntries() =
- root_tdb->getLateNameInfoList()->getNumEntries();
- rnl->resetFlags();
-
- for (UInt32 i = 0;
- i < root_tdb->getLateNameInfoList()->getNumEntries();
- i++)
- {
- strcpy(rnl->getResolvedName((Int32) i).resolvedGuardianName(),
- root_tdb->getLateNameInfoList()->
- getLateNameInfo((Int32) i).resolvedPhyName());
-
- short ignore = (short) root_tdb->getLateNameInfoList()->
- getLateNameInfo((Int32) i).ignoreTS();
-
- rnl->getResolvedName((Int32) i).setIgnoreTS(ignore);
-
-#pragma nowarn(1506) // warning elimination
- rnl->getResolvedName(i).setResolvedAnsiName(
- root_tdb->getLateNameInfoList()->
- getLateNameInfo(i).getLastUsedName(&heap_)->getExternalName());
-#pragma warn(1506) // warning elimination
- }
- }
-
if (processDp2Xns)
{
implicitTransNeeded();
@@ -6705,55 +5678,6 @@ short Statement::rollbackTransaction(ComDiagsArea & diagsArea,
return 0;
}
-
-RETCODE Statement::doVisibilityCheck (LateNameInfoList * lnil,
- ComDiagsArea &diagsArea)
-{
- RETCODE retcode = SUCCESS;
-
- // Visibility Checks disabled for (10-081016-6563)
- //
- const NABoolean disableVisCheck = TRUE;
-
- if(disableVisCheck)
- return retcode;
-
- for (Int32 l = 0; l < (Int32) (lnil->getNumEntries()); l++)
- {
- LateNameInfo * lni = &(lnil->getLateNameInfo(l));
- if ( !lni->isAnsiPhySame() // the name is not a physical name
- && !lni->isAnsiNameChange() // has not been resolved via catman call
- && !lni->isView() ) // vis checks for views done elsewhere
- {
- retcode = checkObjectVisibility(lni->getLastUsedName(&heap_),
- lni->getNameSpace(),
- lni->resolvedPhyName(),
- diagsArea);
- if (retcode != SUCCESS )
- break;
- }
- }
-
- if (retcode == WARNING)
- {
- // Catalog is visible on local node, but either not visible or
- // unrelated on remote node. Force name mapping.
- retcode = forceMapAllNames (lnil, diagsArea);
- // Return WARNING so that the caller can force similarity check
- if (retcode != ERROR)
- retcode = WARNING;
- }
- return retcode;
-}
-
-RETCODE Statement::checkObjectVisibility( AnsiOrNskName *ansiName,
- const ComAnsiNameSpace nameSpace,
- char *guardianName,
- ComDiagsArea &diagsArea)
-{
- return ERROR;
-}
-
static
const NAWchar* get_name_mode(Lng32 name_mode)
{
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/074428ed/core/sql/cli/Statement.h
----------------------------------------------------------------------
diff --git a/core/sql/cli/Statement.h b/core/sql/cli/Statement.h
index 3b354bc..8babe27 100644
--- a/core/sql/cli/Statement.h
+++ b/core/sql/cli/Statement.h
@@ -452,17 +452,6 @@ private:
ex_root_tdb *assignRootTdb(ex_root_tdb *new_root_tdb);
-
- RETCODE getMatchingIndex(Queue * indexInfoList,
- char * indexAnsiName,
- char * indexPhyName,
- ComDiagsArea &diagsArea);
- RETCODE doVisibilityCheck (LateNameInfoList * lnil,
- ComDiagsArea &diagsArea);
- RETCODE checkObjectVisibility( AnsiOrNskName *ansiName,
- const ComAnsiNameSpace nameSpace,
- char *guardianName,
- ComDiagsArea &diagsArea);
NABoolean implicitTransNeeded(void);
void turnOffAutoCommit(void);
void resetAutoCommit(void);
@@ -550,33 +539,12 @@ public:
RETCODE getProxySyntax(char *proxy, Lng32 maxlength, Lng32 *spaceRequired,
const char *prefix, const char *suffix);
- RETCODE resolveNames(LateNameInfoList * lnil,
- Descriptor * input_desc,
- ComDiagsArea &diagsArea,
- NABoolean &doSimCheck,
- NABoolean &doFixup);
-
- RETCODE mapAnsiToGuaName(LateNameInfo * lni,
- ComDiagsArea &diagsArea);
-
- RETCODE forceMapAllNames(LateNameInfoList * lnil,
- ComDiagsArea &diagsArea);
-
- RETCODE doSimilarityCheck(SimilarityInfo * si,
- LateNameInfo * lni,
- char * guaName,
- NABoolean &simCheckFailed,
- ComDiagsArea &diagsArea);
-
- RETCODE doIUDSimilarityCheck(SimilarityInfo * si,
- LateNameInfo * lni,
- char * guaName,
- Queue * indexInfoList,
- NABoolean &simCheckFailed,
- ComDiagsArea &diagsArea);
-
- RETCODE doQuerySimilarityCheck(QuerySimilarityInfo * qsi,
- LateNameInfoList * lnil,
+ RETCODE doHiveTableSimCheck(TrafSimilarityTableInfo *si,
+ void* lobGlob,
+ NABoolean &simCheckFailed,
+ ComDiagsArea &diagsArea);
+
+ RETCODE doQuerySimilarityCheck(TrafQuerySimilarityInfo * qsi,
NABoolean &simCheckFailed,
ComDiagsArea &diagsArea);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/074428ed/core/sql/comexe/CmpMessage.cpp
----------------------------------------------------------------------
diff --git a/core/sql/comexe/CmpMessage.cpp b/core/sql/comexe/CmpMessage.cpp
index a375b36..38d7a19 100644
--- a/core/sql/comexe/CmpMessage.cpp
+++ b/core/sql/comexe/CmpMessage.cpp
@@ -261,15 +261,12 @@ void CmpMessageReplyBasic::unpackMyself(IpcMessageObjType objType,
CmpCompileInfo::CmpCompileInfo(char * sourceStr, Lng32 sourceStrLen,
Lng32 sourceStrCharSet,
- RecompLateNameInfoList * recompLateNameInfoList,
- Lng32 rlnilLen,
char * schemaName, Lng32 schemaNameLen,
char * recompControlInfo, Lng32 recompControlInfoLen,
ULng32 inputArrayMaxsize, short atomicity)
: flags_(0),
sqltext_(sourceStr), sqlTextLen_(sourceStrLen),
sqlTextCharSet_(sourceStrCharSet),
- rlnil_(recompLateNameInfoList), rlnilLen_(rlnilLen),
schemaName_(schemaName), schemaNameLen_(schemaNameLen),
recompControlInfo_(recompControlInfo), recompControlInfoLen_(recompControlInfoLen),
inputArrayMaxsize_(inputArrayMaxsize)
@@ -292,8 +289,6 @@ CmpCompileInfo::CmpCompileInfo()
sqltext_(NULL),
sqlTextLen_(0),
sqlTextCharSet_(0),
- rlnil_(NULL),
- rlnilLen_(0),
schemaName_(NULL),
schemaNameLen_(0),
recompControlInfo_(NULL),
@@ -309,8 +304,6 @@ void CmpCompileInfo::init()
sqltext_ = NULL;
sqlTextLen_ = 0;
sqlTextCharSet_ = 0;
- rlnil_ = NULL;
- rlnilLen_ = 0;
schemaName_ = NULL;
schemaNameLen_ = 0;
recompControlInfo_ = NULL;
@@ -328,7 +321,7 @@ Lng32 CmpCompileInfo::getLength()
Lng32 CmpCompileInfo::getVarLength()
{
return ROUND8(sqlTextLen_) +
- ROUND8(rlnilLen_) + ROUND8(schemaNameLen_)
+ ROUND8(schemaNameLen_)
+ ROUND8(recompControlInfoLen_);
}
@@ -342,13 +335,6 @@ void CmpCompileInfo::packVars(char * buffer, CmpCompileInfo *ci,
nextOffset += ROUND8(sqlTextLen_);
}
- if (rlnil_ && (rlnilLen_ > 0))
- {
- str_cpy_all(&buffer[nextOffset], (char *)rlnil_, rlnilLen_);
- ci->rlnil_ = (RecompLateNameInfoList *)nextOffset;
- nextOffset += ROUND8(rlnilLen_);
- }
-
if (schemaName_ && (schemaNameLen_ > 0))
{
str_cpy_all(&buffer[nextOffset], (char *)schemaName_, schemaNameLen_);
@@ -384,11 +370,6 @@ void CmpCompileInfo::unpack(char * base)
sqltext_ = base + (Lng32)((Long)sqltext_);
}
- if (rlnil_)
- {
- rlnil_ = (RecompLateNameInfoList *)(base + (Lng32)(Long)rlnil_);
- }
-
if (schemaName_)
{
schemaName_ = base + (Lng32)(Long)schemaName_;
@@ -401,7 +382,6 @@ void CmpCompileInfo::unpack(char * base)
}
void CmpCompileInfo::getUnpackedFields(char* &sqltext,
- RecompLateNameInfoList* &rlnil,
char* &schemaName,
char* &recompControlInfo)
{
@@ -412,11 +392,6 @@ void CmpCompileInfo::getUnpackedFields(char* &sqltext,
sqltext = base + (Lng32)(Long)sqltext_;
}
- if (rlnil_)
- {
- rlnil = (RecompLateNameInfoList *)(base + (Lng32)(Long)rlnil_);
- }
-
if (schemaName_)
{
schemaName = base + (Lng32)(Long)schemaName_;
@@ -474,7 +449,6 @@ CmpDDLwithStatusInfo::CmpDDLwithStatusInfo(char * sourceStr, Lng32 sourceStrLen,
char * schemaName, Lng32 schemaNameLen,
char * recompControlInfo, Lng32 recompControlInfoLen)
: CmpCompileInfo(sourceStr, sourceStrLen, sourceStrCharSet,
- NULL, 0,
schemaName, schemaNameLen,
recompControlInfo, recompControlInfoLen,
0, 0)
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/074428ed/core/sql/comexe/CmpMessage.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/CmpMessage.h b/core/sql/comexe/CmpMessage.h
index 5e284f3..8b5037d 100644
--- a/core/sql/comexe/CmpMessage.h
+++ b/core/sql/comexe/CmpMessage.h
@@ -64,7 +64,6 @@ class CmpMessageCompileStmt;
class ex_expr;
class sql_buffer;
-class RecompLateNameInfoList;
class FragmentDir;
// -----------------------------------------------------------------------
@@ -310,8 +309,6 @@ class CmpCompileInfo
public:
CmpCompileInfo(char * sourceStr, Lng32 sourceStrLen,
Lng32 sourceStrCharSet,
- RecompLateNameInfoList * recompLateNameInfoList,
- Lng32 rlnilLen,
char * schemaName, Lng32 schemaNameLen,
char * recompControlInfo, Lng32 recompControlInfoLen,
ULng32 inputArrayMaxsize,
@@ -329,7 +326,6 @@ public:
void unpack(char * base);
void getUnpackedFields(char* &sqltext,
- RecompLateNameInfoList* &rlnil,
char* &schemaName,
char* &recompControlInfo);
@@ -419,8 +415,7 @@ protected:
char * sqltext_; // 00-03
Lng32 sqlTextLen_; // 04-07
- RecompLateNameInfoList * rlnil_; // 08-11
- Lng32 rlnilLen_; // 12-15
+ Lng32 unused_; // 12-15
char * schemaName_; // 16-19
Lng32 schemaNameLen_; // 20-23
ULng32 inputArrayMaxsize_; // 24-27
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/074428ed/core/sql/comexe/ComTdbRoot.cpp
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdbRoot.cpp b/core/sql/comexe/ComTdbRoot.cpp
index b66e19d..511e991 100644
--- a/core/sql/comexe/ComTdbRoot.cpp
+++ b/core/sql/comexe/ComTdbRoot.cpp
@@ -100,7 +100,7 @@ void ComTdbRoot::init(ComTdb * child_tdb,
SqlTableOpenInfo **stoiList,
LateNameInfoList * lateNameInfoList,
Queue *viewStoiList,
- QuerySimilarityInfo * qsi,
+ TrafQuerySimilarityInfo * qsi,
Space *space,
Lng32 uniqueExecuteIdOffset, // ++Triggers -
Lng32 triggersStatusOffset,
@@ -542,6 +542,13 @@ void ComTdbRoot::displayContents(Space * space,ULng32 flag)
space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));
}
+ if (querySimilarityInfo() && querySimilarityInfo()->siList())
+ {
+ str_sprintf(buf,"querySimilarityInfo()->siList()->numEntries() = %d ",
+ querySimilarityInfo()->siList()->entries());
+ space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));
+ }
+
Lng32 fragOffset;
Lng32 fragLen;
Lng32 topNodeOffset;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/074428ed/core/sql/comexe/ComTdbRoot.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdbRoot.h b/core/sql/comexe/ComTdbRoot.h
index f7662fe..3f3b6ce 100644
--- a/core/sql/comexe/ComTdbRoot.h
+++ b/core/sql/comexe/ComTdbRoot.h
@@ -51,7 +51,7 @@ class Descriptor;
class TransMode;
class ExFragDir;
class LateNameInfoList;
-class QuerySimilarityInfo;
+class TragQuerySimilarityInfo;
class Queue;
typedef NABasicPtrTempl<Int64> Int64Ptr; // Needed for triggersList_
@@ -456,8 +456,7 @@ protected:
LateNameInfoListPtr lateNameInfoList_; // 120-127
// contains info used to perform similarity info at runtime.
- QuerySimilarityInfoPtr qsi_; // 128-135
-
+ TrafQuerySimilarityInfoPtr qsi_; // 128-135
// contains the name of the cursor
NABasicPtr fetchedCursorName_; // 136-143
@@ -659,7 +658,7 @@ public:
SqlTableOpenInfo **stoiList,
LateNameInfoList * lateNameInfoList,
Queue *viewStoiList,
- QuerySimilarityInfo * qsi,
+ TrafQuerySimilarityInfo * qsi,
Space *space,
Lng32 uniqueExecuteIdOffset, //++Triggers -
Lng32 triggersStatusOffset,
@@ -863,7 +862,7 @@ public:
Queue* getViewStoiList() {return viewStoiList_; }
- QuerySimilarityInfo * querySimilarityInfo() { return qsi_; };
+ TrafQuerySimilarityInfo * querySimilarityInfo() { return qsi_; };
UninitializedMvName * uninitializedMvList() { return uninitializedMvList_; }
short uninitializedMvCount() { return uninitializedMvCount_; }
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/074428ed/core/sql/comexe/LateBindInfo.cpp
----------------------------------------------------------------------
diff --git a/core/sql/comexe/LateBindInfo.cpp b/core/sql/comexe/LateBindInfo.cpp
index 0422c7b..8574ea1 100644
--- a/core/sql/comexe/LateBindInfo.cpp
+++ b/core/sql/comexe/LateBindInfo.cpp
@@ -194,55 +194,6 @@ static void extractPartsLocal(char * invalue, char *inVal[], short inValLen[])
}
-NABoolean LateNameInfo::applyMPAliasDefaults(char * invalue,
- char * outvalue,
- char * defValString)
-{
-
- char * defVal[3] = {NULL, NULL, NULL};
- short defValLen[3] = {0, 0, 0};
- char * inVal[3] = {NULL, NULL, NULL};
- short inValLen[3] = {0, 0, 0};
-
- // extract cat and schema name from defValString
- extractPartsLocal(defValString, defVal, defValLen);
-
- // extract parts from invalue
- extractPartsLocal(invalue, inVal, inValLen);
-
- // fill in the missing parts of invalue and create outvalue
- Int32 outlen=0;
- if (inVal[0] == NULL)
- {
- outlen = defValLen[0] + 1;
- str_cpy_all(outvalue, defVal[0], outlen);
- }
- else
- {
- outlen = inValLen[0] + 1;
- str_cpy_all(outvalue, inVal[0], outlen);
- }
-
- if (inVal[1] == NULL)
- {
- str_cpy_all(&outvalue[outlen], defVal[1], defValLen[1]+1);
- outlen += defValLen[1]+1;
- }
- else
- {
- str_cpy_all(&outvalue[outlen], inVal[1], inValLen[1]+1);
- outlen += inValLen[1]+1;
- }
-
- str_cpy_all(&outvalue[outlen], inVal[2], inValLen[2]);
- outlen += inValLen[2];
-
- outvalue[outlen] = 0;
-
- return TRUE;
-}
-// LCOV_EXCL_STOP
-
Long LateNameInfoList::pack(void *space)
{
#pragma nowarn(1506) // warning elimination
@@ -259,227 +210,6 @@ Lng32 LateNameInfoList::unpack(void * base, void * reallocator)
return NAVersionedObject::unpack(base, reallocator);
}
-// returns the length of total info that needs to be sent to compiler
-// at recomp time. This info is used to get to the actual tablename
-// (and not the prototype name) that was specified thru a hvar/param/env
-// var.
-ULng32 LateNameInfoList::getRecompLateNameInfoListLen()
-{
- ULng32 numEntriesToSend = 0;
- for (ULng32 i = 0; i < getNumEntries(); i++)
- {
- if (lateNameInfo_[i]->isVariable())
- numEntriesToSend++;
- }
-
- if (numEntriesToSend > 0)
- return sizeof(RecompLateNameInfoList) +
- ((numEntriesToSend-1) * sizeof(RecompLateNameInfo));
- else
- return 0;
-}
-
-// puts recomp info into 'buffer'. Space is to be allocated by caller.
-void LateNameInfoList::getRecompLateNameInfoList(char * buffer)
-{
- RecompLateNameInfoList * rlnil = (RecompLateNameInfoList *)buffer;
-
- Int32 j = 0;
- for (UInt32 i = 0; i < getNumEntries(); i++)
- {
- if (lateNameInfo_[i]->isVariable())
- {
- str_cpy_and_null(rlnil->getRecompLateNameInfo(j).varName(),
- lateNameInfo_[i]->variableName(),
- str_len(lateNameInfo_[i]->variableName()) + 1);
-
- str_cpy_and_null(rlnil->getRecompLateNameInfo(j).compileTimeAnsiName(),
- lateNameInfo_[i]->compileTimeAnsiName(),
- str_len(lateNameInfo_[i]->compileTimeAnsiName())+1);
-
- str_cpy_and_null(rlnil->getRecompLateNameInfo(j).actualAnsiName(),
- lateNameInfo_[i]->lastUsedExtAnsiName(),
- str_len(lateNameInfo_[i]->lastUsedExtAnsiName())+1);
-
-#pragma nowarn(1506) // warning elimination
- rlnil->getRecompLateNameInfo(j).setMPalias(lateNameInfo_[i]->isMPalias());
-#pragma warn(1506) // warning elimination
-
- j++;
- } // if
-
- } // for
-
- if (j > 0)
- rlnil->numEntries() = j;
-}
-
-ULng32 LateNameInfoList::getRecompLateNameInfoListLenPre1800()
-{
- ULng32 numEntriesToSend = 0;
- for (ULng32 i = 0; i < getNumEntries(); i++)
- {
- if (lateNameInfo_[i]->isVariable())
- numEntriesToSend++;
- }
-
- if (numEntriesToSend > 0)
- return sizeof(RecompLateNameInfoListPre1800) +
- ((numEntriesToSend-1) * sizeof(RecompLateNameInfoPre1800));
- else
- return 0;
-}
-
-
-// puts recomp info into 'buffer'. Space is to be allocated by caller.
-void LateNameInfoList::getRecompLateNameInfoListPre1800(char * buffer)
-{
- RecompLateNameInfoListPre1800 * rlnil = (RecompLateNameInfoListPre1800 *)buffer;
-
- Int32 j = 0;
- for (UInt32 i = 0; i < getNumEntries(); i++)
- {
- if (lateNameInfo_[i]->isVariable())
- {
- str_cpy_and_null(rlnil->getRecompLateNameInfo(j).varName(),
- lateNameInfo_[i]->variableName(),
- str_len(lateNameInfo_[i]->variableName()) + 1);
-
- str_cpy_and_null(rlnil->getRecompLateNameInfo(j).compileTimeAnsiName(),
- lateNameInfo_[i]->compileTimeAnsiName(),
- str_len(lateNameInfo_[i]->compileTimeAnsiName())+1);
-
-
- str_cpy_and_null(rlnil->getRecompLateNameInfo(j).actualAnsiName(),
- lateNameInfo_[i]->lastUsedExtAnsiName(),
- str_len(lateNameInfo_[i]->lastUsedExtAnsiName())+1);
-
-#pragma nowarn(1506) // warning elimination
- rlnil->getRecompLateNameInfo(j).setMPalias(lateNameInfo_[i]->isMPalias());
-#pragma warn(1506) // warning elimination
-
- j++;
- } // if
-
- } // for
-
- if (j > 0)
- rlnil->numEntries() = j;
-}
-
-
-void LateNameInfoList::resetRuntimeFlags()
-{
- for (UInt32 i = 0; i < getNumEntries(); i++)
- {
- lateNameInfo_[i]->resetRuntimeFlags();
- }
-}
-
-
-
-SimilarityTableInfo::SimilarityTableInfo()
- : NAVersionedObject(-1)
-{
- flags_ = 0;
-}
-
-SimilarityTableInfo::~SimilarityTableInfo()
-{
-}
-
-Long SimilarityTableInfo::pack(void * space)
-{
- return NAVersionedObject::pack(space);
-}
-
-Lng32 SimilarityTableInfo::unpack(void * base, void * reallocator)
-{
- return 0;
-}
-
-SimilarityInfo::SimilarityInfo(CollHeap * heap)
- : NAVersionedObject(-1)
-{
- tupleDesc_ = 0;
- colNameList_ = 0;
- sti_ = 0;
- runtimeFlags_ = 0;
- compiletimeFlags_ = 0;
- mvAttributesBitmap_ = 0;
-
-}
-
-SimilarityInfo::~SimilarityInfo()
-{
-}
-
-Long SimilarityInfo::pack(void * space)
-{
- return NAVersionedObject::pack(space);
-}
-
-Lng32 SimilarityInfo::unpack(void * base, void * reallocator)
-{
- // ------------------------------------------------------------------------
- // Notice that objects referenced by keyClass_ and indexMapArray_ have been
- // packed based on a different base (see SimilarityInfo::pack()). Hence,
- // they have to be unpacked correspondingly.
- // ------------------------------------------------------------------------
- if(tupleDesc_.unpack(base, reallocator)) return -1;
- if(colNameList_.unpack(base, reallocator)) return -1;
- if(sti_.unpack(base, reallocator)) return -1;
- return NAVersionedObject::unpack(base, reallocator);
-}
-
-QuerySimilarityInfo::QuerySimilarityInfo()
- : heap_(NULL), option_(RECOMP_ON_TS_MISMATCH), NAVersionedObject(-1), siList_(NULL),
- indexInfoList_(NULL)
-{
-}
-
-QuerySimilarityInfo::QuerySimilarityInfo(CollHeap * heap)
- : heap_(heap), option_(RECOMP_ON_TS_MISMATCH), NAVersionedObject(-1)
-{
- siList_ = new(heap) Queue(heap);
- indexInfoList_ = 0;
-}
-
-QuerySimilarityInfo::~QuerySimilarityInfo()
-{
-
-}
-
-Long QuerySimilarityInfo::pack(void * space)
-{
- PackQueueOfNAVersionedObjects(siList_,space,SimilarityInfo);
-
- //PackQueueOfNonNAVersionedObjects(indexInfoList_,space,IndexInfo);
- PackQueueOfNAVersionedObjects(indexInfoList_,space,IndexInfo);
-
- return NAVersionedObject::pack(space);
-}
-
-Lng32 QuerySimilarityInfo::unpack(void * base, void * reallocator)
-{
- UnpackQueueOfNAVersionedObjects(siList_,base,SimilarityInfo,reallocator);
-
- //UnpackQueueOfNonNAVersionedObjects(indexInfoList_,base,IndexInfo);
- UnpackQueueOfNAVersionedObjects(indexInfoList_,base,IndexInfo,reallocator);
-
- return NAVersionedObject::unpack(base, reallocator);
-}
-
-Long IndexInfo::pack(void * space)
-{
- return NAVersionedObject::pack(space);
-}
-
-Lng32 IndexInfo::unpack(void * base, void * reallocator)
-{
- return NAVersionedObject::unpack(base, reallocator);
-}
-
AnsiOrNskName::AnsiOrNskName(char *inName)
{
Int32 len;
@@ -1319,37 +1049,102 @@ Int16 AnsiOrNskName::quoteNSKExtName()
return 0;
}
-void ResolvedNameListPre1800::translateFromNewVersion(ResolvedNameList *newrnl)
+///////////////////////////////////////////////////////////////////
+// class TrafSimilarityTableInfo
+///////////////////////////////////////////////////////////////////
+TrafSimilarityTableInfo::TrafSimilarityTableInfo(char * tableName,
+ NABoolean isHive,
+ char * hdfsRootDir,
+ Int64 modTS, Int32 numPartnLevels,
+ Queue * hdfsDirsToCheck,
+ char * hdfsHostName,
+ Int32 hdfsPort)
+ : NAVersionedObject(-1),
+ tableName_(tableName),
+ hdfsRootDir_(hdfsRootDir),
+ modTS_(modTS), numPartnLevels_(numPartnLevels),
+ hdfsDirsToCheck_(hdfsDirsToCheck),
+ hdfsHostName_(hdfsHostName), hdfsPort_(hdfsPort)
{
- this->numEntries()= newrnl->numEntries();
- this->resetFlags();
- for (Int32 i = 0; i < (Int32) (newrnl->numEntries());i++)
- {
- strcpy(this->getResolvedName(i).resolvedGuardianName(),
- newrnl->getResolvedName(i).resolvedGuardianName());
-
- this->getResolvedName(i).setIgnoreTS((short)newrnl->getResolvedName(i).ignoreTS());
- this->getResolvedName(i).setResolvedAnsiName(newrnl->getResolvedName(i).resolvedAnsiName());
- this->getResolvedName(i).setValidateNumIndexes((short)newrnl->getResolvedName(i).validateNumIndexes());
- this->getResolvedName(i).setNumIndexes(newrnl->getResolvedName(i).numIndexes());
- }
+ if (isHive)
+ setIsHive(TRUE);
}
-void ResolvedNameList::translateFromOldVersion(ResolvedNameListPre1800 *oldrnl)
+TrafSimilarityTableInfo::TrafSimilarityTableInfo()
+ : NAVersionedObject(-1),
+ tableName_(NULL),
+ hdfsRootDir_(NULL),
+ modTS_(-1), numPartnLevels_(-1),
+ hdfsDirsToCheck_(NULL),
+ hdfsHostName_(NULL), hdfsPort_(NULL)
{
- this->numEntries() = oldrnl->numEntries();
- this->resetFlags();
- this->resetFiller();
- for (Int32 i = 0; i < (Int32) (oldrnl->numEntries());i++)
- {
- strcpy(this->getResolvedName(i).resolvedGuardianName(),
- oldrnl->getResolvedName(i).resolvedGuardianName());
-
- this->getResolvedName(i).setIgnoreTS((short)oldrnl->getResolvedName(i).ignoreTS());
- this->getResolvedName(i).setResolvedAnsiName(oldrnl->getResolvedName(i).resolvedAnsiName());
- this->getResolvedName(i).setValidateNumIndexes((short)oldrnl->getResolvedName(i).validateNumIndexes());
- this->getResolvedName(i).setNumIndexes(oldrnl->getResolvedName(i).numIndexes());
- }
- }
+}
+
+TrafSimilarityTableInfo::~TrafSimilarityTableInfo()
+{
+}
+
+NABoolean TrafSimilarityTableInfo::operator==(TrafSimilarityTableInfo &o)
+{
+ return ((isHive() == o.isHive()) &&
+ (strcmp(tableName(), ((TrafSimilarityTableInfo&)o).tableName()) == 0));
+}
+
+Long TrafSimilarityTableInfo::pack(void * space)
+{
+ tableName_.pack(space);
+ hdfsRootDir_.pack(space);
+ hdfsHostName_.pack(space);
+
+ hdfsDirsToCheck_.pack(space);
+
+ return NAVersionedObject::pack(space);
+}
+
+Lng32 TrafSimilarityTableInfo::unpack(void * base, void * reallocator)
+{
+ if(tableName_.unpack(base)) return -1;
+ if(hdfsRootDir_.unpack(base)) return -1;
+ if(hdfsHostName_.unpack(base)) return -1;
+
+ if(hdfsDirsToCheck_.unpack(base, reallocator)) return -1;
+
+ return NAVersionedObject::unpack(base, reallocator);
+}
+
+///////////////////////////////////////////////////////////////////
+// class TrafQuerySimilarityInfo
+///////////////////////////////////////////////////////////////////
+TrafQuerySimilarityInfo::TrafQuerySimilarityInfo(Queue * siList)
+ : NAVersionedObject(-1),
+ siList_(siList)
+{
+}
+
+TrafQuerySimilarityInfo::TrafQuerySimilarityInfo()
+ : NAVersionedObject(-1),
+ siList_(NULL)
+{
+}
+
+TrafQuerySimilarityInfo::~TrafQuerySimilarityInfo()
+{
+}
+
+Long TrafQuerySimilarityInfo::pack(void * space)
+{
+ PackQueueOfNAVersionedObjects(siList_,space,TrafSimilarityTableInfo);
+
+ return NAVersionedObject::pack(space);
+}
+
+Lng32 TrafQuerySimilarityInfo::unpack(void * base, void * reallocator)
+{
+ UnpackQueueOfNAVersionedObjects(siList_,base,TrafSimilarityTableInfo,reallocator);
+
+ return NAVersionedObject::unpack(base, reallocator);
+}
+
+
// End