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/08/15 18:06:50 UTC
[3/4] incubator-trafodion git commit: showplan enhancement to display
expr instruction
showplan enhancement to display expr instruction
display the instruction enum being generated in
text format.
Output will include the instruction and look like:
Clause #2: ex_arith_clause
...
instruction: ADD_BIN16S_BIN16S_BIN16S(0), instrArrayIndex_: 0
Clause #1: ex_comp_clause
OperatorTypeEnum = ITM_GREATER(2024), NumOperands = 3
...
instruction: GT_BIN32S_BIN16S(40), instrArrayIndex_: 218
In addition, some cleanup has been done in expression
code.
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/4c83ecab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/4c83ecab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/4c83ecab
Branch: refs/heads/master
Commit: 4c83ecab0363b8ddde84c92a7843b26e72c82413
Parents: a0a6363
Author: Anoop Sharma <an...@esgyn.com>
Authored: Mon Aug 15 01:35:03 2016 +0000
Committer: Anoop Sharma <an...@esgyn.com>
Committed: Mon Aug 15 01:35:03 2016 +0000
----------------------------------------------------------------------
core/sql/cli/CliExpExchange.cpp | 14 +-
core/sql/comexe/ComTdbStoredProc.cpp | 2 +-
core/sql/comexe/ComTdbStoredProc.h | 8 +-
core/sql/common/DateTimeType.cpp | 8 +-
core/sql/common/IntervalType.cpp | 2 +-
core/sql/common/NumericType.cpp | 2 +-
core/sql/common/OperTypeEnum.h | 8 +-
core/sql/common/dfs2rec.h | 1 +
core/sql/executor/ExFastTransport.cpp | 7 +-
core/sql/exp/ExpPCodeClauseGen.cpp | 70 +-
core/sql/exp/ExpPCodeOptimizations.cpp | 10 +-
core/sql/exp/ExpPCodeOptsNativeExpr.cpp | 84 +-
core/sql/exp/exp_arith.cpp | 2 +-
core/sql/exp/exp_clause.cpp | 57 +-
core/sql/exp/exp_clause.h | 20 +-
core/sql/exp/exp_clause_derived.h | 745 +++++----
core/sql/exp/exp_comp.cpp | 2 +-
core/sql/exp/exp_conv.cpp | 16 +-
core/sql/exp/exp_expr.cpp | 2 +-
core/sql/exp/exp_fixup.cpp | 2272 ++++++++++++++------------
core/sql/exp/exp_function.cpp | 2 +-
core/sql/generator/GenPreCode.cpp | 10 +-
core/sql/generator/GenStoredProc.cpp | 12 +-
23 files changed, 1784 insertions(+), 1572 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/cli/CliExpExchange.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/CliExpExchange.cpp b/core/sql/cli/CliExpExchange.cpp
index d047b0c..8de03e6 100644
--- a/core/sql/cli/CliExpExchange.cpp
+++ b/core/sql/cli/CliExpExchange.cpp
@@ -1830,7 +1830,7 @@ InputOutputExpr::outputValues(atp_struct *atp,
}
} // implicit conversion
- conv_case_index case_index = CONV_UNKNOWN;
+ ConvInstruction case_index = CONV_UNKNOWN;
ULng32 convFlags = 0;
if ((source) &&
(NOT implicitConversion) &&
@@ -3733,9 +3733,9 @@ InputOutputExpr::inputValues(atp_struct *atp,
Lng32 numToProcess = ((targetRowsetSize > 0) ? targetRowsetSize : 1);
// Define and clear case indexes potentially used for rowsets
- conv_case_index index1 = CONV_UNKNOWN;
- conv_case_index index2 = CONV_UNKNOWN;
- conv_case_index index3 = CONV_UNKNOWN;
+ ConvInstruction index1 = CONV_UNKNOWN;
+ ConvInstruction index2 = CONV_UNKNOWN;
+ ConvInstruction index3 = CONV_UNKNOWN;
for (Lng32 RowNum = 0; RowNum < numToProcess; RowNum++)
{
@@ -4014,7 +4014,7 @@ InputOutputExpr::inputValues(atp_struct *atp,
// Initialize index for this convDoIt call, if needed
if (index1 == CONV_UNKNOWN) {
ex_conv_clause tempClause;
- index1 = tempClause.find_case_index(sourceType,
+ index1 = tempClause.findInstruction(sourceType,
sourceLen,
REC_BYTE_F_ASCII,
sourceLen,
@@ -4129,7 +4129,7 @@ InputOutputExpr::inputValues(atp_struct *atp,
// Initialize index for this convDoIt call, if needed
if (index2 == CONV_UNKNOWN) {
ex_conv_clause tempClause;
- index2 = tempClause.find_case_index(REC_BYTE_F_ASCII,
+ index2 = tempClause.findInstruction(REC_BYTE_F_ASCII,
sourceLen,
sourceType,
intermediateLen,
@@ -4176,7 +4176,7 @@ InputOutputExpr::inputValues(atp_struct *atp,
// Initialize index for this convDoIt call, if needed
if (index3 == CONV_UNKNOWN) {
ex_conv_clause tempClause;
- index3 = tempClause.find_case_index(sourceType,
+ index3 = tempClause.findInstruction(sourceType,
sourceLen,
operand->getDatatype(),
operand->getLength(),
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/comexe/ComTdbStoredProc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdbStoredProc.cpp b/core/sql/comexe/ComTdbStoredProc.cpp
index 4e59d5d..16a22a6 100644
--- a/core/sql/comexe/ComTdbStoredProc.cpp
+++ b/core/sql/comexe/ComTdbStoredProc.cpp
@@ -141,7 +141,7 @@ ExSPInputOutput::ExSPInputOutput() : NAVersionedObject(-1)
void ExSPInputOutput::initialize(ExpTupleDesc * tupleDesc,
ULng32 totalLen,
- conv_case_index * caseIndexArray)
+ ConvInstruction * caseIndexArray)
{
tupleDesc_ = tupleDesc;
totalLen_ = totalLen;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/comexe/ComTdbStoredProc.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdbStoredProc.h b/core/sql/comexe/ComTdbStoredProc.h
index 9b16d2c..4bd478f 100644
--- a/core/sql/comexe/ComTdbStoredProc.h
+++ b/core/sql/comexe/ComTdbStoredProc.h
@@ -60,7 +60,7 @@ public:
void initialize(ExpTupleDesc * tupleDesc,
ULng32 totalLen,
- conv_case_index * caseIndexArray);
+ ConvInstruction * caseIndexArray);
// ---------------------------------------------------------------------
// Redefine virtual functions required for Versioning.
@@ -91,8 +91,8 @@ public:
ULng32 getLength(){return totalLen_;};
- conv_case_index * getCaseIndexArray()
- { return (conv_case_index *)(short *)caseIndexArray_; }
+ ConvInstruction * getCaseIndexArray()
+ { return (ConvInstruction *)(short *)caseIndexArray_; }
protected:
@@ -104,7 +104,7 @@ protected:
// pointer to the record descriptor
ExpTupleDescPtr tupleDesc_; // 08-15
- // this is a (enum conv_case_index *) before.
+ // this is a (enum ConvInstruction *) before.
Int16Ptr caseIndexArray_; // 16-23
// length of ExSPInputOutput starting at 'this'. All classes following
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/common/DateTimeType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/DateTimeType.cpp b/core/sql/common/DateTimeType.cpp
index dca78cd..43e57b0 100644
--- a/core/sql/common/DateTimeType.cpp
+++ b/core/sql/common/DateTimeType.cpp
@@ -814,7 +814,7 @@ NABoolean DatetimeType::createSQLLiteral(const char * buf,
sizeof(resultLen),
h,
&diags,
- conv_case_index::CONV_UNKNOWN,
+ ConvInstruction::CONV_UNKNOWN,
0);
if ( ok != ex_expr::EXPR_OK || resultLen == 0)
@@ -1079,7 +1079,7 @@ double SQLDate::encodeSqlLiteral(char* source) const
NULL, 0,
0, // heap
0, // diagsPtr
- conv_case_index::CONV_UNKNOWN,
+ ConvInstruction::CONV_UNKNOWN,
0,// data conversionErrorFlag
0 // flags
);
@@ -1172,7 +1172,7 @@ double SQLTime::encodeSqlLiteral(char* source) const
NULL, 0,
0, // heap
0, // diagsPtr
- conv_case_index::CONV_UNKNOWN,
+ ConvInstruction::CONV_UNKNOWN,
0,// data conversionErrorFlag
0 // flags
);
@@ -1274,7 +1274,7 @@ double SQLTimestamp::encodeSqlLiteral(char* source) const
NULL, 0,
0, // heap
0, // diagsPtr
- conv_case_index::CONV_UNKNOWN,
+ ConvInstruction::CONV_UNKNOWN,
0,// data conversionErrorFlag
0 // flags
);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/common/IntervalType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/IntervalType.cpp b/core/sql/common/IntervalType.cpp
index 00733fe..9456816 100644
--- a/core/sql/common/IntervalType.cpp
+++ b/core/sql/common/IntervalType.cpp
@@ -633,7 +633,7 @@ NABoolean IntervalType::createSQLLiteral(const char * buf,
sizeof(numValLen),
h,
&diags,
- conv_case_index::CONV_UNKNOWN,
+ ConvInstruction::CONV_UNKNOWN,
0);
if ( ok != ex_expr::EXPR_OK || numValLen == 0)
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/common/NumericType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/NumericType.cpp b/core/sql/common/NumericType.cpp
index 9bb4bfb..1db027e 100644
--- a/core/sql/common/NumericType.cpp
+++ b/core/sql/common/NumericType.cpp
@@ -792,7 +792,7 @@ NABoolean NumericType::createSQLLiteral(const char * buf,
sizeof(resultLen),
h,
&diags,
- conv_case_index::CONV_UNKNOWN,
+ ConvInstruction::CONV_UNKNOWN,
0);
if ( ok != ex_expr::EXPR_OK || resultLen == 0)
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/common/OperTypeEnum.h
----------------------------------------------------------------------
diff --git a/core/sql/common/OperTypeEnum.h b/core/sql/common/OperTypeEnum.h
index f524d33..f221e1d 100644
--- a/core/sql/common/OperTypeEnum.h
+++ b/core/sql/common/OperTypeEnum.h
@@ -284,10 +284,7 @@ enum OperatorTypeEnum {
// item operators (predicates)
// ---------------------------------------------------
// NOTE: the numbers for ITM operator types are also
- // used for expressions in the executor. Do NOT
- // change any numbers in this range without adding
- // versioning support in DP2. Try to add new numbers
- // rather than changing existing numbers.
+ // used for expressions in the executor.
// ---------------------------------------------------
ITM_FIRST_ITEM_OP = 2000,
// binary logic operators
@@ -313,6 +310,9 @@ enum OperatorTypeEnum {
// new operator type used in the hash anti semi join optimization project
//
ITM_NOT_IN = 2026,
+
+ ITM_ANY_COMP = 2027,
+
// unary arithmetic operators
ITM_NEGATE = 2030,
ITM_INVERSE = 2031,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/common/dfs2rec.h
----------------------------------------------------------------------
diff --git a/core/sql/common/dfs2rec.h b/core/sql/common/dfs2rec.h
index 08ecdb2..1d27fa2 100644
--- a/core/sql/common/dfs2rec.h
+++ b/core/sql/common/dfs2rec.h
@@ -237,6 +237,7 @@ enum REC_DATETIME_CODE {
#define REC_MAX_INTERVAL_MP 212
#define REC_MAX_INTERVAL_MP 212
+#define REC_UNKNOWN -1
// Keep this in synch with ComDateTimeStartEnd in ComSmallDefs.h
enum rec_datetime_field {
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/executor/ExFastTransport.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExFastTransport.cpp b/core/sql/executor/ExFastTransport.cpp
index bec43e2..7676013 100644
--- a/core/sql/executor/ExFastTransport.cpp
+++ b/core/sql/executor/ExFastTransport.cpp
@@ -1,4 +1,3 @@
-
/**********************************************************************
// @@@ START COPYRIGHT @@@
//
@@ -612,7 +611,7 @@ void ExHdfsFastExtractTcb::convertSQRowToString(ULng32 nullLen,
targetData += nullLen;
currBuffer_->bytesLeft_ -= nullLen;
} else {
- switch ((conv_case_index) sourceFieldsConvIndex_[i]) {
+ switch ((ConvInstruction) sourceFieldsConvIndex_[i]) {
case CONV_ASCII_V_V:
case CONV_ASCII_F_V:
case CONV_UNICODE_V_V:
@@ -631,7 +630,7 @@ void ExHdfsFastExtractTcb::convertSQRowToString(ULng32 nullLen,
targetData, attr2->getLength(), attr2->getDatatype(),
attr2->getPrecision(), attr2->getScale(), (char*) &vcActualLen,
sizeof(vcActualLen), 0, 0, // diags may need to be added
- (conv_case_index) sourceFieldsConvIndex_[i]);
+ (ConvInstruction) sourceFieldsConvIndex_[i]);
if (err == ex_expr::EXPR_ERROR) {
convError = TRUE;
@@ -889,7 +888,7 @@ ExWorkProcRetcode ExHdfsFastExtractTcb::work()
ex_conv_clause tempClause;
int convIndex = 0;
sourceFieldsConvIndex_[i] =
- tempClause.find_case_index(
+ tempClause.findInstruction(
attr->getDatatype(),
0,
attr2->getDatatype(),
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/exp/ExpPCodeClauseGen.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpPCodeClauseGen.cpp b/core/sql/exp/ExpPCodeClauseGen.cpp
index 60ebe2c..7ab9a35 100644
--- a/core/sql/exp/ExpPCodeClauseGen.cpp
+++ b/core/sql/exp/ExpPCodeClauseGen.cpp
@@ -807,7 +807,7 @@ ex_expr::exp_return_type ex_comp_clause::pCodeGenerate(Space *space, UInt32 f) {
// Generate the standard clause->eval PCode for cases that
// are not handled with more fundamental PCode operations.
//
- switch(get_case_index()) {
+ switch(getInstruction()) {
case NE_ASCII_F_F:
case EQ_ASCII_F_F:
case LT_ASCII_F_F:
@@ -979,7 +979,7 @@ ex_expr::exp_return_type ex_comp_clause::pCodeGenerate(Space *space, UInt32 f) {
// Generate the comparison operator
//
PCIT::Operation op = PCIT::Op_OPDATA; // prevent init warning
- switch(get_case_index()) {
+ switch(getInstruction()) {
case EQ_BIN32S_BIN16S:
case EQ_BIN32U_BIN16U:
@@ -2033,7 +2033,7 @@ ex_expr::exp_return_type ex_arith_clause::unaryArithPCodeGenerate
AttributesPtr *attrs = getOperand();
- switch(get_case_index()) {
+ switch(getInstruction()) {
case NEGATE_BOOLEAN:
break;
@@ -2070,7 +2070,7 @@ ex_expr::exp_return_type ex_arith_clause::unaryArithPCodeGenerate
OL *ol = NULL;
PCIT::Operation inst = PCIT::Op_OPDATA; // prevent uninitialized var warning
- switch(get_case_index())
+ switch(getInstruction())
{
case NEGATE_BOOLEAN:
aml = &aml2;
@@ -2136,7 +2136,7 @@ ex_expr::exp_return_type ex_arith_clause::pCodeGenerate(Space *space, UInt32 f)
// are not handled with more fundamental PCode operations.
//
AttributesPtr *attrs = getOperand();
- switch(get_case_index()) {
+ switch(getInstruction()) {
case ADD_BIN16S_BIN16S_BIN16S:
case ADD_BIN32S_BIN32S_BIN32S:
case ADD_BIN64S_BIN64S_BIN64S:
@@ -2290,7 +2290,7 @@ ex_expr::exp_return_type ex_arith_clause::pCodeGenerate(Space *space, UInt32 f)
AML *aml = NULL;
OL *ol = NULL;
PCIT::Operation inst = PCIT::Op_OPDATA; // prevent uninitialized var warning
- switch(get_case_index())
+ switch(getInstruction())
{
case ADD_BIN32S_BIN16S_BIN32S:
case ADD_BIN64S_BIN32S_BIN64S:
@@ -2446,7 +2446,7 @@ ex_expr::exp_return_type ex_arith_sum_clause::pCodeGenerate(Space *space, UInt32
// are not handled with more fundamental PCode operations.
// Since this is arith_sum, only add operations should appear.
//
- switch(get_case_index()) {
+ switch(getInstruction()) {
case ADD_BIN32S_BIN32S_BIN32S:
case ADD_BIN64S_BIN64S_BIN64S:
break;
@@ -2521,7 +2521,7 @@ ex_expr::exp_return_type ex_arith_sum_clause::pCodeGenerate(Space *space, UInt32
// not, choose the appropriate operand number and size for the
// increment operation.
//
- if (get_case_index() == ADD_COMPLEX)
+ if (getInstruction() == ADD_COMPLEX)
{
AML aml(PCIT::MATTR3, PCIT::MATTR3, PCIT::IBIN32S, PCIT::MBIGS,
PCIT::MBIGS, PCIT::IBIN32S);
@@ -2809,7 +2809,7 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
// conversions that are not handled with more fundamental PCode
// operations.
//
- switch(get_case_index()) {
+ switch(getInstruction()) {
case CONV_BPINTU_BPINTU:
case CONV_BIN16S_BIN16S: case CONV_BIN16S_BIN16U:
@@ -2907,7 +2907,7 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
dst->getLength(),
dst->getPrecision(),
dst->getScale(),
- get_case_index()
+ getInstruction()
))
return ex_clause::pCodeGenerate(space, f);
}
@@ -2922,7 +2922,7 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
case CONV_ASCII_BIN64S:
case CONV_ASCII_FLOAT32:
{
- if (get_case_index() == CONV_DECS_DECS)
+ if (getInstruction() == CONV_DECS_DECS)
{
// not enabled for NEO CA
return ex_clause::pCodeGenerate(space, f);
@@ -2936,12 +2936,12 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
return ex_clause::pCodeGenerate(space, f);
}
- if ((get_case_index() == CONV_ASCII_V_V) ||
- (get_case_index() == CONV_DATETIME_DATETIME) ||
- (get_case_index() == CONV_DECS_DECS))
+ if ((getInstruction() == CONV_ASCII_V_V) ||
+ (getInstruction() == CONV_DATETIME_DATETIME) ||
+ (getInstruction() == CONV_DECS_DECS))
{
- if ((get_case_index() == CONV_DATETIME_DATETIME) ||
- (get_case_index() == CONV_DECS_DECS))
+ if ((getInstruction() == CONV_DATETIME_DATETIME) ||
+ (getInstruction() == CONV_DECS_DECS))
{
if ((dst->getPrecision() != src->getPrecision()) ||
(dst->getScale() != src->getScale()))
@@ -2959,7 +2959,7 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
PCIID nullJmp = PCode::nullBranch(this, code, attrs);
// copy the value
- switch(get_case_index())
+ switch(getInstruction())
{
case CONV_ASCII_V_V:
case CONV_UNICODE_V_V:
@@ -3064,7 +3064,7 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
#ifdef NA_DEBUG_C_RUNTIME
// Allow 64 -> 64 with differing scale
//
- if(get_case_index() == CONV_BIN64S_BIN64S)
+ if(getInstruction() == CONV_BIN64S_BIN64S)
{
if(getenv("PCODE_NO_INT64_SCALE_CONV"))
{
@@ -3093,19 +3093,19 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
//
PCIID nullBranch = PCode::nullBranch(this, code, attrs);
- if((get_case_index() != CONV_BIGNUM_BIN64S) &&
- (get_case_index() != CONV_BIN64S_BIGNUM) &&
- (get_case_index() != CONV_BIN32S_BIGNUM) &&
- (get_case_index() != CONV_BIN16S_BIGNUM) &&
- (get_case_index() != CONV_BIGNUM_BIGNUM) &&
- (get_case_index() != CONV_SIMPLE_TO_COMPLEX) &&
- (get_case_index() != CONV_FLOAT64_FLOAT64) &&
- (get_case_index() != CONV_FLOAT32_FLOAT32) &&
- (get_case_index() != CONV_FLOAT32_FLOAT64) &&
- (get_case_index() != CONV_BIN16S_FLOAT64) &&
- (get_case_index() != CONV_BIN32S_FLOAT64) &&
- (get_case_index() != CONV_BIN64S_FLOAT64) &&
- (get_case_index() != CONV_BOOL_BOOL)) {
+ if((getInstruction() != CONV_BIGNUM_BIN64S) &&
+ (getInstruction() != CONV_BIN64S_BIGNUM) &&
+ (getInstruction() != CONV_BIN32S_BIGNUM) &&
+ (getInstruction() != CONV_BIN16S_BIGNUM) &&
+ (getInstruction() != CONV_BIGNUM_BIGNUM) &&
+ (getInstruction() != CONV_SIMPLE_TO_COMPLEX) &&
+ (getInstruction() != CONV_FLOAT64_FLOAT64) &&
+ (getInstruction() != CONV_FLOAT32_FLOAT32) &&
+ (getInstruction() != CONV_FLOAT32_FLOAT64) &&
+ (getInstruction() != CONV_BIN16S_FLOAT64) &&
+ (getInstruction() != CONV_BIN32S_FLOAT64) &&
+ (getInstruction() != CONV_BIN64S_FLOAT64) &&
+ (getInstruction() != CONV_BOOL_BOOL)) {
// Compute the high and low bounds of the source and destination
@@ -3130,7 +3130,7 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
if(srcLowBounds < dstLowBounds)
{
- if (get_case_index() == CONV_DECS_BIN64S)
+ if (getInstruction() == CONV_DECS_BIN64S)
return ex_clause::pCodeGenerate(space, f);
OL ol(srcAtp, srcAtpIndex, srcOffset, (Int64)dstLowBounds);
@@ -3139,7 +3139,7 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
}
if(srcHighBounds > dstHighBounds)
{
- if (get_case_index() == CONV_DECS_BIN64S)
+ if (getInstruction() == CONV_DECS_BIN64S)
return ex_clause::pCodeGenerate(space, f);
OL ol(srcAtp, srcAtpIndex, srcOffset, (Int64)dstHighBounds);
@@ -3151,7 +3151,7 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
#if (defined (_DEBUG) && !(defined(__EID)))
if(!getenv("NO_PCODE_FLOAT_RANGE"))
#endif
- if( get_case_index() == CONV_FLOAT64_FLOAT64 &&
+ if( getInstruction() == CONV_FLOAT64_FLOAT64 &&
!ex_expr::notValidateFloat64(f)) {
AML aml(PCIT::MFLT64);
OL ol(src->getAtp(), src->getAtpIndex(), (Int32)src->getOffset());
@@ -3161,7 +3161,7 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
// Do the conversion
//
- switch(get_case_index())
+ switch(getInstruction())
{
// For conversions that are simple moves, generate the byte move
// instruction. This includes unmatched signedness conversions such
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/exp/ExpPCodeOptimizations.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpPCodeOptimizations.cpp b/core/sql/exp/ExpPCodeOptimizations.cpp
index 2414855..cc58feb 100644
--- a/core/sql/exp/ExpPCodeOptimizations.cpp
+++ b/core/sql/exp/ExpPCodeOptimizations.cpp
@@ -4480,12 +4480,12 @@ NABoolean PCodeCfg::localCSE(INSTLIST** parent, PCodeBlock* tailBlock,
switch (clauseHead->getClassID()) {
case ex_clause::CONV_TYPE:
match =
- ((((ex_conv_clause*)clauseHead)->get_case_index() ==
- ((ex_conv_clause*)clauseTail)->get_case_index()) &&
+ ((((ex_conv_clause*)clauseHead)->getInstruction() ==
+ ((ex_conv_clause*)clauseTail)->getInstruction()) &&
(((ex_conv_clause*)clauseHead)->treatAllSpacesAsZero() ==
((ex_conv_clause*)clauseTail)->treatAllSpacesAsZero()));
if ( match ) {
- if ( ((ex_conv_clause*)clauseHead)->get_case_index() ==
+ if ( ((ex_conv_clause*)clauseHead)->getInstruction() ==
CONV_DATETIME_DATETIME )
{
Attributes *tgtH = ((ex_conv_clause*)clauseHead)->getOperand(0);
@@ -4506,8 +4506,8 @@ NABoolean PCodeCfg::localCSE(INSTLIST** parent, PCodeBlock* tailBlock,
case ex_clause::ARITH_TYPE:
match =
- (((ex_arith_clause*)clauseHead)->get_case_index() ==
- ((ex_arith_clause*)clauseTail)->get_case_index());
+ (((ex_arith_clause*)clauseHead)->getInstruction() ==
+ ((ex_arith_clause*)clauseTail)->getInstruction());
break;
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/exp/ExpPCodeOptsNativeExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpPCodeOptsNativeExpr.cpp b/core/sql/exp/ExpPCodeOptsNativeExpr.cpp
index cb7fa5a..7a8bce2 100755
--- a/core/sql/exp/ExpPCodeOptsNativeExpr.cpp
+++ b/core/sql/exp/ExpPCodeOptsNativeExpr.cpp
@@ -898,13 +898,13 @@ NABoolean PCodeCfg::canGenerateNativeExpr()
return FALSE;
}
- switch (((ex_comp_clause*)clause)->get_case_index()) {
- case ex_comp_clause::NE_DATETIME_DATETIME:
- case ex_comp_clause::EQ_DATETIME_DATETIME:
- case ex_comp_clause::LT_DATETIME_DATETIME:
- case ex_comp_clause::GT_DATETIME_DATETIME:
- case ex_comp_clause::LE_DATETIME_DATETIME:
- case ex_comp_clause::GE_DATETIME_DATETIME:
+ switch (((ex_comp_clause*)clause)->getInstruction()) {
+ case NE_DATETIME_DATETIME:
+ case EQ_DATETIME_DATETIME:
+ case LT_DATETIME_DATETIME:
+ case GT_DATETIME_DATETIME:
+ case LE_DATETIME_DATETIME:
+ case GE_DATETIME_DATETIME:
{
// Only support standard types
long dtCode =
@@ -1736,13 +1736,13 @@ NABoolean PCodeCfg::canGenerateNativeExpr()
if (clause->isSpecialNulls())
return FALSE;
- switch (((ex_comp_clause*)clause)->get_case_index()) {
- case ex_comp_clause::NE_DATETIME_DATETIME:
- case ex_comp_clause::EQ_DATETIME_DATETIME:
- case ex_comp_clause::LT_DATETIME_DATETIME:
- case ex_comp_clause::GT_DATETIME_DATETIME:
- case ex_comp_clause::LE_DATETIME_DATETIME:
- case ex_comp_clause::GE_DATETIME_DATETIME:
+ switch (((ex_comp_clause*)clause)->getInstruction()) {
+ case NE_DATETIME_DATETIME:
+ case EQ_DATETIME_DATETIME:
+ case LT_DATETIME_DATETIME:
+ case GT_DATETIME_DATETIME:
+ case LE_DATETIME_DATETIME:
+ case GE_DATETIME_DATETIME:
{
// Only support standard types
long dtCode =
@@ -8187,13 +8187,13 @@ void PCodeCfg::layoutNativeCode()
"trueLabel = %p, falseLabel = %p, nullLabel = %p\n",
trueLabel, falseLabel, nullLabel );
- switch (((ex_comp_clause*)clause)->get_case_index()) {
- case ex_comp_clause::NE_DATETIME_DATETIME:
- case ex_comp_clause::EQ_DATETIME_DATETIME:
- case ex_comp_clause::LT_DATETIME_DATETIME:
- case ex_comp_clause::GT_DATETIME_DATETIME:
- case ex_comp_clause::LE_DATETIME_DATETIME:
- case ex_comp_clause::GE_DATETIME_DATETIME:
+ switch (((ex_comp_clause*)clause)->getInstruction()) {
+ case NE_DATETIME_DATETIME:
+ case EQ_DATETIME_DATETIME:
+ case LT_DATETIME_DATETIME:
+ case GT_DATETIME_DATETIME:
+ case LE_DATETIME_DATETIME:
+ case GE_DATETIME_DATETIME:
{
DPT0( "VV9B210: ", VV_VD,
"CLAUSE_EVAL - COMP_TYPE - found DATETIME case index\n" );
@@ -8331,8 +8331,8 @@ void PCodeCfg::layoutNativeCode()
// comparison, the fall-through may be the "true" block,
// or it may be the "false" block - default is TRUE.
- switch (((ex_comp_clause*)clause)->get_case_index()) {
- case ex_comp_clause::NE_DATETIME_DATETIME:
+ switch (((ex_comp_clause*)clause)->getInstruction()) {
+ case NE_DATETIME_DATETIME:
//// resJitVal = jit_insn_ne(f, year1, year2);
resJitVal = jitGenCompare( Bldr, IntCompare_NE,
year1, year2,
@@ -8346,7 +8346,7 @@ void PCodeCfg::layoutNativeCode()
dumpTrueBlockFirst = FALSE;
break;
- case ex_comp_clause::EQ_DATETIME_DATETIME:
+ case EQ_DATETIME_DATETIME:
//// resJitVal = jit_insn_ne(f, year1, year2);
resJitVal = jitGenCompare( Bldr, IntCompare_EQ,
year1, year2,
@@ -8360,7 +8360,7 @@ void PCodeCfg::layoutNativeCode()
IR_insn_branch_if_not_zero( Bldr, resJitVal, &falseLabel );
break;
- case ex_comp_clause::LT_DATETIME_DATETIME:
+ case LT_DATETIME_DATETIME:
//// resJitVal = jit_insn_lt(f, year1, year2);
resJitVal = jitGenCompare( Bldr, IntCompare_ULT,
year1, year2,
@@ -8387,7 +8387,7 @@ void PCodeCfg::layoutNativeCode()
dumpTrueBlockFirst = FALSE;
break;
- case ex_comp_clause::GT_DATETIME_DATETIME:
+ case GT_DATETIME_DATETIME:
//// resJitVal = jit_insn_gt(f, year1, year2);
resJitVal = jitGenCompare( Bldr, IntCompare_UGT,
year1, year2,
@@ -8414,7 +8414,7 @@ void PCodeCfg::layoutNativeCode()
dumpTrueBlockFirst = FALSE;
break;
- case ex_comp_clause::LE_DATETIME_DATETIME:
+ case LE_DATETIME_DATETIME:
//// resJitVal = jit_insn_lt(f, year1, year2);
resJitVal = jitGenCompare( Bldr, IntCompare_ULT,
year1, year2,
@@ -8440,7 +8440,7 @@ void PCodeCfg::layoutNativeCode()
IR_insn_branch_if_not_zero( Bldr, resJitVal, &falseLabel );
break;
- case ex_comp_clause::GE_DATETIME_DATETIME:
+ case GE_DATETIME_DATETIME:
//// resJitVal = jit_insn_gt(f, year1, year2);
resJitVal = jitGenCompare( Bldr, IntCompare_UGT,
year1, year2,
@@ -11794,13 +11794,13 @@ void PCodeCfg::layoutNativeCode(Space* showplanSpace = NULL)
case ex_clause::COMP_TYPE:
{
- switch (((ex_comp_clause*)clause)->get_case_index()) {
- case ex_comp_clause::NE_DATETIME_DATETIME:
- case ex_comp_clause::EQ_DATETIME_DATETIME:
- case ex_comp_clause::LT_DATETIME_DATETIME:
- case ex_comp_clause::GT_DATETIME_DATETIME:
- case ex_comp_clause::LE_DATETIME_DATETIME:
- case ex_comp_clause::GE_DATETIME_DATETIME:
+ switch (((ex_comp_clause*)clause)->getInstruction()) {
+ case NE_DATETIME_DATETIME:
+ case EQ_DATETIME_DATETIME:
+ case LT_DATETIME_DATETIME:
+ case GT_DATETIME_DATETIME:
+ case LE_DATETIME_DATETIME:
+ case GE_DATETIME_DATETIME:
{
jit_value_t year1, year2;
@@ -11881,37 +11881,37 @@ void PCodeCfg::layoutNativeCode(Space* showplanSpace = NULL)
// comparison, the fall-through may be the "true" block,
// or it may be the "false" block - default is TRUE.
- switch (((ex_comp_clause*)clause)->get_case_index()) {
- case ex_comp_clause::NE_DATETIME_DATETIME:
+ switch (((ex_comp_clause*)clause)->getInstruction()) {
+ case NE_DATETIME_DATETIME:
resJitVal = jit_insn_ne(f, year1, year2);
jit_insn_branch_if(f, resJitVal, &trueLabel);
dumpTrueBlockFirst = FALSE;
break;
- case ex_comp_clause::EQ_DATETIME_DATETIME:
+ case EQ_DATETIME_DATETIME:
resJitVal = jit_insn_ne(f, year1, year2);
jit_insn_branch_if(f, resJitVal, &falseLabel);
break;
- case ex_comp_clause::LT_DATETIME_DATETIME:
+ case LT_DATETIME_DATETIME:
resJitVal = jit_insn_lt(f, year1, year2);
jit_insn_branch_if(f, resJitVal, &trueLabel);
resJitVal = jit_insn_gt(f, year1, year2);
jit_insn_branch_if(f, resJitVal, &falseLabel);
dumpTrueBlockFirst = FALSE;
break;
- case ex_comp_clause::GT_DATETIME_DATETIME:
+ case GT_DATETIME_DATETIME:
resJitVal = jit_insn_gt(f, year1, year2);
jit_insn_branch_if(f, resJitVal, &trueLabel);
resJitVal = jit_insn_lt(f, year1, year2);
jit_insn_branch_if(f, resJitVal, &falseLabel);
dumpTrueBlockFirst = FALSE;
break;
- case ex_comp_clause::LE_DATETIME_DATETIME:
+ case LE_DATETIME_DATETIME:
resJitVal = jit_insn_lt(f, year1, year2);
jit_insn_branch_if(f, resJitVal, &trueLabel);
resJitVal = jit_insn_gt(f, year1, year2);
jit_insn_branch_if(f, resJitVal, &falseLabel);
break;
- case ex_comp_clause::GE_DATETIME_DATETIME:
+ case GE_DATETIME_DATETIME:
resJitVal = jit_insn_gt(f, year1, year2);
jit_insn_branch_if(f, resJitVal, &trueLabel);
resJitVal = jit_insn_lt(f, year1, year2);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/exp/exp_arith.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_arith.cpp b/core/sql/exp/exp_arith.cpp
index b7f2b6f..e9155db 100644
--- a/core/sql/exp/exp_arith.cpp
+++ b/core/sql/exp/exp_arith.cpp
@@ -675,7 +675,7 @@ ex_expr::exp_return_type ex_arith_clause::eval(char *op_data[],
ComDiagsArea** diagsArea)
{
- switch (get_case_index())
+ switch (getInstruction())
{
/* ADD operation */
case ADD_BIN16S_BIN16S_BIN16S:
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/exp/exp_clause.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_clause.cpp b/core/sql/exp/exp_clause.cpp
index 164268c..5fd6490 100644
--- a/core/sql/exp/exp_clause.cpp
+++ b/core/sql/exp/exp_clause.cpp
@@ -174,6 +174,8 @@ ex_clause::ex_clause(clause_type type,
pciLink_ = NULL;
nextClause_ = NULL;
flags_ = 0;
+ // instruction_ = -1;
+ instrArrayIndex_ = -1;
str_pad(fillers_, sizeof(fillers_), '\0');
@@ -1497,9 +1499,11 @@ void ex_clause::displayContents(Space * space, const char * displayStr,
}
void ex_clause::displayContents(Space * space, const char * displayStr,
- Int32 clauseNum, char * constsArea, UInt32 clauseFlags)
+ Int32 clauseNum, char * constsArea,
+ UInt32 clauseFlags,
+ Int16 instruction,
+ const char * instrText)
{
-#ifndef __EID
char buf[100];
if (displayStr)
{
@@ -1530,7 +1534,17 @@ void ex_clause::displayContents(Space * space, const char * displayStr,
str_sprintf(buf, " PCODE = supported ");
space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));
}
-#endif
+
+ if (instruction >= 0)
+ {
+ if (instrText)
+ str_sprintf(buf, " instruction: %s(%d), instrArrayIndex_: %d",
+ instrText, instruction, instrArrayIndex_);
+ else
+ str_sprintf(buf, " instruction: UNKNOWN(%d), instrArrayIndex_: %d",
+ instruction, instrArrayIndex_);
+ space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));
+ }
if (numOperands_ == 0)
return;
@@ -1580,7 +1594,7 @@ ex_arith_clause::ex_arith_clause(OperatorTypeEnum oper_type,
setDivToDownscale(TRUE);
if (attr)
- set_case_index();
+ setInstruction();
}
ex_arith_clause::ex_arith_clause(clause_type type,
@@ -1592,7 +1606,7 @@ ex_arith_clause::ex_arith_clause(clause_type type,
flags_(0)
{
- set_case_index();
+ setInstruction();
}
ex_arith_sum_clause::ex_arith_sum_clause(OperatorTypeEnum oper_type,
@@ -1622,7 +1636,7 @@ ex_comp_clause::ex_comp_clause(OperatorTypeEnum oper_type,
flags_(0)
{
if(flags) setSpecialNulls();
- set_case_index();
+ setInstruction();
}
///////////////////////////////////////////////////////////
@@ -1636,7 +1650,6 @@ ex_conv_clause::ex_conv_clause(OperatorTypeEnum oper_type,
NABoolean noStringTruncWarnings,
NABoolean convertToNullWhenErrorFlag)
: ex_clause (ex_clause::CONV_TYPE, oper_type, num_operands, attr, space),
- case_index(CONV_UNKNOWN),
lastVOAoffset_(0),
lastVcIndicatorLength_(0),
lastNullIndicatorLength_(0),
@@ -1660,7 +1673,7 @@ ex_conv_clause::ex_conv_clause(OperatorTypeEnum oper_type,
if (convertToNullWhenErrorFlag)
flags_ |= CONV_TO_NULL_WHEN_ERROR;
- set_case_index();
+ setInstruction();
}
#pragma warn(1506) // warning elimination
@@ -1804,7 +1817,7 @@ void ex_pivot_group_clause::displayContents(Space * space, const char * /*displa
void ex_arith_clause::displayContents(Space * space, const char * /*displayStr*/, Int32 clauseNum, char * constsArea)
{
- set_case_index();
+ setInstruction();
#ifndef __EID
char buf[100];
@@ -1817,17 +1830,19 @@ void ex_arith_clause::displayContents(Space * space, const char * /*displayStr*/
(short)arithRoundingMode_, (getDivToDownscale() ? 1 : 0));
space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));
}
+
#endif
- ex_clause::displayContents(space, (const char *)NULL, clauseNum, constsArea);
- // cout << "Case Index = " << get_case_index() << endl;
+ ex_clause::displayContents(space, (const char *)NULL, clauseNum, constsArea, 0,
+ ex_arith_clause::getInstruction(getInstrArrayIndex()),
+ ex_arith_clause::getInstructionStr(getInstrArrayIndex()));
}
void ex_arith_sum_clause::displayContents(Space * space,
const char * /*displayStr*/,
Int32 clauseNum, char * constsArea)
{
- set_case_index();
+ setInstruction();
ex_clause::displayContents(space, "ex_arith_sum_clause", clauseNum, constsArea);
}
@@ -1835,7 +1850,7 @@ void ex_arith_count_clause::displayContents(Space * space,
const char * /*displayStr*/,
Int32 clauseNum, char * constsArea)
{
- set_case_index();
+ setInstruction();
ex_clause::displayContents(space, "ex_arith_count_clause", clauseNum, constsArea);
}
@@ -1905,17 +1920,21 @@ void ex_branch_clause::displayContents(Space * space, const char * /*displayStr*
void ex_comp_clause::displayContents(Space * space, const char * /*displayStr*/, Int32 clauseNum, char * constsArea)
{
- set_case_index();
- ex_clause::displayContents(space, "ex_comp_clause", clauseNum, constsArea, flags_);
- // cout << "Case Index = " << get_case_index() << endl;
+ setInstruction();
+ ex_clause::displayContents(space, "ex_comp_clause", clauseNum, constsArea,
+ flags_,
+ ex_comp_clause::getInstruction(getInstrArrayIndex()),
+ ex_comp_clause::getInstructionStr(getInstrArrayIndex()));
+
}
void ex_conv_clause::displayContents(Space * space, const char * /*displayStr*/, Int32 clauseNum, char * constsArea)
{
- set_case_index();
+ setInstruction();
ex_clause::displayContents(space, "ex_conv_clause", clauseNum, constsArea,
- flags_);
- // cout << "Case Index = " << get_case_index() << endl;
+ flags_,
+ ex_conv_clause::getInstruction(getInstrArrayIndex()),
+ ex_conv_clause::getInstructionStr(getInstrArrayIndex()));
}
void ex_function_clause::displayContents(Space * space, const char * /*displayStr*/, Int32 clauseNum, char * constsArea)
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/exp/exp_clause.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_clause.h b/core/sql/exp/exp_clause.h
index 42eed3b..83c7124 100644
--- a/core/sql/exp/exp_clause.h
+++ b/core/sql/exp/exp_clause.h
@@ -444,9 +444,12 @@ public:
//
NA_EIDPROC virtual void displayContents(Space * space, const char * displayStr,
Int32 clauseNum, char * constsArea);
-
- NA_EIDPROC void displayContents(Space * space, const char * displayStr,
- Int32 clauseNum, char * constsArea, UInt32 clauseFlags);
+
+ NA_EIDPROC void displayContents(Space * space, const char * displayStr,
+ Int32 clauseNum, char * constsArea,
+ UInt32 clauseFlags,
+ Int16 instruction = -1,
+ const char * instrText = NULL);
NA_EIDPROC static void clearVOA(Attributes *attr, atp_struct *atp)
{
@@ -526,6 +529,9 @@ public:
globals_ = glob;
}
+ Int16 getInstrArrayIndex() { return instrArrayIndex_; }
+ void setInstrArrayIndex(Int16 index) { instrArrayIndex_ = index; }
+
protected:
NA_EIDPROC ex_globals * getExeGlobals()
{
@@ -557,7 +563,11 @@ private:
Int16 /*OperatorTypeEnum*/ operType_; // 34-35
Int16 /*clause_type*/ clauseType_; // 36-37
- Int16 filler1_; // 38-39
+ // index into static clause array struct containing details about
+ // this clause (datatypes, operation, etc) if derived clause has
+ // this array defined.
+ // See derived clauses for details.
+ Int16 instrArrayIndex_; // 48-49
// this field is set at runtime when this clause is fixed up.
// It is used in eval for cases where an expression needs to access
@@ -571,7 +581,7 @@ private:
// When a new member is added, size of this filler should be reduced so
// that the size of the object remains the same (and is modulo 8).
// ---------------------------------------------------------------------
- char fillers_[16]; // 48-63
+ char fillers_[16]; // 52-63
};
#pragma warn(1506) // warning elimination
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/exp/exp_clause_derived.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_clause_derived.h b/core/sql/exp/exp_clause_derived.h
index ff6c2b2..5d9291d 100644
--- a/core/sql/exp/exp_clause_derived.h
+++ b/core/sql/exp/exp_clause_derived.h
@@ -1,4 +1,4 @@
-/**********************************************************************
+/************************************************************************
// @@@ START COPYRIGHT @@@
//
// Licensed to the Apache Software Foundation (ASF) under one
@@ -48,6 +48,8 @@
#pragma warning ( disable : 4251 )
+#define instrAndText(a) a, #a
+
/////////////////////////////////////////
// Class ex_aggregate_clause //
/////////////////////////////////////////
@@ -127,7 +129,7 @@ public:
// Display
//
NA_EIDPROC void displayContents(Space * space, const char * displayStr,
- Int32 clauseNum, char * constsArea);
+ Int32 clauseNum, char * constsArea);
// ---------------------------------------------------------------------
// Redefinition of methods inherited from NAVersionedObject.
@@ -185,7 +187,7 @@ public:
// Display
//
NA_EIDPROC void displayContents(Space * space, const char * displayStr,
- Int32 clauseNum, char * constsArea);
+ Int32 clauseNum, char * constsArea);
// ---------------------------------------------------------------------
// Redefinition of methods inherited from NAVersionedObject.
@@ -352,92 +354,101 @@ private:
/////////////////////////////////////////
// Class arith_clause //
/////////////////////////////////////////
-struct ex_arith_struct; // forward reference
-
-class SQLEXP_LIB_FUNC ex_arith_clause : public ex_clause {
-public:
- // (these codes must remain invariant across future versions)
- enum arith_case_index {
- ADD_BIN16S_BIN16S_BIN16S =0,
- ADD_BIN16S_BIN16S_BIN32S =1,
- ADD_BIN16S_BIN32S_BIN32S =2,
- ADD_BIN32S_BIN16S_BIN32S =3,
- ADD_BIN32S_BIN32S_BIN32S =4,
- ADD_BIN64S_BIN64S_BIN64S =5,
- ADD_BIN32S_BIN64S_BIN64S =6,
- ADD_BIN64S_BIN32S_BIN64S =7,
- ADD_BIN16U_BIN16U_BIN16U =8,
- ADD_BIN16U_BIN16U_BIN32U =9,
- ADD_BIN16U_BIN32U_BIN32U =10,
- ADD_BIN32U_BIN16U_BIN32U =11,
- ADD_BIN32U_BIN32U_BIN32U =12,
- ADD_BPINTU_BIN64S_BIN64S =13,
- ADD_BIN64S_BPINTU_BIN64S =14,
- ADD_BIN32U_BIN64S_BIN64S =15,
- ADD_BIN64S_BIN32U_BIN64S =16,
-
- ADD_FLOAT32_FLOAT32_FLOAT32 =17,
- ADD_FLOAT64_FLOAT64_FLOAT64 =18,
- ADD_DATETIME_INTERVAL_DATETIME=19,
- ADD_INTERVAL_DATETIME_DATETIME=20,
+// (these codes must remain invariant across future versions)
+enum ArithInstruction {
+ ADD_BIN16S_BIN16S_BIN16S =0,
+ ADD_BIN16S_BIN16S_BIN32S =1,
+ ADD_BIN16S_BIN32S_BIN32S =2,
+ ADD_BIN32S_BIN16S_BIN32S =3,
+ ADD_BIN32S_BIN32S_BIN32S =4,
+ ADD_BIN64S_BIN64S_BIN64S =5,
+ ADD_BIN32S_BIN64S_BIN64S =6,
+ ADD_BIN64S_BIN32S_BIN64S =7,
+ ADD_BIN16U_BIN16U_BIN16U =8,
+ ADD_BIN16U_BIN16U_BIN32U =9,
+ ADD_BIN16U_BIN32U_BIN32U =10,
+ ADD_BIN32U_BIN16U_BIN32U =11,
+ ADD_BIN32U_BIN32U_BIN32U =12,
+ ADD_BPINTU_BIN64S_BIN64S =13,
+ ADD_BIN64S_BPINTU_BIN64S =14,
+ ADD_BIN32U_BIN64S_BIN64S =15,
+ ADD_BIN64S_BIN32U_BIN64S =16,
+
+ ADD_FLOAT32_FLOAT32_FLOAT32 =17,
+ ADD_FLOAT64_FLOAT64_FLOAT64 =18,
+ ADD_DATETIME_INTERVAL_DATETIME=19,
+ ADD_INTERVAL_DATETIME_DATETIME=20,
- SUB_BIN16S_BIN16S_BIN16S =21,
- SUB_BIN16S_BIN16S_BIN32S =22,
- SUB_BIN16S_BIN32S_BIN32S =23,
- SUB_BIN32S_BIN16S_BIN32S =24,
- SUB_BIN32S_BIN32S_BIN32S =25,
- SUB_BIN64S_BIN64S_BIN64S =26,
- SUB_BIN16U_BIN16U_BIN16U =27,
- SUB_BIN16U_BIN16U_BIN32U =28,
- SUB_BIN16U_BIN32U_BIN32U =29,
- SUB_BIN32U_BIN16U_BIN32U =30,
- SUB_BIN32U_BIN32U_BIN32U =31,
- SUB_FLOAT32_FLOAT32_FLOAT32 =32,
- SUB_FLOAT64_FLOAT64_FLOAT64 =33,
- SUB_DATETIME_INTERVAL_DATETIME=34,
- SUB_DATETIME_DATETIME_INTERVAL=35,
+ SUB_BIN16S_BIN16S_BIN16S =21,
+ SUB_BIN16S_BIN16S_BIN32S =22,
+ SUB_BIN16S_BIN32S_BIN32S =23,
+ SUB_BIN32S_BIN16S_BIN32S =24,
+ SUB_BIN32S_BIN32S_BIN32S =25,
+ SUB_BIN64S_BIN64S_BIN64S =26,
+ SUB_BIN16U_BIN16U_BIN16U =27,
+ SUB_BIN16U_BIN16U_BIN32U =28,
+ SUB_BIN16U_BIN32U_BIN32U =29,
+ SUB_BIN32U_BIN16U_BIN32U =30,
+ SUB_BIN32U_BIN32U_BIN32U =31,
+ SUB_FLOAT32_FLOAT32_FLOAT32 =32,
+ SUB_FLOAT64_FLOAT64_FLOAT64 =33,
+ SUB_DATETIME_INTERVAL_DATETIME=34,
+ SUB_DATETIME_DATETIME_INTERVAL=35,
- MUL_BIN16S_BIN16S_BIN16S =36,
- MUL_BIN16S_BIN16S_BIN32S =37,
- MUL_BIN16S_BIN32S_BIN32S =38,
- MUL_BIN32S_BIN16S_BIN32S =39,
- MUL_BIN32S_BIN32S_BIN32S =40,
- MUL_BIN64S_BIN64S_BIN64S =41,
- MUL_BIN16U_BIN16U_BIN16U =42,
- MUL_BIN16U_BIN16U_BIN32U =43,
- MUL_BIN16U_BIN32U_BIN32U =44,
- MUL_BIN32U_BIN16U_BIN32U =45,
- MUL_BIN32U_BIN32U_BIN32U =46,
- MUL_FLOAT32_FLOAT32_FLOAT32 =47,
- MUL_FLOAT64_FLOAT64_FLOAT64 =48,
+ MUL_BIN16S_BIN16S_BIN16S =36,
+ MUL_BIN16S_BIN16S_BIN32S =37,
+ MUL_BIN16S_BIN32S_BIN32S =38,
+ MUL_BIN32S_BIN16S_BIN32S =39,
+ MUL_BIN32S_BIN32S_BIN32S =40,
+ MUL_BIN64S_BIN64S_BIN64S =41,
+ MUL_BIN16U_BIN16U_BIN16U =42,
+ MUL_BIN16U_BIN16U_BIN32U =43,
+ MUL_BIN16U_BIN32U_BIN32U =44,
+ MUL_BIN32U_BIN16U_BIN32U =45,
+ MUL_BIN32U_BIN32U_BIN32U =46,
+ MUL_FLOAT32_FLOAT32_FLOAT32 =47,
+ MUL_FLOAT64_FLOAT64_FLOAT64 =48,
- DIV_BIN16S_BIN16S_BIN16S =49,
- DIV_BIN16S_BIN16S_BIN32S =50,
- DIV_BIN16S_BIN32S_BIN32S =51,
- DIV_BIN32S_BIN16S_BIN32S =52,
- DIV_BIN32S_BIN32S_BIN32S =53,
- DIV_BIN64S_BIN64S_BIN64S =54,
- DIV_BIN16U_BIN16U_BIN16U =55,
- DIV_BIN16U_BIN16U_BIN32U =56,
- DIV_BIN16U_BIN32U_BIN32U =57,
- DIV_BIN32U_BIN16U_BIN32U =58,
- DIV_BIN32U_BIN32U_BIN32U =59,
- DIV_FLOAT64_FLOAT64_FLOAT64 =60,
+ DIV_BIN16S_BIN16S_BIN16S =49,
+ DIV_BIN16S_BIN16S_BIN32S =50,
+ DIV_BIN16S_BIN32S_BIN32S =51,
+ DIV_BIN32S_BIN16S_BIN32S =52,
+ DIV_BIN32S_BIN32S_BIN32S =53,
+ DIV_BIN64S_BIN64S_BIN64S =54,
+ DIV_BIN16U_BIN16U_BIN16U =55,
+ DIV_BIN16U_BIN16U_BIN32U =56,
+ DIV_BIN16U_BIN32U_BIN32U =57,
+ DIV_BIN32U_BIN16U_BIN32U =58,
+ DIV_BIN32U_BIN32U_BIN32U =59,
+ DIV_FLOAT64_FLOAT64_FLOAT64 =60,
- ADD_COMPLEX =61,
- SUB_COMPLEX =62,
- MUL_COMPLEX =63,
- DIV_COMPLEX =64,
- ARITH_NOT_SUPPORTED =65,
- MUL_BIN16S_BIN32S_BIN64S =66,
- MUL_BIN32S_BIN16S_BIN64S =67,
- MUL_BIN32S_BIN32S_BIN64S =68,
-
- DIV_BIN64S_BIN64S_BIN64S_ROUND=69,
-
- NEGATE_BOOLEAN =70
- };
+ ADD_COMPLEX =61,
+ SUB_COMPLEX =62,
+ MUL_COMPLEX =63,
+ DIV_COMPLEX =64,
+ ARITH_NOT_SUPPORTED =65,
+ MUL_BIN16S_BIN32S_BIN64S =66,
+ MUL_BIN32S_BIN16S_BIN64S =67,
+ MUL_BIN32S_BIN32S_BIN64S =68,
+
+ DIV_BIN64S_BIN64S_BIN64S_ROUND=69,
+
+ NEGATE_BOOLEAN =70
+};
+
+class SQLEXP_LIB_FUNC ex_arith_clause : public ex_clause {
+
+ typedef struct {
+ OperatorTypeEnum op;
+ short type_op1; // left operand
+ short type_op2; // right operand
+ short type_op0; // result
+ ArithInstruction instruction;
+ const char * instrStr;
+ } ArithInstrStruct;
+
+public:
// Construction
//
@@ -455,20 +466,31 @@ public:
// Accessors
//
- NA_EIDPROC inline arith_case_index get_case_index()
+ ArithInstruction getInstruction()
{
- return (arith_case_index) case_index;
+ if (getInstrArrayIndex() >= 0)
+ return getInstruction(getInstrArrayIndex());
+ else
+ return ARITH_NOT_SUPPORTED;
};
- NA_EIDPROC void set_case_index();
- NA_EIDPROC void set_case_index(OperatorTypeEnum op,
- Attributes * attr1,
- Attributes * attr2,
- Attributes * result);
+ void setInstruction();
+ void setInstruction(OperatorTypeEnum op,
+ Attributes * attr1,
+ Attributes * attr2,
+ Attributes * result);
+
+ short isArithSupported(OperatorTypeEnum op,
+ Attributes * attr1,
+ Attributes * attr2,
+ Attributes * result);
- NA_EIDPROC short isArithSupported(OperatorTypeEnum op,
- Attributes * attr1,
- Attributes * attr2,
- Attributes * result);
+ static const ArithInstrStruct arithInstrInfo[];
+ static const char * getInstructionStr(Lng32 index)
+ { return arithInstrInfo[index].instrStr;}
+ static const ArithInstruction getInstruction(Lng32 index)
+ { return arithInstrInfo[index].instruction;}
+
+ Lng32 findIndexIntoInstrArray(ArithInstruction ci);
// Null Semantics
//
@@ -533,7 +555,7 @@ private:
DIV_TO_DOWNSCALE = 0x01
};
- Int32 case_index; // 00-03
+ char filler[4]; // 00-03
char arithRoundingMode_; // 04-04
char flags_; // 05-05
@@ -545,12 +567,12 @@ private:
// ---------------------------------------------------------------------
char fillers_[18]; // 06-23
- NA_EIDPROC const ex_arith_struct * getMatchingRow(OperatorTypeEnum op,
+ NA_EIDPROC const ArithInstrStruct * getMatchingRow(OperatorTypeEnum op,
short datatype1,
short datatype2,
short resulttype);
- NA_EIDPROC const arith_case_index computeCaseIndex(OperatorTypeEnum op,
+ NA_EIDPROC const ArithInstruction computeCaseIndex(OperatorTypeEnum op,
Attributes * attr1,
Attributes * attr2,
Attributes * result);
@@ -662,18 +684,6 @@ private:
};
-// private helper struct for class ex_arith_clause (can not make it
-// a struct inside the class because of c89 limitations with nested classes)
-struct ex_arith_struct
-{
- OperatorTypeEnum op;
- short type_op1; // left operand
- short type_op2; // right operand
- short type_op0; // result
- ex_arith_clause::arith_case_index index;
-};
-
-
/////////////////////////////////////////
// Class bool_clause //
/////////////////////////////////////////
@@ -917,230 +927,238 @@ private:
// return saved_next_clause;
//};
+#define myDefine(a) #a
+
/////////////////////////////////////////
// Class comp_clause
/////////////////////////////////////////
-struct ex_comp_struct; // forward reference
-
-class SQLEXP_LIB_FUNC ex_comp_clause : public ex_clause {
-
-public:
-
- // (these codes must remain invariant across future versions)
- enum comp_case_index {
- EQ_BIN16S_BIN16S =0,
- EQ_BIN16S_BIN32S =1,
- EQ_BIN16S_BIN16U =2,
- EQ_BIN16S_BIN32U =3,
- NE_BIN16S_BIN16S =4,
- NE_BIN16S_BIN32S =5,
- NE_BIN16S_BIN16U =6,
- NE_BIN16S_BIN32U =7,
- LT_BIN16S_BIN16S =8,
- LT_BIN16S_BIN32S =9,
- LT_BIN16S_BIN16U =10,
- LT_BIN16S_BIN32U =11,
- LE_BIN16S_BIN16S =12,
- LE_BIN16S_BIN32S =13,
- LE_BIN16S_BIN16U =14,
- LE_BIN16S_BIN32U =15,
- GT_BIN16S_BIN16S =16,
- GT_BIN16S_BIN32S =17,
- GT_BIN16S_BIN16U =18,
- GT_BIN16S_BIN32U =19,
- GE_BIN16S_BIN16S =20,
- GE_BIN16S_BIN32S =21,
- GE_BIN16S_BIN16U =22,
- GE_BIN16S_BIN32U =23,
+// (these codes must remain invariant across future versions)
+enum CompInstruction {
+ EQ_BIN16S_BIN16S =0,
+ EQ_BIN16S_BIN32S =1,
+ EQ_BIN16S_BIN16U =2,
+ EQ_BIN16S_BIN32U =3,
+ NE_BIN16S_BIN16S =4,
+ NE_BIN16S_BIN32S =5,
+ NE_BIN16S_BIN16U =6,
+ NE_BIN16S_BIN32U =7,
+ LT_BIN16S_BIN16S =8,
+ LT_BIN16S_BIN32S =9,
+ LT_BIN16S_BIN16U =10,
+ LT_BIN16S_BIN32U =11,
+ LE_BIN16S_BIN16S =12,
+ LE_BIN16S_BIN32S =13,
+ LE_BIN16S_BIN16U =14,
+ LE_BIN16S_BIN32U =15,
+ GT_BIN16S_BIN16S =16,
+ GT_BIN16S_BIN32S =17,
+ GT_BIN16S_BIN16U =18,
+ GT_BIN16S_BIN32U =19,
+ GE_BIN16S_BIN16S =20,
+ GE_BIN16S_BIN32S =21,
+ GE_BIN16S_BIN16U =22,
+ GE_BIN16S_BIN32U =23,
- EQ_BIN32S_BIN16S =24,
- EQ_BIN32S_BIN32S =25,
- EQ_BIN32S_BIN16U =26,
- EQ_BIN32S_BIN32U =27,
- NE_BIN32S_BIN16S =28,
- NE_BIN32S_BIN32S =29,
- NE_BIN32S_BIN16U =30,
- NE_BIN32S_BIN32U =31,
- LT_BIN32S_BIN16S =32,
- LT_BIN32S_BIN32S =33,
- LT_BIN32S_BIN16U =34,
- LT_BIN32S_BIN32U =35,
- LE_BIN32S_BIN16S =36,
- LE_BIN32S_BIN32S =37,
- LE_BIN32S_BIN16U =38,
- LE_BIN32S_BIN32U =39,
- GT_BIN32S_BIN16S =40,
- GT_BIN32S_BIN32S =41,
- GT_BIN32S_BIN16U =42,
- GT_BIN32S_BIN32U =43,
- GE_BIN32S_BIN16S =44,
- GE_BIN32S_BIN32S =45,
- GE_BIN32S_BIN16U =46,
- GE_BIN32S_BIN32U =47,
+ EQ_BIN32S_BIN16S =24,
+ EQ_BIN32S_BIN32S =25,
+ EQ_BIN32S_BIN16U =26,
+ EQ_BIN32S_BIN32U =27,
+ NE_BIN32S_BIN16S =28,
+ NE_BIN32S_BIN32S =29,
+ NE_BIN32S_BIN16U =30,
+ NE_BIN32S_BIN32U =31,
+ LT_BIN32S_BIN16S =32,
+ LT_BIN32S_BIN32S =33,
+ LT_BIN32S_BIN16U =34,
+ LT_BIN32S_BIN32U =35,
+ LE_BIN32S_BIN16S =36,
+ LE_BIN32S_BIN32S =37,
+ LE_BIN32S_BIN16U =38,
+ LE_BIN32S_BIN32U =39,
+ GT_BIN32S_BIN16S =40,
+ GT_BIN32S_BIN32S =41,
+ GT_BIN32S_BIN16U =42,
+ GT_BIN32S_BIN32U =43,
+ GE_BIN32S_BIN16S =44,
+ GE_BIN32S_BIN32S =45,
+ GE_BIN32S_BIN16U =46,
+ GE_BIN32S_BIN32U =47,
- EQ_BIN64S_BIN64S =48,
- NE_BIN64S_BIN64S =49,
- LT_BIN64S_BIN64S =50,
- LE_BIN64S_BIN64S =51,
- GT_BIN64S_BIN64S =52,
- GE_BIN64S_BIN64S =53,
+ EQ_BIN64S_BIN64S =48,
+ NE_BIN64S_BIN64S =49,
+ LT_BIN64S_BIN64S =50,
+ LE_BIN64S_BIN64S =51,
+ GT_BIN64S_BIN64S =52,
+ GE_BIN64S_BIN64S =53,
- EQ_BIN16U_BIN16S =54,
- EQ_BIN16U_BIN32S =55,
- EQ_BIN16U_BIN16U =56,
- EQ_BIN16U_BIN32U =57,
- NE_BIN16U_BIN16S =58,
- NE_BIN16U_BIN32S =59,
- NE_BIN16U_BIN16U =60,
- NE_BIN16U_BIN32U =61,
- LT_BIN16U_BIN16S =62,
- LT_BIN16U_BIN32S =63,
- LT_BIN16U_BIN16U =64,
- LT_BIN16U_BIN32U =65,
- LE_BIN16U_BIN16S =66,
- LE_BIN16U_BIN32S =67,
- LE_BIN16U_BIN16U =68,
- LE_BIN16U_BIN32U =69,
- GT_BIN16U_BIN16S =70,
- GT_BIN16U_BIN32S =71,
- GT_BIN16U_BIN16U =72,
- GT_BIN16U_BIN32U =73,
- GE_BIN16U_BIN16S =74,
- GE_BIN16U_BIN32S =75,
- GE_BIN16U_BIN16U =76,
- GE_BIN16U_BIN32U =77,
+ EQ_BIN16U_BIN16S =54,
+ EQ_BIN16U_BIN32S =55,
+ EQ_BIN16U_BIN16U =56,
+ EQ_BIN16U_BIN32U =57,
+ NE_BIN16U_BIN16S =58,
+ NE_BIN16U_BIN32S =59,
+ NE_BIN16U_BIN16U =60,
+ NE_BIN16U_BIN32U =61,
+ LT_BIN16U_BIN16S =62,
+ LT_BIN16U_BIN32S =63,
+ LT_BIN16U_BIN16U =64,
+ LT_BIN16U_BIN32U =65,
+ LE_BIN16U_BIN16S =66,
+ LE_BIN16U_BIN32S =67,
+ LE_BIN16U_BIN16U =68,
+ LE_BIN16U_BIN32U =69,
+ GT_BIN16U_BIN16S =70,
+ GT_BIN16U_BIN32S =71,
+ GT_BIN16U_BIN16U =72,
+ GT_BIN16U_BIN32U =73,
+ GE_BIN16U_BIN16S =74,
+ GE_BIN16U_BIN32S =75,
+ GE_BIN16U_BIN16U =76,
+ GE_BIN16U_BIN32U =77,
- EQ_BIN32U_BIN16S =78,
- EQ_BIN32U_BIN32S =79,
- EQ_BIN32U_BIN16U =80,
- EQ_BIN32U_BIN32U =81,
- NE_BIN32U_BIN16S =82,
- NE_BIN32U_BIN32S =83,
- NE_BIN32U_BIN16U =84,
- NE_BIN32U_BIN32U =85,
- LT_BIN32U_BIN16S =86,
- LT_BIN32U_BIN32S =87,
- LT_BIN32U_BIN16U =88,
- LT_BIN32U_BIN32U =89,
- LE_BIN32U_BIN16S =90,
- LE_BIN32U_BIN32S =91,
- LE_BIN32U_BIN16U =92,
- LE_BIN32U_BIN32U =93,
- GT_BIN32U_BIN16S =94,
- GT_BIN32U_BIN32S =95,
- GT_BIN32U_BIN16U =96,
- GT_BIN32U_BIN32U =97,
- GE_BIN32U_BIN16S =98,
- GE_BIN32U_BIN32S =99,
- GE_BIN32U_BIN16U =100,
- GE_BIN32U_BIN32U =101,
+ EQ_BIN32U_BIN16S =78,
+ EQ_BIN32U_BIN32S =79,
+ EQ_BIN32U_BIN16U =80,
+ EQ_BIN32U_BIN32U =81,
+ NE_BIN32U_BIN16S =82,
+ NE_BIN32U_BIN32S =83,
+ NE_BIN32U_BIN16U =84,
+ NE_BIN32U_BIN32U =85,
+ LT_BIN32U_BIN16S =86,
+ LT_BIN32U_BIN32S =87,
+ LT_BIN32U_BIN16U =88,
+ LT_BIN32U_BIN32U =89,
+ LE_BIN32U_BIN16S =90,
+ LE_BIN32U_BIN32S =91,
+ LE_BIN32U_BIN16U =92,
+ LE_BIN32U_BIN32U =93,
+ GT_BIN32U_BIN16S =94,
+ GT_BIN32U_BIN32S =95,
+ GT_BIN32U_BIN16U =96,
+ GT_BIN32U_BIN32U =97,
+ GE_BIN32U_BIN16S =98,
+ GE_BIN32U_BIN32S =99,
+ GE_BIN32U_BIN16U =100,
+ GE_BIN32U_BIN32U =101,
- EQ_DECU_DECU =102,
- NE_DECU_DECU =103,
- LT_DECU_DECU =104,
- LE_DECU_DECU =105,
- GT_DECU_DECU =106,
- GE_DECU_DECU =107,
+ EQ_DECU_DECU =102,
+ NE_DECU_DECU =103,
+ LT_DECU_DECU =104,
+ LE_DECU_DECU =105,
+ GT_DECU_DECU =106,
+ GE_DECU_DECU =107,
- EQ_DECS_DECS =108,
- NE_DECS_DECS =109,
- LT_DECS_DECS =110,
- LE_DECS_DECS =111,
- GT_DECS_DECS =112,
- GE_DECS_DECS =113,
+ EQ_DECS_DECS =108,
+ NE_DECS_DECS =109,
+ LT_DECS_DECS =110,
+ LE_DECS_DECS =111,
+ GT_DECS_DECS =112,
+ GE_DECS_DECS =113,
- EQ_FLOAT32_FLOAT32 =114,
- NE_FLOAT32_FLOAT32 =115,
- LT_FLOAT32_FLOAT32 =116,
- LE_FLOAT32_FLOAT32 =117,
- GT_FLOAT32_FLOAT32 =118,
- GE_FLOAT32_FLOAT32 =119,
+ EQ_FLOAT32_FLOAT32 =114,
+ NE_FLOAT32_FLOAT32 =115,
+ LT_FLOAT32_FLOAT32 =116,
+ LE_FLOAT32_FLOAT32 =117,
+ GT_FLOAT32_FLOAT32 =118,
+ GE_FLOAT32_FLOAT32 =119,
- EQ_FLOAT64_FLOAT64 =120,
- NE_FLOAT64_FLOAT64 =121,
- LT_FLOAT64_FLOAT64 =122,
- LE_FLOAT64_FLOAT64 =123,
- GT_FLOAT64_FLOAT64 =124,
- GE_FLOAT64_FLOAT64 =125,
+ EQ_FLOAT64_FLOAT64 =120,
+ NE_FLOAT64_FLOAT64 =121,
+ LT_FLOAT64_FLOAT64 =122,
+ LE_FLOAT64_FLOAT64 =123,
+ GT_FLOAT64_FLOAT64 =124,
+ GE_FLOAT64_FLOAT64 =125,
- EQ_DATETIME_DATETIME=126,
- NE_DATETIME_DATETIME=127,
- LT_DATETIME_DATETIME=128,
- LE_DATETIME_DATETIME=129,
- GT_DATETIME_DATETIME=130,
- GE_DATETIME_DATETIME=131,
+ EQ_DATETIME_DATETIME=126,
+ NE_DATETIME_DATETIME=127,
+ LT_DATETIME_DATETIME=128,
+ LE_DATETIME_DATETIME=129,
+ GT_DATETIME_DATETIME=130,
+ GE_DATETIME_DATETIME=131,
- EQ_ASCII_F_F =132,
- NE_ASCII_F_F =133,
- LT_ASCII_F_F =134,
- LE_ASCII_F_F =135,
- GT_ASCII_F_F =136,
- GE_ASCII_F_F =137,
+ EQ_ASCII_F_F =132,
+ NE_ASCII_F_F =133,
+ LT_ASCII_F_F =134,
+ LE_ASCII_F_F =135,
+ GT_ASCII_F_F =136,
+ GE_ASCII_F_F =137,
- EQ_UNICODE_F_F =138,
- NE_UNICODE_F_F =139,
- LT_UNICODE_F_F =140,
- LE_UNICODE_F_F =141,
- GT_UNICODE_F_F =142,
- GE_UNICODE_F_F =143,
+ EQ_UNICODE_F_F =138,
+ NE_UNICODE_F_F =139,
+ LT_UNICODE_F_F =140,
+ LE_UNICODE_F_F =141,
+ GT_UNICODE_F_F =142,
+ GE_UNICODE_F_F =143,
- ASCII_COMP =144,
- UNICODE_COMP =145,
+ ASCII_COMP =144,
+ UNICODE_COMP =145,
- COMP_COMPLEX =146,
-
- EQ_ASCII_COMP =147,
- NE_ASCII_COMP =148,
- LT_ASCII_COMP =149,
- LE_ASCII_COMP =150,
- GT_ASCII_COMP =151,
- GE_ASCII_COMP =152,
-
- EQ_BLOB =153,
- NE_BLOB =154,
- LT_BLOB =155,
- LE_BLOB =156,
- GT_BLOB =157,
- GE_BLOB =158,
-
- EQ_BIN64U_BIN64U =159,
- EQ_BIN64U_BIN64S =160,
- EQ_BIN64S_BIN64U =161,
- NE_BIN64U_BIN64U =162,
- NE_BIN64U_BIN64S =163,
- NE_BIN64S_BIN64U =164,
- LT_BIN64U_BIN64U =165,
- LT_BIN64U_BIN64S =166,
- LT_BIN64S_BIN64U =167,
- LE_BIN64U_BIN64U =168,
- LE_BIN64U_BIN64S =169,
- LE_BIN64S_BIN64U =170,
- GT_BIN64U_BIN64U =171,
- GT_BIN64U_BIN64S =172,
- GT_BIN64S_BIN64U =173,
- GE_BIN64U_BIN64U =174,
- GE_BIN64U_BIN64S =175,
- GE_BIN64S_BIN64U =176,
+ COMP_COMPLEX =146,
+
+ EQ_ASCII_COMP =147,
+ NE_ASCII_COMP =148,
+ LT_ASCII_COMP =149,
+ LE_ASCII_COMP =150,
+ GT_ASCII_COMP =151,
+ GE_ASCII_COMP =152,
+
+ EQ_BLOB =153,
+ NE_BLOB =154,
+ LT_BLOB =155,
+ LE_BLOB =156,
+ GT_BLOB =157,
+ GE_BLOB =158,
+
+ EQ_BIN64U_BIN64U =159,
+ EQ_BIN64U_BIN64S =160,
+ EQ_BIN64S_BIN64U =161,
+ NE_BIN64U_BIN64U =162,
+ NE_BIN64U_BIN64S =163,
+ NE_BIN64S_BIN64U =164,
+ LT_BIN64U_BIN64U =165,
+ LT_BIN64U_BIN64S =166,
+ LT_BIN64S_BIN64U =167,
+ LE_BIN64U_BIN64U =168,
+ LE_BIN64U_BIN64S =169,
+ LE_BIN64S_BIN64U =170,
+ GT_BIN64U_BIN64U =171,
+ GT_BIN64U_BIN64S =172,
+ GT_BIN64S_BIN64U =173,
+ GE_BIN64U_BIN64U =174,
+ GE_BIN64U_BIN64S =175,
+ GE_BIN64S_BIN64U =176,
- EQ_BOOL_BOOL =177,
- NE_BOOL_BOOL =178,
-
- // tinyint operations
- EQ_BIN8S_BIN8S =179,
- EQ_BIN8U_BIN8U =180,
- NE_BIN8S_BIN8S =181,
- NE_BIN8U_BIN8U =182,
- LT_BIN8S_BIN8S =183,
- LT_BIN8U_BIN8U =184,
- LE_BIN8S_BIN8S =185,
- LE_BIN8U_BIN8U =186,
- GT_BIN8S_BIN8S =187,
- GT_BIN8U_BIN8U =188,
- GE_BIN8S_BIN8S =189,
- GE_BIN8U_BIN8U =190,
-
- COMP_NOT_SUPPORTED =191
- };
+ EQ_BOOL_BOOL =177,
+ NE_BOOL_BOOL =178,
+
+ // tinyint operations
+ EQ_BIN8S_BIN8S =179,
+ EQ_BIN8U_BIN8U =180,
+ NE_BIN8S_BIN8S =181,
+ NE_BIN8U_BIN8U =182,
+ LT_BIN8S_BIN8S =183,
+ LT_BIN8U_BIN8U =184,
+ LE_BIN8S_BIN8S =185,
+ LE_BIN8U_BIN8U =186,
+ GT_BIN8S_BIN8S =187,
+ GT_BIN8U_BIN8U =188,
+ GE_BIN8S_BIN8S =189,
+ GE_BIN8U_BIN8U =190,
+
+ COMP_NOT_SUPPORTED =191
+};
+
+class SQLEXP_LIB_FUNC ex_comp_clause : public ex_clause {
+
+ typedef struct {
+ OperatorTypeEnum op;
+ short type_op1; // left operand
+ short type_op2; // right operand
+ CompInstruction instruction;
+ const char * instrStr;
+ } CompInstrStruct;
+
+public:
// Construction
//
@@ -1154,12 +1172,16 @@ public:
// Accessors
//
- NA_EIDPROC inline comp_case_index get_case_index()
+ NA_EIDPROC inline CompInstruction getInstruction()
{
- return (comp_case_index) case_index;
+ if (getInstrArrayIndex() >= 0)
+ return getInstruction(getInstrArrayIndex());
+ else
+ return COMP_NOT_SUPPORTED;
};
- NA_EIDPROC void set_case_index();
- NA_EIDPROC void set_case_index(OperatorTypeEnum op,
+
+ NA_EIDPROC void setInstruction();
+ NA_EIDPROC void setInstruction(OperatorTypeEnum op,
Attributes * attr1,
Attributes * attr2);
@@ -1167,6 +1189,15 @@ public:
Attributes * attr1,
Attributes * attr2);
+ static const CompInstrStruct compInstrInfo[];
+ static const char * getInstructionStr(Lng32 index)
+ { return compInstrInfo[index].instrStr;}
+ static const CompInstruction getInstruction(Lng32 index)
+ { return compInstrInfo[index].instruction;}
+
+ Lng32 findIndexIntoInstrArray(CompInstruction ci);
+
+
// Null Semantics
//
NA_EIDPROC Int32 isNullInNullOut() const { return 0; };
@@ -1241,7 +1272,7 @@ private:
COLLATION_ENCODE_COMP = 0x0001
};
- Int32 case_index; // 00-03
+ Int32 filler0; // 00-03
Int16 flags_; //04-05
// ---------------------------------------------------------------------
// Fillers for potential future extensions without changing class size.
@@ -1253,30 +1284,20 @@ private:
CollHeap *heap,
ComDiagsArea** diagsArea);
- NA_EIDPROC const ex_comp_struct * getMatchingRow(OperatorTypeEnum op,
+ NA_EIDPROC const CompInstrStruct * getMatchingRow(OperatorTypeEnum op,
short datatype1,
short datatype2);
- NA_EIDPROC const comp_case_index computeCaseIndex(OperatorTypeEnum op,
+ NA_EIDPROC const CompInstruction computeCaseIndex(OperatorTypeEnum op,
Attributes * attr1,
Attributes * attr2);
};
-// private helper struct for class ex_comp_clause (can not make it
-// a struct inside the class because of c89 limitations with nested classes)
-struct ex_comp_struct
-{
- OperatorTypeEnum op;
- short type_op1; // left operand
- short type_op2; // right operand
- ex_comp_clause::comp_case_index index;
-};
-
/////////////////////////////////////////
// Class ex_conv_clause
/////////////////////////////////////////
-enum conv_case_index {
+enum ConvInstruction {
// (these codes must remain invariant across future versions)
CONV_BIN16S_BPINTU =0,
CONV_BIN16S_BIN16S =1,
@@ -1636,6 +1657,13 @@ enum conv_case_index {
};
class SQLEXP_LIB_FUNC ex_conv_clause : public ex_clause {
+
+ typedef struct {
+ short type_op1; // left operand
+ short type_op2; // right operand
+ ConvInstruction instruction;
+ const char * instrStr;
+ } ConvInstrStruct;
public:
@@ -1670,7 +1698,7 @@ public:
// Accessors
//
- NA_EIDPROC void set_case_index();
+ NA_EIDPROC void setInstruction();
// Null Semantics
//
@@ -1687,17 +1715,31 @@ public:
NA_EIDPROC ex_expr::exp_return_type eval(char *op_data[],
CollHeap * = 0,
ComDiagsArea ** = 0);
- NA_EIDPROC inline conv_case_index get_case_index()
+
+ // case index get and set
+ ConvInstruction getInstruction()
{
- return (conv_case_index) case_index;
+ if (getInstrArrayIndex() >= 0)
+ return getInstruction(getInstrArrayIndex());
+ else
+ return CONV_NOT_SUPPORTED;
};
- NA_EIDPROC conv_case_index find_case_index(short sourceType, Lng32 sourceLen,
+
+ NA_EIDPROC ConvInstruction findInstruction(short sourceType, Lng32 sourceLen,
short targetType, Lng32 targetLen,
Lng32 scaleDifference);
NABoolean isConversionSupported(short sourceType, Lng32 srcLen,
short targetType, Lng32 tgtLen);
+ static const ConvInstrStruct convInstrInfo[];
+ static const char * getInstructionStr(Lng32 index)
+ { return convInstrInfo[index].instrStr;}
+ static const ConvInstruction getInstruction(Lng32 index)
+ { return convInstrInfo[index].instruction;}
+
+ Lng32 findIndexIntoInstrArray(ConvInstruction ci);
+
NA_EIDPROC NABoolean treatAllSpacesAsZero()
{ return ((flags_ & TREAT_ALL_SPACES_AS_ZERO) != 0); };
@@ -1791,16 +1833,6 @@ public:
return alignment_;
}
private:
- // conv_case_index
- Int16 case_index; // 00-01
-
- // Flags
- UInt16 flags_; // 02-03
- UInt32 lastVOAoffset_; //
- Int16 lastVcIndicatorLength_; // 08-09
- Int16 lastNullIndicatorLength_;// 10-11
- UInt32 computedLength_;
- Int16 alignment_;
enum flags_type
{
REVERSE_DATA_ERROR_CONVERSION_FLAG = 0x0001, // Reverse data error conversion flag
@@ -1817,6 +1849,17 @@ private:
// when convert into error, suppress error, move null into convert target
CONV_TO_NULL_WHEN_ERROR = 0x0020
};
+
+ char filler_[2]; // 00-01
+
+ // Flags
+ UInt16 flags_; // 02-03
+ UInt32 lastVOAoffset_; //
+ Int16 lastVcIndicatorLength_; // 08-09
+ Int16 lastNullIndicatorLength_;// 10-11
+ UInt32 computedLength_;
+ Int16 alignment_;
+
// ---------------------------------------------------------------------
// Fillers for potential future extensions without changing class size.
// When a new member is added, size of this filler should be reduced so
@@ -1885,7 +1928,7 @@ enum ConvDoItFlags
// for max. number of characters?
inline int requiresNoConvOrVal(Lng32 sourceLen, Lng32 sourcePrecision, Lng32 sourceScale,
Lng32 targetLen, Lng32 targetPrecision, Lng32 targetScale,
- conv_case_index index)
+ ConvInstruction index)
{
return (
// ISO chars are ok - treat UNKNOWN as ISO88591 if the other operand is ISO88591 or unknown
@@ -1927,7 +1970,7 @@ convDoIt(char * source,
Lng32 varCharLenSize, // 0 if not a varChar
CollHeap *heap = 0,
ComDiagsArea** diagsArea = 0,
- conv_case_index index = CONV_UNKNOWN,
+ ConvInstruction index = CONV_UNKNOWN,
Lng32 * dataConversionErrorFlag = 0,
ULng32 flags = 0);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/exp/exp_comp.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_comp.cpp b/core/sql/exp/exp_comp.cpp
index 2e4fb3e..88ad46f 100644
--- a/core/sql/exp/exp_comp.cpp
+++ b/core/sql/exp/exp_comp.cpp
@@ -187,7 +187,7 @@ ex_expr::exp_return_type ex_comp_clause::eval(char *op_data[],
{
ex_expr::exp_return_type retcode = ex_expr::EXPR_OK;
- switch (get_case_index())
+ switch (getInstruction())
{
// EQUAL opcode
case EQ_BIN8S_BIN8S:
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/exp/exp_conv.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_conv.cpp b/core/sql/exp/exp_conv.cpp
index c88ec8b..a2ce1e3 100644
--- a/core/sql/exp/exp_conv.cpp
+++ b/core/sql/exp/exp_conv.cpp
@@ -326,7 +326,7 @@ if (targetLen == SQL_LARGE_SIZE)
else
{
short physicalTargetType = (short) REC_BIN16_SIGNED;
- conv_case_index index = CONV_BIN64S_BIN16S;
+ ConvInstruction index = CONV_BIN64S_BIN16S;
if (targetLen == SQL_INT_SIZE)
{
@@ -513,7 +513,7 @@ else
else
{
short physicalTargetType = (short) REC_BIN16_SIGNED;
- conv_case_index index = CONV_BIN64S_BIN16S;
+ ConvInstruction index = CONV_BIN64S_BIN16S;
if (targetLen == SQL_INT_SIZE)
{
@@ -4966,7 +4966,7 @@ convDoIt(char * source,
Lng32 varCharLenSize, // 0 if not a varChar
CollHeap *heap,
ComDiagsArea** diagsArea,
- conv_case_index index,
+ ConvInstruction index,
Lng32 * dataConversionErrorFlag,
ULng32 flags) {
@@ -5020,7 +5020,7 @@ convDoIt(char * source,
if (index == CONV_UNKNOWN_LEFTPAD)
leftPad = TRUE;
- index = tempClause.find_case_index(sourceType,
+ index = tempClause.findInstruction(sourceType,
sourceLen,
targetType,
targetLen,
@@ -10063,7 +10063,7 @@ convDoIt(char * source,
case CONV_DECS_UNICODE:
case CONV_BIGNUM_UNICODE:
{
- conv_case_index cci = CONV_UNKNOWN; // next switch will change.
+ ConvInstruction cci = CONV_UNKNOWN; // next switch will change.
switch (index) {
case CONV_BIN16S_UNICODE: cci = CONV_BIN16S_ASCII;break;
case CONV_BIN16U_UNICODE: cci = CONV_BIN16U_ASCII;break;
@@ -10163,7 +10163,7 @@ convDoIt(char * source,
if ( cBuf -> getStrLen() == sourceLen/BYTES_PER_NAWCHAR ) {
- conv_case_index cci = CONV_UNKNOWN;
+ ConvInstruction cci = CONV_UNKNOWN;
switch (index) {
case CONV_UNICODE_BIN16S: cci = CONV_ASCII_BIN16S;break;
case CONV_UNICODE_BIN16U: cci = CONV_ASCII_BIN16U;break;
@@ -11664,7 +11664,7 @@ ex_expr::exp_return_type ex_conv_clause::eval(char *op_data[],
warningMark = 0;
- switch (get_case_index()) {
+ switch (getInstruction()) {
case CONV_COMPLEX_TO_COMPLEX: {
@@ -11733,7 +11733,7 @@ ex_expr::exp_return_type ex_conv_clause::eval(char *op_data[],
tgt->getVCIndicatorLength(),
heap,
diagsArea,
- get_case_index(),
+ getInstruction(),
dataConversionErrorFlag,
convFlags
);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c83ecab/core/sql/exp/exp_expr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_expr.cpp b/core/sql/exp/exp_expr.cpp
index 9424eb9..0b4e1a6 100644
--- a/core/sql/exp/exp_expr.cpp
+++ b/core/sql/exp/exp_expr.cpp
@@ -451,7 +451,7 @@ int ex_expr::formatARow2(const char** srcFldsPtr,
sizeof(vcActualLen),
heap,
diags,
- (conv_case_index)srcFieldsConvIndex[index]
+ (ConvInstruction)srcFieldsConvIndex[index]
);
if(err == ex_expr::EXPR_ERROR) return -1;