http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/exp/exp_function.cpp ---------------------------------------------------------------------- diff --git a/core/sql/exp/exp_function.cpp b/core/sql/exp/exp_function.cpp index 4e3211d..fd5a74b 100644 --- a/core/sql/exp/exp_function.cpp +++ b/core/sql/exp/exp_function.cpp @@ -3178,6 +3178,18 @@ void ex_function_encode::encodeKeyValue(Attributes * attr, switch (fsDatatype) { #if defined( NA_LITTLE_ENDIAN ) + case REC_BIN8_SIGNED: + // + // Flip the sign bit. + // + *(UInt8*)target = *(UInt8*)source; + target[0] ^= 0200; + break; + + case REC_BIN8_UNSIGNED: + *(UInt8*)target = *(UInt8*)source; + break; + case REC_BIN16_SIGNED: // // Flip the sign bit. @@ -3296,6 +3308,7 @@ void ex_function_encode::encodeKeyValue(Attributes * attr, break; } #else + case REC_BIN8_SIGNED: case REC_BIN16_SIGNED: case REC_BIN32_SIGNED: case REC_BIN64_SIGNED: @@ -3320,6 +3333,7 @@ void ex_function_encode::encodeKeyValue(Attributes * attr, target[0] ^= 0200; break; #endif + case REC_DECIMAL_LSE: // // If the number is negative, complement all the bytes. Otherwise, set @@ -3440,58 +3454,6 @@ void ex_function_encode::encodeKeyValue(Attributes * attr, break; } - case REC_TDM_FLOAT32: { - // - // Unencoded float (NSK): - // - // +-+----------------------+---------+ - // | | Mantissa |Exponent | - // | | (22 bits) |(9 bits) | - // +-+----------------------+---------+ - // | - // +- Sign bit - // - // Encoded float (NSK): - // - // +-+--------+-----------------------+ - // | |Exponent| Mantissa | - // | |(9 bits)| (22 bits) | - // +-+--------+-----------------------+ - // || | - // |+- Complemented if sign was neg.-+ - // | - // +- Sign bit complement - // - - - break; - } - case REC_TDM_FLOAT64: { - // - // Unencoded double (NSK): - // - // +-+----------------------+---------+ - // | | Mantissa |Exponent | - // | | (54 bits) |(9 bits) | - // +-+----------------------+---------+ - // | - // +- Sign bit - // - // - // Encoded double: - // - // +-+----------+---------------------+ - // | | Exponent | Mantissa | - // | | (9 bits) | (54 bits) | - // +-+----------+---------------------+ - // || | - // |+- Complemented if sign was neg.-+ - // | - // +- Sign bit complement - // - - break; - } // LCOV_EXCL_START case REC_BYTE_F_ASCII: { if (CollationInfo::isSystemCollation(collation )) @@ -4719,12 +4681,10 @@ ex_expr::exp_return_type ExHDPHash::eval(char *op_data[], break; case REC_BIN32_SIGNED: case REC_BIN32_UNSIGNED: - case REC_TDM_FLOAT32: case REC_IEEE_FLOAT32: flags = SWAP_FOUR; break; case REC_BIN64_SIGNED: - case REC_TDM_FLOAT64: case REC_IEEE_FLOAT64: flags = SWAP_EIGHT; break; @@ -5032,24 +4992,6 @@ ex_expr::exp_return_type getDoubleValue(double *dest, case REC_FLOAT64: *dest = *(double *)(source); return ex_expr::EXPR_OK; - case REC_TDM_FLOAT64: - // Convert source from TDM_FLOAT64 -> double - // - if (convDoIt(source, - operand->getLength(), - operand->getDatatype(), - operand->getPrecision(), - operand->getScale(), - (char *)dest, - (Lng32)sizeof(double), - REC_FLOAT64, - 0, - 0, - NULL, 0, heap, diagsArea, - CONV_UNKNOWN) != ex_expr::EXPR_OK) { - return ex_expr::EXPR_ERROR; - } - return ex_expr::EXPR_OK; default: ExRaiseSqlError(heap, diagsArea, EXE_INTERNAL_ERROR); return ex_expr::EXPR_ERROR; @@ -5068,24 +5010,6 @@ ex_expr::exp_return_type setDoubleValue(char *dest, case REC_FLOAT64: *(double *)dest = *source; return ex_expr::EXPR_OK; - case REC_TDM_FLOAT64: - // Convert source from double -> TDM_FLOAT64 - // - if (convDoIt((char *)source, - (Lng32)sizeof(double), - REC_FLOAT64, - 0, - 0, - dest, - operand->getLength(), - operand->getDatatype(), - operand->getPrecision(), - operand->getScale(), - NULL, 0, heap, diagsArea, - CONV_UNKNOWN) != ex_expr::EXPR_OK) { - return ex_expr::EXPR_ERROR; - } - return ex_expr::EXPR_OK; default: ExRaiseSqlError(heap, diagsArea, EXE_INTERNAL_ERROR); return ex_expr::EXPR_ERROR; @@ -7193,6 +7117,18 @@ short ex_function_encode::decodeKeyValue(Attributes * attr, switch (fsDatatype) { #if defined( NA_LITTLE_ENDIAN ) + case REC_BIN8_SIGNED: + // + // Flip the sign bit. + // + *(UInt8*)target = *(UInt8*)source; + target[0] ^= 0200; + break; + + case REC_BIN8_UNSIGNED: + *(UInt8*)target = *(UInt8*)source; + break; + case REC_BIN16_SIGNED: // // Flip the sign bit. @@ -7313,6 +7249,7 @@ short ex_function_encode::decodeKeyValue(Attributes * attr, break; } #else + case REC_BIN8_SIGNED: case REC_BIN16_SIGNED: case REC_BIN32_SIGNED: case REC_BIN64_SIGNED: @@ -7460,54 +7397,6 @@ short ex_function_encode::decodeKeyValue(Attributes * attr, break; } - case REC_TDM_FLOAT32: { - // - // Encoded float (NSK): - // - // +-+--------+-----------------------+ - // | |Exponent| Mantissa | - // | |(9 bits)| (22 bits) | - // +-+--------+-----------------------+ - // || | - // |+- Complemented if sign was neg.-+ - // | - // +- Sign bit complement - // - // Unencoded float (NSK): - // - // +-+----------------------+---------+ - // | | Mantissa |Exponent | - // | | (22 bits) |(9 bits) | - // +-+----------------------+---------+ - // | - // +- Sign bit - // - break; - } - case REC_TDM_FLOAT64: { - // - // Encoded double: - // - // +-+----------+---------------------+ - // | | Exponent | Mantissa | - // | | (9 bits) | (54 bits) | - // +-+----------+---------------------+ - // || | - // |+- Complemented if sign was neg.-+ - // | - // +- Sign bit complement - // - // Unencoded double (NSK): - // - // +-+----------------------+---------+ - // | | Mantissa |Exponent | - // | | (54 bits) |(9 bits) | - // +-+----------------------+---------+ - // | - // +- Sign bit - // - break; - } case REC_BYTE_V_ASCII: case REC_BYTE_V_ASCII_LONG: { //
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/exp/exp_math_func.cpp ---------------------------------------------------------------------- diff --git a/core/sql/exp/exp_math_func.cpp b/core/sql/exp/exp_math_func.cpp index fa2be98..b6e6cd2 100644 --- a/core/sql/exp/exp_math_func.cpp +++ b/core/sql/exp/exp_math_func.cpp @@ -102,44 +102,6 @@ ex_expr::exp_return_type ex_function_abs::eval(char *op_data[], *(double *)op_data[0] = fabs(*(double *)op_data[1]); break; - case REC_TDM_FLOAT64: - { - // convert tdm float to ieee float, do the abs and - // convert result back from ieee to tdm float. - double op1Double; - // LCOV_EXCL_START - if (convDoIt(op_data[1], - getOperand(1)->getLength(), - getOperand(1)->getDatatype(), - getOperand(1)->getPrecision(), - getOperand(1)->getScale(), - (char*)&op1Double, - (Lng32)sizeof(double), - REC_FLOAT64, - 0, - 0, NULL, 0, heap, diagsArea, - CONV_UNKNOWN) != ex_expr::EXPR_OK) - return ex_expr::EXPR_ERROR; - - if (op1Double < 0) - op1Double = -op1Double; - - // convert to result type. - if (convDoIt((char*)&op1Double, - (Lng32)sizeof(double), - REC_FLOAT64, - 0, 0, - op_data[0], - getOperand(0)->getLength(), - getOperand(0)->getDatatype(), - getOperand(0)->getPrecision(), - getOperand(0)->getScale(), - NULL, 0, heap, diagsArea, - CONV_UNKNOWN) != ex_expr::EXPR_OK) - return ex_expr::EXPR_ERROR; - } - break; - default: ExRaiseSqlError(heap, diagsArea, EXE_INTERNAL_ERROR); retcode = ex_expr::EXPR_ERROR; @@ -158,73 +120,8 @@ ex_expr::exp_return_type ExFunctionMath::evalUnsupportedOperations( CollHeap *heap, ComDiagsArea** diagsArea) { - if (getOperand(0)->getDatatype() == REC_TDM_FLOAT64) - { - // convert all child operands to double. - // Do the math function operation and convert result back to the - // type of result operand. - double op1Double; - double op2Double; - double op0Double; // result - - char * opDoubleData[3]; - opDoubleData[0] = (char *)&op0Double; - opDoubleData[1] = (char *)&op1Double; - opDoubleData[2] = (char *)&op2Double; - - SimpleType op1DoubleAttr(REC_FLOAT64, sizeof(double), 0, 0, - ExpTupleDesc::SQLMX_FORMAT, - 8, 0, 0, 0, Attributes::NO_DEFAULT, 0); - SimpleType op2DoubleAttr(REC_FLOAT64, sizeof(double), 0, 0, - ExpTupleDesc::SQLMX_FORMAT, - 8, 0, 0, 0, Attributes::NO_DEFAULT, 0); - SimpleType op0DoubleAttr(REC_FLOAT64, sizeof(double), 0, 0, - ExpTupleDesc::SQLMX_FORMAT, - 8, 0, 0, 0, Attributes::NO_DEFAULT, 0); - - for (Int32 i = 1; i < getNumOperands(); i++) - { -#pragma nowarn(1506) // warning elimination - if (convDoIt(op_data[i], - getOperand(i)->getLength(), - getOperand(i)->getDatatype(), - getOperand(i)->getPrecision(), - getOperand(i)->getScale(), - opDoubleData[i], - (Lng32)sizeof(double), - REC_FLOAT64, - 0, - 0, NULL, 0, heap, diagsArea, - CONV_UNKNOWN) != ex_expr::EXPR_OK) - return ex_expr::EXPR_ERROR; -#pragma warn(1506) // warning elimination - } - - ExFunctionMath tempMath(getOperType(), getNumOperands(), NULL, NULL); - if (tempMath.eval(opDoubleData, heap, diagsArea) != ex_expr::EXPR_OK) - return ex_expr::EXPR_ERROR; - - // convert double result to the actual result type. - if (convDoIt(opDoubleData[0], - (Lng32)sizeof(double), - REC_FLOAT64, - 0, 0, - op_data[0], - getOperand(0)->getLength(), - getOperand(0)->getDatatype(), - getOperand(0)->getPrecision(), - getOperand(0)->getScale(), - NULL, 0, heap, diagsArea, - CONV_UNKNOWN) != ex_expr::EXPR_OK) - return ex_expr::EXPR_ERROR; - } - else - { - ExRaiseSqlError(heap, diagsArea, EXE_INTERNAL_ERROR); - return ex_expr::EXPR_ERROR; - } - - return ex_expr::EXPR_OK; + ExRaiseSqlError(heap, diagsArea, EXE_INTERNAL_ERROR); + return ex_expr::EXPR_ERROR; } // LCOV_EXCL_STOP ex_expr::exp_return_type ExFunctionMath::eval(char *op_data[], http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/generator/GenPreCode.cpp ---------------------------------------------------------------------- diff --git a/core/sql/generator/GenPreCode.cpp b/core/sql/generator/GenPreCode.cpp index 56a1b95..7c67254 100644 --- a/core/sql/generator/GenPreCode.cpp +++ b/core/sql/generator/GenPreCode.cpp @@ -8605,42 +8605,35 @@ ItemExpr * Cast::preCodeGen(Generator * generator) } } - // Conversion to/from a tandem float type is only supported if - // the from/to type is a float type. - // If target is a tandem float type and source is not float or - // target is not float and source is tandem, then convert source - // to ieee float type (ieee double). - short srcFsType = child(0)->getValueId().getType().getFSDatatype(); - short tgtFsType = getValueId().getType().getFSDatatype(); - - if ((((tgtFsType == REC_TDM_FLOAT32) || - (tgtFsType == REC_TDM_FLOAT64)) && - ! ((srcFsType >= REC_MIN_FLOAT) && - (srcFsType <= REC_MAX_FLOAT))) || - - (((srcFsType == REC_TDM_FLOAT32) || - (srcFsType == REC_TDM_FLOAT64)) && - ! ((tgtFsType >= REC_MIN_FLOAT) && - (tgtFsType <= REC_MAX_FLOAT)))) - { - NAType * intermediateType = - new(generator->wHeap()) SQLDoublePrecision( - child(0)->getValueId().getType().supportsSQLnull(), - generator->wHeap()); - - // Genesis case 10-040126-9823. - // Match the scales of the source with that of the intermediate type. If - // this is not done, the cast to the intermediate type does not get scaled - // properly, leading to incorrect results. - child(0) = generator->getExpGenerator()->matchScales( - child(0)->getValueId(), *intermediateType); - - child(0) = new(generator->wHeap()) Cast(child(0),intermediateType); - - child(0)->bindNode(generator->getBindWA()); - - sourceTypeQual = - child(0)->getValueId().getType().getTypeQualifier(); + const NAType &srcNAType = child(0)->getValueId().getType(); + const NAType &tgtNAType = getValueId().getType(); + short srcFsType = srcNAType.getFSDatatype(); + short tgtFsType = tgtNAType.getFSDatatype(); + + // Currently, Tinyint conversions are only supported to/from smallint. + // if source is TINYINT, then convert it to SMALLINT first. + if (((srcNAType.getTypeName() == LiteralTinyInt) && + (tgtNAType.getTypeName() != LiteralSmallInt)) || + ((srcNAType.getTypeName() != LiteralSmallInt) && + (tgtNAType.getTypeName() == LiteralTinyInt))) + { + // add a Cast node to convert from/to tinyint to/from small int. + ItemExpr * newChild = + new (generator->wHeap()) + Cast(child(0), + new (generator->wHeap()) + SQLSmall(TRUE, + srcNAType.supportsSQLnull())); + ((Cast*)newChild)->setFlags(getFlags()); + // ((Cast*)newChild)->setSrcIsVarcharPtr(srcIsVarcharPtr()); + setSrcIsVarcharPtr(FALSE); + newChild = newChild->bindNode(generator->getBindWA()); + newChild = newChild->preCodeGen(generator); + if (! newChild) + return NULL; + + setChild(0, newChild); + srcFsType = child(0)->getValueId().getType().getFSDatatype(); } if ((sourceTypeQual == NA_NUMERIC_TYPE) && @@ -8929,18 +8922,6 @@ ItemExpr * Cast::preCodeGen(Generator * generator) intermediateScale = 324; // 308 + 17 - 1 = 324 } - else if (sourceNumType->getFSDatatype() == REC_TDM_FLOAT32) - { - intermediatePrecision = 164; // (2 x 78) + 7 + 1 = 164 - intermediateScale = 84; // 78 + 7 - 1 = 84 - } - - else if (sourceNumType->getFSDatatype() == REC_TDM_FLOAT64) - { - intermediatePrecision = 175; // (2 x 78) + 18 + 1 = 175 - intermediateScale = 95; // 78 + 18 - 1 = 95 - } - NAType * intermediateType = new(generator->wHeap()) SQLBigNum(intermediatePrecision, http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/langman/LmJavaType.cpp ---------------------------------------------------------------------- diff --git a/core/sql/langman/LmJavaType.cpp b/core/sql/langman/LmJavaType.cpp index 980005c..543fef1 100644 --- a/core/sql/langman/LmJavaType.cpp +++ b/core/sql/langman/LmJavaType.cpp @@ -36,12 +36,13 @@ #include "LmParameter.h" #include "LmJavaType.h" -#define JAVATYPETABLE_SIZE 16 +#define JAVATYPETABLE_SIZE 17 #define LM_JAVATYPE_INVALID_INDEX -1 LmJavaType::TypeElement LmJavaType::javaTypeTable[] = { {JT_VOID, "V", 1, "void", 4}, + {JT_TINY, "T", 1, "tiny", 4}, {JT_SHORT, "S", 1, "short", 5}, {JT_INT, "I", 1, "int", 3}, {JT_LONG, "J", 1, "long", 4}, @@ -84,6 +85,23 @@ LmJavaType::LmJavaType(LmParameter *lmParam) ComFSDataType data_type = lmParam_->fsType(); switch(data_type) { + case COM_SIGNED_BIN8_FSDT: + case COM_UNSIGNED_BIN8_FSDT: + { + if (lmParam_->prec() > 0) + { + type_ = JT_MATH_BIGDEC; + } + else + { + if (lmParam_->objMapping()) + type_ = (Type) (lmParam_->fsType() + COM_LAST_FSDT); + else + type_ = JT_TINY; + } + break; + } + case COM_SIGNED_BIN16_FSDT: case COM_UNSIGNED_BIN16_FSDT: { @@ -245,6 +263,7 @@ LmJavaType::isJavaTypeObject() const return TRUE; case JT_VOID: + case JT_TINY: case JT_SHORT: case JT_INT: case JT_LONG: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/langman/LmJavaType.h ---------------------------------------------------------------------- diff --git a/core/sql/langman/LmJavaType.h b/core/sql/langman/LmJavaType.h index a429a3d..1770904 100644 --- a/core/sql/langman/LmJavaType.h +++ b/core/sql/langman/LmJavaType.h @@ -67,6 +67,7 @@ public: enum Type { JT_NONE = COM_UNKNOWN_FSDT -1, JT_VOID = COM_UNKNOWN_FSDT, + JT_TINY = COM_SIGNED_BIN8_FSDT, JT_SHORT = COM_SIGNED_BIN16_FSDT, JT_INT = COM_SIGNED_BIN32_FSDT, JT_LONG = COM_SIGNED_BIN64_FSDT, http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/langman/LmResultSetJava.cpp ---------------------------------------------------------------------- diff --git a/core/sql/langman/LmResultSetJava.cpp b/core/sql/langman/LmResultSetJava.cpp index 99b577c..b9468c6 100644 --- a/core/sql/langman/LmResultSetJava.cpp +++ b/core/sql/langman/LmResultSetJava.cpp @@ -599,6 +599,35 @@ LmResultSetJava::fetchSpecialRows(void *dataPtr, switch(LmJavaType(col).getType()) { + case LmJavaType::JT_TINY: + { + jlong jlval; + lmResult = getValueAsJlong(javaRS, index + 1, da, wasNull, jlval); + + if (lmResult == LM_ERR) + { + retcode = -1; // Diags are already populated + break; + } + + if (!wasNull) + { + // Now cast jlong to appropriate value + if (col->fsType() == COM_SIGNED_BIN8_FSDT) + { + char sval = (char) jlval; + memcpy(thisColDataPtr, (char *)&sval, col->outSize()); + } + else + { + unsigned char sval = (unsigned char) jlval; + memcpy(thisColDataPtr, (char *)&sval, col->outSize()); + } + } + + } // JT_TINY + break; + case LmJavaType::JT_SHORT: { jlong jlval; @@ -875,6 +904,13 @@ LmResultSetJava::fetchSpecialRows(void *dataPtr, } else { + if ((col->fsType() == COM_SIGNED_BIN8_FSDT) || + (col->fsType() == COM_UNSIGNED_BIN8_FSDT)) + { + char sval = (char)jlval; + memcpy(thisColDataPtr, (char *)&sval, col->outSize()); + } + else if ((col->fsType() == COM_SIGNED_BIN16_FSDT) || (col->fsType() == COM_UNSIGNED_BIN16_FSDT)) { @@ -882,18 +918,16 @@ LmResultSetJava::fetchSpecialRows(void *dataPtr, memcpy(thisColDataPtr, (char *)&sval, col->outSize()); } else - { - if ((col->fsType() == COM_SIGNED_BIN32_FSDT) || + if ((col->fsType() == COM_SIGNED_BIN32_FSDT) || (col->fsType() == COM_UNSIGNED_BIN32_FSDT)) - { - Int32 ival = (Int32)jlval; - memcpy(thisColDataPtr, (char *)&ival, col->outSize()); - } - else - { - // 64 bit value - memcpy(thisColDataPtr, (char *)&jlval, col->outSize()); - } + { + Int32 ival = (Int32)jlval; + memcpy(thisColDataPtr, (char *)&ival, col->outSize()); + } + else + { + // 64 bit value + memcpy(thisColDataPtr, (char *)&jlval, col->outSize()); } } http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/langman/LmRoutineCSql.cpp ---------------------------------------------------------------------- diff --git a/core/sql/langman/LmRoutineCSql.cpp b/core/sql/langman/LmRoutineCSql.cpp index 043def2..c32686e 100644 --- a/core/sql/langman/LmRoutineCSql.cpp +++ b/core/sql/langman/LmRoutineCSql.cpp @@ -909,6 +909,15 @@ LmResult LmRoutineCSql::invokeRoutine(void *inputRow, } break; + case COM_SIGNED_BIN8_FSDT: + case COM_UNSIGNED_BIN8_FSDT: + { + // TINYINT [UNSIGNED] + // NUMERIC 0 <= precision <= 3 + memcpy(inCopy, inData, 1); + } + break; + case COM_SIGNED_BIN16_FSDT: case COM_UNSIGNED_BIN16_FSDT: { @@ -1009,6 +1018,15 @@ LmResult LmRoutineCSql::invokeRoutine(void *inputRow, } break; + case COM_SIGNED_BIN8_FSDT: + case COM_UNSIGNED_BIN8_FSDT: + { + // TINYINT [UNSIGNED] + // NUMERIC 0 <= precision <= 3 + memset(outCopy, 0, 1); + } + break; + case COM_SIGNED_BIN16_FSDT: case COM_UNSIGNED_BIN16_FSDT: { @@ -1185,6 +1203,15 @@ LmResult LmRoutineCSql::invokeRoutine(void *inputRow, } break; + case COM_SIGNED_BIN8_FSDT: + case COM_UNSIGNED_BIN8_FSDT: + { + // TINYINT [UNSIGNED] + // NUMERIC 0 <= precision <= 3 + memcpy(outData, outCopy, 1); + } + break; + case COM_SIGNED_BIN16_FSDT: case COM_UNSIGNED_BIN16_FSDT: { http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/optimizer/BindRelExpr.cpp ---------------------------------------------------------------------- diff --git a/core/sql/optimizer/BindRelExpr.cpp b/core/sql/optimizer/BindRelExpr.cpp index 8188b57..d20b452 100644 --- a/core/sql/optimizer/BindRelExpr.cpp +++ b/core/sql/optimizer/BindRelExpr.cpp @@ -1004,19 +1004,6 @@ void castComputedColumnsToAnsiTypes(BindWA *bindWA, CollIndex i = cols.entries(); CMPASSERT(i == compExpr.entries()); - NAString tmp; - // For a SELECT query that is part of a CREATE VIEW statement, force use of IEEE floating-point - // because SQL/MX Catalog Manager does not support Tandem floating-point, and would return an - // internal error if it is encountered. - if (bindWA->inViewDefinition() || bindWA->inMVDefinition()) - tmp = "IEEE"; - else - CmpCommon::getDefault(FLOATTYPE, tmp, -1); - NABoolean outputFloattypeIEEE = - ((tmp == "IEEE") || - (CmpCommon::getDefault(ODBC_PROCESS) == DF_ON) || - (CmpCommon::getDefault(JDBC_PROCESS) == DF_ON)); - while (i--) { ColumnDesc *col = cols[i]; @@ -1061,65 +1048,25 @@ void castComputedColumnsToAnsiTypes(BindWA *bindWA, compExpr[i] = newChild->getValueId(); } - // For dynamic queries that are not part of a CREATE VIEW, change the returned type based on the - // 'floattype' CQD. The default is Tandem type. - // This is done to be upward compatible with - // pre-R2 dynamic programs which are coded to expect tandem float - // types in dynamic statements (describe, get descriptor, etc...). - // The static statements are ok as we would convert from/to - // tandem float hostvariables at runtime. - // For the SELECT query that is part of a CREATE VIEW statement, do not convert to any - // Tandem floating-point type because SQL/MX catalog manager does not support Tandem floating-point - // and would give internal error. - if ((naType.getTypeQualifier() == NA_NUMERIC_TYPE) && - (CmpCommon::context()->GetMode() == STMT_DYNAMIC)) - { - NumericType &nTyp = (NumericType &)col->getValueId().getType(); - - if ((outputFloattypeIEEE && - (nTyp.getFSDatatype() == REC_TDM_FLOAT32 || - nTyp.getFSDatatype() == REC_TDM_FLOAT64)) || - (! outputFloattypeIEEE && - (nTyp.getFSDatatype() == REC_IEEE_FLOAT32 || - nTyp.getFSDatatype() == REC_IEEE_FLOAT64))) - { - NAType *newTyp; - - if (outputFloattypeIEEE) - { - // convert to IEEE floating point. - newTyp = new (bindWA->wHeap()) - SQLDoublePrecision(nTyp.supportsSQLnull(), - bindWA->wHeap(), - nTyp.getBinaryPrecision()); - } - else - { - // convert to Tandem floating point. - if (nTyp.getFSDatatype() == REC_IEEE_FLOAT32) - newTyp = new (bindWA->wHeap()) - SQLRealTdm(nTyp.supportsSQLnull(), - bindWA->wHeap(), - nTyp.getBinaryPrecision()); - else - newTyp = new (bindWA->wHeap()) - SQLDoublePrecisionTdm(nTyp.supportsSQLnull(), - bindWA->wHeap(), - nTyp.getBinaryPrecision()); - } - - ItemExpr *ie = col->getValueId().getItemExpr(); - ItemExpr *cast = new (bindWA->wHeap()) - Cast(ie, newTyp, ITM_CAST); - cast = cast->bindNode(bindWA); - if (bindWA->errStatus()) return; - - col->setValueId(cast->getValueId()); - compExpr[i] = cast->getValueId(); - } + // if ON, return tinyint as smallint. + // This is needed until all callers/drivers have full support to + // handle IO of tinyint datatypes. + if ((naType.getTypeName() == LiteralTinyInt) && + ((CmpCommon::getDefault(TRAF_TINYINT_SUPPORT) == DF_OFF) || + (CmpCommon::getDefault(TRAF_TINYINT_RETURN_VALUES) == DF_OFF))) + { + ItemExpr * cast = new (bindWA->wHeap()) + Cast(col->getValueId().getItemExpr(), + new (bindWA->wHeap()) SQLSmall(TRUE, naType.supportsSQLnull())); + cast = cast->bindNode(bindWA); + if (bindWA->errStatus()) + return; + col->setValueId(cast->getValueId()); + compExpr[i] = cast->getValueId(); } - - if (naType.getTypeQualifier() == NA_NUMERIC_TYPE && !((NumericType &)col->getValueId().getType()).binaryPrecision()) { + + else if (naType.getTypeQualifier() == NA_NUMERIC_TYPE && + !((NumericType &)col->getValueId().getType()).binaryPrecision()) { NumericType &nTyp = (NumericType &)col->getValueId().getType(); ItemExpr * ie = col->getValueId().getItemExpr(); http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/optimizer/EncodedValue.cpp ---------------------------------------------------------------------- diff --git a/core/sql/optimizer/EncodedValue.cpp b/core/sql/optimizer/EncodedValue.cpp index 2c29714..829105b 100644 --- a/core/sql/optimizer/EncodedValue.cpp +++ b/core/sql/optimizer/EncodedValue.cpp @@ -500,6 +500,14 @@ EncodedValue::outputToBufferToComputeRTHash( double x = getDblValue(); flags = ExHDPHash::NO_FLAGS; switch (naType->getFSDatatype()) { + case REC_BIN8_UNSIGNED: + len = 1; + { UInt8 y = (UInt8)x; memcpy(data, &y, len); } + break; + case REC_BIN8_SIGNED: + len = 1; + { Int8 y = (Int8)x; memcpy(data, &y, len); } + break; case REC_BIN16_UNSIGNED: len = 2; flags =ExHDPHash::SWAP_TWO; @@ -510,7 +518,7 @@ EncodedValue::outputToBufferToComputeRTHash( flags =ExHDPHash::SWAP_TWO; { short y = (short)x; memcpy(data, &y, len); } break; - case REC_BIN32_UNSIGNED: + case REC_BIN32_UNSIGNED: len = 4; flags =ExHDPHash::SWAP_FOUR; { UInt32 y = (UInt32)x; memcpy(data, &y, len); } http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/optimizer/ItemExpr.cpp ---------------------------------------------------------------------- diff --git a/core/sql/optimizer/ItemExpr.cpp b/core/sql/optimizer/ItemExpr.cpp index 04adb28..bdc9ea1 100644 --- a/core/sql/optimizer/ItemExpr.cpp +++ b/core/sql/optimizer/ItemExpr.cpp @@ -11149,12 +11149,10 @@ UInt32 ConstValue::computeHashValue(const NAType& columnType) break; case REC_BIN32_SIGNED: case REC_BIN32_UNSIGNED: - case REC_TDM_FLOAT32: case REC_IEEE_FLOAT32: flags = ExHDPHash::SWAP_FOUR; break; case REC_BIN64_SIGNED: - case REC_TDM_FLOAT64: case REC_IEEE_FLOAT64: flags = ExHDPHash::SWAP_EIGHT; break; @@ -12033,8 +12031,7 @@ Cast::Cast(ItemExpr *val1Ptr, const NAType *type, OperatorTypeEnum otype, } } - noStringTruncationWarnings_ = noStringTrunWarnings; - convertNullWhenError_ = FALSE; + setNoStringTruncationWarnings(noStringTrunWarnings); } Cast::Cast(ItemExpr *val1Ptr, ItemExpr *errorOutPtr, const NAType *type, @@ -12047,8 +12044,7 @@ Cast::Cast(ItemExpr *val1Ptr, ItemExpr *errorOutPtr, const NAType *type, flags_(0) { checkForTruncation_ = checkForTrunc; - noStringTruncationWarnings_ = noStringTrunWarnings; - convertNullWhenError_ = FALSE; + setNoStringTruncationWarnings(noStringTrunWarnings); } Cast::~Cast() {} @@ -12204,7 +12200,7 @@ NABoolean Cast::hasEquivalentProperties(ItemExpr * other) (this->type_->operator == (*(tmp->type_) )) && (this->checkForTruncation_ == tmp->checkForTruncation_ ) && (this->reverseDataErrorConversionFlag_ == tmp->reverseDataErrorConversionFlag_ ) && - (this->noStringTruncationWarnings_ == tmp->noStringTruncationWarnings_ ) && + // (this->noStringTruncationWarnings_ == tmp->noStringTruncationWarnings_ ) && (this->flags_ == tmp->flags_); } // -------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/optimizer/ItemFunc.h ---------------------------------------------------------------------- diff --git a/core/sql/optimizer/ItemFunc.h b/core/sql/optimizer/ItemFunc.h index 41e5c92..0589fc7 100644 --- a/core/sql/optimizer/ItemFunc.h +++ b/core/sql/optimizer/ItemFunc.h @@ -2436,10 +2436,6 @@ public: NABoolean checkTruncationError() { return checkForTruncation_; } void setCheckTruncationError(NABoolean v) { checkForTruncation_ = v; } - NABoolean noStringTruncationWarnings() { return noStringTruncationWarnings_; } - - NABoolean convertNullWhenError() { return convertNullWhenError_; } - // get and set for flags_. See enum Flags. NABoolean matchChildType() { return (flags_ & MATCH_CHILD_TYPE) != 0; } void setMatchChildType(NABoolean v) @@ -2465,16 +2461,23 @@ public: NA_EIDPROC void setAllowSignInInterval(NABoolean v) { (v) ? flags_ |= ALLOW_SIGN_IN_INTERVAL : flags_ &= ~ALLOW_SIGN_IN_INTERVAL; } + NABoolean convertNullWhenError() + { return (flags_ & CONV_NULL_WHEN_ERROR) != 0; } + void setConvertNullWhenError(NABoolean v) + { (v ? flags_ |= CONV_NULL_WHEN_ERROR : flags_ &= ~CONV_NULL_WHEN_ERROR); } + + NABoolean noStringTruncationWarnings() + { return (flags_ & NO_STRING_TRUNC_WARNINGS) != 0; } + void setNoStringTruncationWarnings(NABoolean v) + { (v ? flags_ |= NO_STRING_TRUNC_WARNINGS: flags_ &= ~NO_STRING_TRUNC_WARNINGS); } + const NAType * pushDownType(NAType& desiredType, enum NABuiltInTypeEnum defaultQualifier); virtual NABoolean hasEquivalentProperties(ItemExpr * other); - void setNoStringTruncationWarnings(NABoolean v) - { noStringTruncationWarnings_ = v; } - - void setConvertNullWhenError(NABoolean v) - { convertNullWhenError_= v; } + UInt16 getFlags() { return flags_; } + void setFlags(UInt16 f) { flags_ = f; } private: @@ -2495,7 +2498,13 @@ private: // source is a varchar value which is a pointer to the actual data. SRC_IS_VARCHAR_PTR = 0x0008, - ALLOW_SIGN_IN_INTERVAL = 0x0010 + ALLOW_SIGN_IN_INTERVAL = 0x0010, + + // convert error will not be returned, null will be moved into target + CONV_NULL_WHEN_ERROR = 0x0020, + + // string truncation warnings are not to be returned + NO_STRING_TRUNC_WARNINGS = 0x0040 }; @@ -2509,13 +2518,6 @@ private: // This is a Narrow-only issue. NABoolean reverseDataErrorConversionFlag_; - // If true, string truncation warnings are not returned. This is set to true - - NABoolean noStringTruncationWarnings_; - - // If true, convert error will not returned, move null into target - NABoolean convertNullWhenError_; - UInt32 flags_; }; // class Cast http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/optimizer/NAColumn.cpp ---------------------------------------------------------------------- diff --git a/core/sql/optimizer/NAColumn.cpp b/core/sql/optimizer/NAColumn.cpp index 1e47161..54c53fd 100644 --- a/core/sql/optimizer/NAColumn.cpp +++ b/core/sql/optimizer/NAColumn.cpp @@ -214,7 +214,42 @@ NABoolean NAColumn::createNAType(columns_desc_struct *column_desc /*IN*/, SQLBPInt(column_desc->precision, column_desc->null_flag, FALSE, heap); break; - case REC_BIN16_SIGNED: + case REC_BIN8_SIGNED: + if (column_desc->precision > 0) + type = new (heap) + SQLNumeric(column_desc->length, + column_desc->precision, + column_desc->scale, + TRUE, + column_desc->null_flag, + heap + ); + else + type = new (heap) + SQLTiny(TRUE, + column_desc->null_flag, + heap + ); + break; + case REC_BIN8_UNSIGNED: + if (column_desc->precision > 0) + type = new (heap) + SQLNumeric(column_desc->length, + column_desc->precision, + column_desc->scale, + FALSE, + column_desc->null_flag, + heap + ); + else + type = new (heap) + SQLTiny(FALSE, + column_desc->null_flag, + heap + ); + break; + + case REC_BIN16_SIGNED: if (column_desc->precision > 0) type = new (heap) SQLNumeric(column_desc->length, @@ -248,6 +283,7 @@ NABoolean NAColumn::createNAType(columns_desc_struct *column_desc /*IN*/, heap ); break; + case REC_BIN32_SIGNED: if (column_desc->precision > 0) type = new (heap) @@ -338,16 +374,6 @@ NABoolean NAColumn::createNAType(columns_desc_struct *column_desc /*IN*/, ); break; - case REC_TDM_FLOAT32: - type = new (heap) - SQLRealTdm(column_desc->null_flag, heap, column_desc->precision); - break; - - case REC_TDM_FLOAT64: - type = new (heap) - SQLDoublePrecisionTdm(column_desc->null_flag, heap, column_desc->precision); - break; - case REC_FLOAT32: type = new (heap) SQLReal(column_desc->null_flag, heap, column_desc->precision); @@ -501,7 +527,7 @@ NABoolean NAColumn::createNAType(columns_desc_struct *column_desc /*IN*/, } break; -case REC_BLOB : + case REC_BLOB : type = new (heap) SQLBlob(column_desc->precision, Lob_Invalid_Storage, column_desc->null_flag); http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/optimizer/NATable.cpp ---------------------------------------------------------------------- diff --git a/core/sql/optimizer/NATable.cpp b/core/sql/optimizer/NATable.cpp index 7150963..0d45133 100644 --- a/core/sql/optimizer/NATable.cpp +++ b/core/sql/optimizer/NATable.cpp @@ -2961,6 +2961,41 @@ NABoolean createNAType(columns_desc_struct *column_desc /*IN*/, SQLBPInt(column_desc->precision, column_desc->null_flag, FALSE, heap); break; + case REC_BIN8_SIGNED: + if (column_desc->precision > 0) + type = new (heap) + SQLNumeric(column_desc->length, + column_desc->precision, + column_desc->scale, + TRUE, + column_desc->null_flag, + heap + ); + else + type = new (heap) + SQLTiny(TRUE, + column_desc->null_flag, + heap + ); + break; + case REC_BIN8_UNSIGNED: + if (column_desc->precision > 0) + type = new (heap) + SQLNumeric(column_desc->length, + column_desc->precision, + column_desc->scale, + FALSE, + column_desc->null_flag, + heap + ); + else + type = new (heap) + SQLTiny(FALSE, + column_desc->null_flag, + heap + ); + break; + case REC_BIN16_SIGNED: if (column_desc->precision > 0) type = new (heap) @@ -2995,6 +3030,7 @@ NABoolean createNAType(columns_desc_struct *column_desc /*IN*/, heap ); break; + case REC_BIN32_SIGNED: if (column_desc->precision > 0) type = new (heap) @@ -3085,16 +3121,6 @@ NABoolean createNAType(columns_desc_struct *column_desc /*IN*/, ); break; - case REC_TDM_FLOAT32: - type = new (heap) - SQLRealTdm(column_desc->null_flag, heap, column_desc->precision); - break; - - case REC_TDM_FLOAT64: - type = new (heap) - SQLDoublePrecisionTdm(column_desc->null_flag, heap, column_desc->precision); - break; - case REC_FLOAT32: type = new (heap) SQLReal(column_desc->null_flag, heap, column_desc->precision); @@ -3520,8 +3546,15 @@ NABoolean createNAColumns(desc_struct *column_desc_list /*IN*/, NAType* getSQColTypeForHive(const char* hiveType, NAMemory* heap) { - if ( !strcmp(hiveType, "tinyint") || - !strcmp(hiveType, "smallint")) + if ( !strcmp(hiveType, "tinyint")) + { + if (CmpCommon::getDefault(TRAF_TINYINT_SUPPORT) == DF_OFF) + return new (heap) SQLSmall(TRUE /* neg */, TRUE /* allow NULL*/, heap); + else + return new (heap) SQLTiny(TRUE /* neg */, TRUE /* allow NULL*/, heap); + } + + if ( !strcmp(hiveType, "smallint")) return new (heap) SQLSmall(TRUE /* neg */, TRUE /* allow NULL*/, heap); if ( !strcmp(hiveType, "int")) http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/optimizer/OptRange.cpp ---------------------------------------------------------------------- diff --git a/core/sql/optimizer/OptRange.cpp b/core/sql/optimizer/OptRange.cpp index f6c0b84..8e6464c 100644 --- a/core/sql/optimizer/OptRange.cpp +++ b/core/sql/optimizer/OptRange.cpp @@ -849,7 +849,6 @@ void OptRangeSpec::intersectTypeConstraint(QRDescGenerator* descGen, { switch (colType.getFSDatatype()) { - case REC_TDM_FLOAT32: case REC_IEEE_FLOAT32: { typeRange = new(mvqrHeap_) OptRangeSpec(descGen, mvqrHeap_); @@ -866,7 +865,6 @@ void OptRangeSpec::intersectTypeConstraint(QRDescGenerator* descGen, } break; - case REC_TDM_FLOAT64: case REC_IEEE_FLOAT64: // No range restriction needed. break; http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/optimizer/ValueDesc.cpp ---------------------------------------------------------------------- diff --git a/core/sql/optimizer/ValueDesc.cpp b/core/sql/optimizer/ValueDesc.cpp index 59edfeb..173ce7a 100644 --- a/core/sql/optimizer/ValueDesc.cpp +++ b/core/sql/optimizer/ValueDesc.cpp @@ -350,53 +350,37 @@ void ValueId::coerceType(const NAType& desiredType, // if (NotaCharType && // We do not want to force a characters storage values to be float (desiredType.getFSDatatype() == REC_FLOAT32 || - desiredType.getFSDatatype() == REC_FLOAT64 || - desiredType.getFSDatatype() == REC_TDM_FLOAT32 || - desiredType.getFSDatatype() == REC_TDM_FLOAT64)) + desiredType.getFSDatatype() == REC_FLOAT64 )) { - // type untyped params according to floattype CQD. - NAString tmp; - CmpCommon::getDefault(FLOATTYPE, tmp, -1); - NABoolean inputFloattypeIEEE = - ((tmp == "IEEE") || - (CmpCommon::getDefault(ODBC_PROCESS) == DF_ON) || - (CmpCommon::getDefault(JDBC_PROCESS) == DF_ON)); - - if (NOT inputFloattypeIEEE) - { - if (desiredType.getFSDatatype() == REC_TDM_FLOAT32) - newType = new STMTHEAP - SQLRealTdm(desiredType.supportsSQLnull(), - STMTHEAP, - desiredType.getPrecision()); - else - newType = new STMTHEAP - SQLDoublePrecisionTdm(desiredType.supportsSQLnull(), - STMTHEAP, - desiredType.getPrecision()); - } + if (desiredType.getFSDatatype() == REC_FLOAT32) + newType = new STMTHEAP + SQLReal(desiredType.supportsSQLnull(), + STMTHEAP, + desiredType.getPrecision()); else - { - if (desiredType.getFSDatatype() == REC_FLOAT32) - newType = new STMTHEAP - SQLReal(desiredType.supportsSQLnull(), - STMTHEAP, - desiredType.getPrecision()); - else - // ieee double, tandem real and tandem double are all - // cast as IEEE double. Tandem real is cast as ieee double as - // it won't 'fit' into ieee real. - newType = new STMTHEAP - SQLDoublePrecision(desiredType.supportsSQLnull(), - STMTHEAP, - desiredType.getPrecision()); - } - + // ieee double, tandem real and tandem double are all + // cast as IEEE double. Tandem real is cast as ieee double as + // it won't 'fit' into ieee real. + newType = new STMTHEAP + SQLDoublePrecision(desiredType.supportsSQLnull(), + STMTHEAP, + desiredType.getPrecision()); } else { if ( newType == NULL ) { - if (DFS2REC::isBigNum(desiredType.getFSDatatype())) + // if param default is OFF, type tinyint as smallint. + // This is needed until all callers/drivers have full support to + // handle IO of tinyint datatypes. + if ((desiredType.getTypeName() == LiteralTinyInt) && + ((CmpCommon::getDefault(TRAF_TINYINT_SUPPORT) == DF_OFF) || + (CmpCommon::getDefault(TRAF_TINYINT_INPUT_PARAMS) == DF_OFF))) + { + NABoolean isSigned = ((NumericType&)desiredType).isSigned(); + newType = new (STMTHEAP) + SQLSmall(isSigned, desiredType.supportsSQLnull()); + } // TinyInt + else if (DFS2REC::isBigNum(desiredType.getFSDatatype())) { // If bignum IO is not enabled or // if max numeric precision allowed is what is supported in http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/parser/ParKeyWords.cpp ---------------------------------------------------------------------- diff --git a/core/sql/parser/ParKeyWords.cpp b/core/sql/parser/ParKeyWords.cpp index 20c2ed7..fee890f 100644 --- a/core/sql/parser/ParKeyWords.cpp +++ b/core/sql/parser/ParKeyWords.cpp @@ -359,7 +359,6 @@ ParKeyWord ParKeyWords::keyWords_[] = { ParKeyWord("DOMAIN", IDENTIFIER, ANS_|RESWORD_), ParKeyWord("DOUBLE", TOK_DOUBLE, ANS_|RESWORD_|NONRESTOKEN_), ParKeyWord("DOUBLE_IEEE", TOK_DOUBLE_IEEE, NONRESTOKEN_), - ParKeyWord("DOUBLE_TANDEM", TOK_DOUBLE_TANDEM, NONRESTOKEN_), ParKeyWord("DROP", TOK_DROP, ANS_|RESWORD_), ParKeyWord("DROPPABLE", TOK_DROPPABLE, SECOND_|NONRESTOKEN_), ParKeyWord("DROP_LIBRARY", TOK_DROP_LIBRARY, NONRESTOKEN_), @@ -437,7 +436,6 @@ ParKeyWord ParKeyWords::keyWords_[] = { ParKeyWord("FIXED", TOK_FIXED, NONRESTOKEN_), ParKeyWord("FLOAT", TOK_FLOAT, ANS_|RESWORD_|NONRESTOKEN_), ParKeyWord("FLOAT_IEEE", TOK_FLOAT_IEEE, NONRESTOKEN_), - ParKeyWord("FLOAT_TANDEM", TOK_FLOAT_TANDEM, NONRESTOKEN_), ParKeyWord("FLOOR", TOK_FLOOR, NONRESTOKEN_), ParKeyWord("FN", TOK_FN, NONRESTOKEN_), ParKeyWord("FOLLOWING", TOK_FOLLOWING, NONRESTOKEN_), @@ -845,7 +843,6 @@ ParKeyWord ParKeyWords::keyWords_[] = { ParKeyWord("READS", TOK_READS, COMPAQ_|RESWORD_), ParKeyWord("REAL", TOK_REAL, ANS_|RESWORD_|NONRESTOKEN_), ParKeyWord("REAL_IEEE", TOK_REAL_IEEE, NONRESTOKEN_), - ParKeyWord("REAL_TANDEM", TOK_REAL_TANDEM, NONRESTOKEN_), ParKeyWord("REBUILD", TOK_REBUILD, NONRESTOKEN_), ParKeyWord("RECOMPUTE", TOK_RECOMPUTE, FLAGSNONE_), ParKeyWord("RECORD_SEPARATOR", TOK_RECORD_SEPARATOR, NONRESTOKEN_), http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/parser/sqlparser.y ---------------------------------------------------------------------- diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y index 6466bdd..5d2677c 100755 --- a/core/sql/parser/sqlparser.y +++ b/core/sql/parser/sqlparser.y @@ -627,7 +627,6 @@ static void enableMakeQuotedStringISO88591Mechanism() %token <tokval> TOK_DOT_STAR %token <tokval> TOK_DOUBLE %token <tokval> TOK_DOUBLE_IEEE -%token <tokval> TOK_DOUBLE_TANDEM %token <tokval> TOK_DUPLICATE %token <tokval> TOK_DYNAMIC %token <tokval> TOK_DYNAMIC_FUNCTION /* ANSI SQL non-reserved word */ @@ -675,7 +674,6 @@ static void enableMakeQuotedStringISO88591Mechanism() %token <tokval> TOK_FIRST_FSCODE %token <tokval> TOK_FLOAT %token <tokval> TOK_FLOAT_IEEE -%token <tokval> TOK_FLOAT_TANDEM %token <tokval> TOK_FLOOR %token <tokval> TOK_FN /* ODBC extension non-reserved word */ %token <tokval> TOK_FOLLOWING @@ -964,7 +962,6 @@ static void enableMakeQuotedStringISO88591Mechanism() %token <tokval> TOK_READ %token <tokval> TOK_REAL %token <tokval> TOK_REAL_IEEE -%token <tokval> TOK_REAL_TANDEM %token <tokval> TOK_RECOMPUTE %token <tokval> TOK_RECORD_SEPARATOR %token <tokval> TOK_RECOVER @@ -2014,6 +2011,7 @@ static void enableMakeQuotedStringISO88591Mechanism() %type <na_type> proc_arg_data_type %type <na_type> data_type %type <na_type> Set_Cast_Global_False_and_data_type +%type <na_type> routine_predef_type %type <na_type> predef_type %type <na_type> predefined_type %type <na_type> date_time_type @@ -10613,7 +10611,10 @@ int_type : TOK_INTEGER signed_option { // odbc SQL_TINYINT is exact numeric value with precision 3 & // scale 0. signed: -128<=n<=127, unsigned: 0<=n<=255. - $$ = new (PARSERHEAP()) SQLSmall( $2, TRUE); + if (CmpCommon::getDefault(TRAF_TINYINT_SUPPORT) == DF_OFF) + $$ = new (PARSERHEAP()) SQLSmall( $2, TRUE); + else + $$ = new (PARSERHEAP()) SQLTiny( $2, TRUE); // ((SQLSmall *)$$)->setDisplayDataType("TINYINT"); } | TOK_BYTEINT signed_option @@ -10865,34 +10866,14 @@ proc_arg_float_type : TOK_FLOAT_IEEE { $$ = new (PARSERHEAP()) SQLDoublePrecision(TRUE, PARSERHEAP(), 0); } - | TOK_FLOAT_TANDEM - { - $$ = new (PARSERHEAP()) SQLDoublePrecisionTdm(TRUE, PARSERHEAP(), 0); - } - | TOK_FLOAT_TANDEM left_unsigned_right - { -#pragma nowarn(1506) // warning elimination - $$ = new (PARSERHEAP()) SQLDoublePrecisionTdm(TRUE, NULL, $2); -#pragma warn(1506) // warning elimination - if (! ((SQLDoublePrecision *)$$)->checkValid(SqlParser_Diags)) - YYERROR; - } - | TOK_REAL_TANDEM - { - $$ = new (PARSERHEAP()) SQLRealTdm(TRUE, PARSERHEAP(), 0); - } - | TOK_DOUBLE_TANDEM - { - $$ = new (PARSERHEAP()) SQLDoublePrecisionTdm(TRUE, PARSERHEAP(), 0); - } | TOK_FLOAT { - $$ = new (PARSERHEAP()) SQLDoublePrecisionTdm(TRUE, PARSERHEAP(), 0); + $$ = new (PARSERHEAP()) SQLDoublePrecision(TRUE, PARSERHEAP(), 0); } | TOK_FLOAT left_unsigned_right { #pragma nowarn(1506) // warning elimination - $$ = new (PARSERHEAP()) SQLDoublePrecisionTdm(TRUE, NULL, $2); + $$ = new (PARSERHEAP()) SQLDoublePrecision(TRUE, NULL, $2); #pragma warn(1506) // warning elimination if (! ((SQLDoublePrecision *)$$)->checkValid(SqlParser_Diags)) YYERROR; @@ -23876,7 +23857,7 @@ routine_return_param_list : routine_return_param_optional_not_null } /* type pElemDDL */ -routine_return_param : optional_return_param_mode optional_param_name predef_type +routine_return_param : optional_return_param_mode optional_param_name routine_predef_type { ElemDDLParamDef *p = new (PARSERHEAP()) ElemDDLParamDef($3 /*predef_type*/, @@ -23891,7 +23872,7 @@ routine_return_param : optional_return_param_mode optional_param_name predef_typ routine_return_param_optional_not_null : optional_return_param_mode optional_param_name - predef_type + routine_predef_type optional_cast_spec_not_null_spec { ElemDDLParamDef *p = new (PARSERHEAP()) @@ -24018,7 +23999,7 @@ routine_params : routine_param } /* type pElemDDL */ -routine_param : optional_param_mode optional_param_name predef_type +routine_param : optional_param_mode optional_param_name routine_predef_type optional_cast_spec_not_null_spec { if ($4) @@ -24032,6 +24013,19 @@ routine_param : optional_param_mode optional_param_name predef_type delete $2 /*optional_param_name*/; } +/* type na_type */ +routine_predef_type : predef_type + { + if (($1->getTypeName() == LiteralTinyInt) && + ((CmpCommon::getDefault(TRAF_TINYINT_SUPPORT) == DF_OFF) || + (CmpCommon::getDefault(TRAF_TINYINT_SPJ_SUPPORT) == DF_OFF))) + { + NumericType * nt = (NumericType*)$1; + $$ = new (PARSERHEAP()) + SQLSmall(NOT nt->isUnsigned(), $1->supportsSQLnull()); + } + } + /* type pElemDDLParamName */ optional_param_name : empty { @@ -32824,7 +32818,6 @@ nonreserved_word : TOK_ABORT | TOK_DIVISION | TOK_DO | TOK_DOUBLE_IEEE - | TOK_DOUBLE_TANDEM | TOK_DROP_LIBRARY | TOK_DROP_MV | TOK_DROP_MV_GROUP @@ -32867,7 +32860,6 @@ nonreserved_word : TOK_ABORT | TOK_FINAL | TOK_FIRST_FSCODE | TOK_FLOAT_IEEE - | TOK_FLOAT_TANDEM | TOK_FOLLOWING | TOK_FOR_MAXRUNTIME | TOK_FORMAT @@ -33079,7 +33071,6 @@ nonreserved_word : TOK_ABORT | TOK_RANGELOG // MV | TOK_RATE | TOK_REAL_IEEE - | TOK_REAL_TANDEM | TOK_REBUILD | TOK_RECOMPUTE // MV | TOK_RECORD_SEPARATOR http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/regress/executor/EXPECTED022.SB ---------------------------------------------------------------------- diff --git a/core/sql/regress/executor/EXPECTED022.SB b/core/sql/regress/executor/EXPECTED022.SB index cbe4b2f..3b30a0e 100644 --- a/core/sql/regress/executor/EXPECTED022.SB +++ b/core/sql/regress/executor/EXPECTED022.SB @@ -371,6 +371,63 @@ --- 1 row(s) selected. >> +>>select cast (10 as tinyint) from t022t1; + +(EXPR) +------ + + 10 + +--- 1 row(s) selected. +>>select cast (-10 as tinyint) from t022t1; + +(EXPR) +------ + + -10 + +--- 1 row(s) selected. +>>select cast (127 as tinyint) from t022t1; + +(EXPR) +------ + + 127 + +--- 1 row(s) selected. +>>select cast (-128 as tinyint) from t022t1; + +(EXPR) +------ + + -128 + +--- 1 row(s) selected. +>>select cast (10 as tinyint unsigned) from t022t1; + +(EXPR) +------ + + 10 + +--- 1 row(s) selected. +>>select cast (0 as tinyint unsigned) from t022t1; + +(EXPR) +------ + + 0 + +--- 1 row(s) selected. +>>select cast (255 as tinyint unsigned) from t022t1; + +(EXPR) +------ + + 255 + +--- 1 row(s) selected. +>> >>select cast (date'12/31/9999' as timestamp(3)) from t022t1; (EXPR) @@ -1254,34 +1311,6 @@ A B C --- 1 row(s) selected. >> ->>-- Floating point results are different depending on whether you are ->>-- running on NSK (Tandem floating point) or NT (IEEE floating point) ->>?ifNSK ->>select cast (-32769 as real) from t022t1; ->>select cast (32768 as real) from t022t1; ->>select cast (-10 as real) from t022t1; ->>select cast (10 as real) from t022t1; ->>select cast (-1 as real) from t022t1; ->>select cast (65536 as real) from t022t1; ->>select cast (-2147483649 as real) from t022t1; ->>select cast (9999999999 as real) from t022t1; ->>select cast (-100000 as real) from t022t1; ->>select cast (100000 as real) from t022t1; ->>select cast (9999999999 as real) from t022t1; ->> ->>select cast (-32769 as double precision) from t022t1; ->>select cast (32768 as double precision) from t022t1; ->>select cast (-10 as double precision) from t022t1; ->>select cast (10 as double precision) from t022t1; ->>select cast (-1 as double precision) from t022t1; ->>select cast (65536 as double precision) from t022t1; ->>select cast (-2147483649 as double precision) from t022t1; ->>select cast (2147483648 as double precision) from t022t1; ->>select cast (-100000 as double precision) from t022t1; ->>select cast (100000 as double precision) from t022t1; ->>select cast (4294967296 as double precision) from t022t1; ->>?ifNSK ->>?ifNT >>select cast (-32769 as real) from t022t1; (EXPR) @@ -1459,7 +1488,6 @@ A B C 4.29496729600000000E+009 --- 1 row(s) selected. ->>?ifNT >> >>select cast ('Hello, world!' as char(13)) from t022t2; @@ -2297,6 +2325,28 @@ Hello --- 0 row(s) selected. >> +>>-- negative tests for tinyint +>>select cast(-129 as tinyint) from t022t1; + +*** ERROR[8411] A numeric overflow occurred during an arithmetic computation or data conversion. Conversion of Source Type:SMALLINT SIGNED(REC_BIN16_SIGNED) Source Value:-129 to Target Type:TINYINT SIGNED(REC_BIN8_SIGNED). + +--- 0 row(s) selected. +>>select cast(128 as tinyint) from t022t1; + +*** ERROR[8411] A numeric overflow occurred during an arithmetic computation or data conversion. Conversion of Source Type:SMALLINT SIGNED(REC_BIN16_SIGNED) Source Value:128 to Target Type:TINYINT SIGNED(REC_BIN8_SIGNED). + +--- 0 row(s) selected. +>>select cast(256 as tinyint unsigned) from t022t1; + +*** ERROR[8411] A numeric overflow occurred during an arithmetic computation or data conversion. Conversion of Source Type:SMALLINT SIGNED(REC_BIN16_SIGNED) Source Value:256 to Target Type:TINYINT UNSIGNED(REC_BIN8_UNSIGNED). + +--- 0 row(s) selected. +>>select cast(-1 as tinyint unsigned) from t022t1; + +*** ERROR[8432] A negative value cannot be converted to an unsigned numeric datatype. + +--- 0 row(s) selected. +>> >>-- tests for DATE, TIME, TIMESTAMP >>select cast ('12.07.1961 03.04.55.123456' as timestamp) from t022t2; @@ -2501,13 +2551,6 @@ Hello --- 0 row(s) selected. >> ->>-- Floating point results are different depending on whether you are ->>-- running on NSK (Tandem floating point) or NT (IEEE floating point) ->>?ifNSK ->>-- results: 0 rows selected ->>select cast('66.2' as float) from t022t1 where cast('66.2' as float) = 66.2; ->>?ifNSK ->>?ifNT >>-- results: 1 row selected >>select cast('66.2' as float) from t022t1 where cast('66.2' as float) = 66.2; @@ -2517,7 +2560,6 @@ Hello 6.62000000000000128E+001 --- 1 row(s) selected. ->>?ifNT >> >>-- to test comparisons between signed and unsigned numbers. >> @@ -4219,7 +4261,7 @@ Hello (EXPR) (EXPR) (EXPR) ------------- ------------- -------------------------- -10:13:14.0000 10:13:14.0000 2016-02-19 15:24:29.239482 +10:13:14.0000 10:13:14.0000 2016-06-11 16:50:13.692785 --- 1 row(s) selected. >>--test on precision of time @@ -4424,11 +4466,6 @@ float access 1.1754943E-038 2.22507385850720128E-308 --- 5 row(s) selected. >> ->>-- This CQD is required, otherwise TANDEM float will show up in showplan ->>control query default FLOATTYPE 'IEEE'; - ---- SQL operation complete. ->> >>-- Start the basic tests >>-- New PCode instructions for FLOAT64 and FLOAT32: GT and LE >>select c1 - 20.00, c2 + 20.00 from t022fltcmp where c1 > 10.02 and c2 <= >>30.02; @@ -5104,6 +5141,63 @@ lkjihgfedc ? ? --- 1 row(s) selected. >> +>>select cast (10 as tinyint) from t022t1; + +(EXPR) +------ + + 10 + +--- 1 row(s) selected. +>>select cast (-10 as tinyint) from t022t1; + +(EXPR) +------ + + -10 + +--- 1 row(s) selected. +>>select cast (127 as tinyint) from t022t1; + +(EXPR) +------ + + 127 + +--- 1 row(s) selected. +>>select cast (-128 as tinyint) from t022t1; + +(EXPR) +------ + + -128 + +--- 1 row(s) selected. +>>select cast (10 as tinyint unsigned) from t022t1; + +(EXPR) +------ + + 10 + +--- 1 row(s) selected. +>>select cast (0 as tinyint unsigned) from t022t1; + +(EXPR) +------ + + 0 + +--- 1 row(s) selected. +>>select cast (255 as tinyint unsigned) from t022t1; + +(EXPR) +------ + + 255 + +--- 1 row(s) selected. +>> >>select cast (date'12/31/9999' as timestamp(3)) from t022t1; (EXPR) @@ -5987,34 +6081,6 @@ A B C --- 1 row(s) selected. >> ->>-- Floating point results are different depending on whether you are ->>-- running on NSK (Tandem floating point) or NT (IEEE floating point) ->>?ifNSK ->>select cast (-32769 as real) from t022t1; ->>select cast (32768 as real) from t022t1; ->>select cast (-10 as real) from t022t1; ->>select cast (10 as real) from t022t1; ->>select cast (-1 as real) from t022t1; ->>select cast (65536 as real) from t022t1; ->>select cast (-2147483649 as real) from t022t1; ->>select cast (9999999999 as real) from t022t1; ->>select cast (-100000 as real) from t022t1; ->>select cast (100000 as real) from t022t1; ->>select cast (9999999999 as real) from t022t1; ->> ->>select cast (-32769 as double precision) from t022t1; ->>select cast (32768 as double precision) from t022t1; ->>select cast (-10 as double precision) from t022t1; ->>select cast (10 as double precision) from t022t1; ->>select cast (-1 as double precision) from t022t1; ->>select cast (65536 as double precision) from t022t1; ->>select cast (-2147483649 as double precision) from t022t1; ->>select cast (2147483648 as double precision) from t022t1; ->>select cast (-100000 as double precision) from t022t1; ->>select cast (100000 as double precision) from t022t1; ->>select cast (4294967296 as double precision) from t022t1; ->>?ifNSK ->>?ifNT >>select cast (-32769 as real) from t022t1; (EXPR) @@ -6192,7 +6258,6 @@ A B C 4.29496729600000000E+009 --- 1 row(s) selected. ->>?ifNT >> >>select cast ('Hello, world!' as char(13)) from t022t2; @@ -7030,6 +7095,28 @@ Hello --- 0 row(s) selected. >> +>>-- negative tests for tinyint +>>select cast(-129 as tinyint) from t022t1; + +*** ERROR[8411] A numeric overflow occurred during an arithmetic computation or data conversion. Conversion of Source Type:SMALLINT SIGNED(REC_BIN16_SIGNED) Source Value:-129 to Target Type:TINYINT SIGNED(REC_BIN8_SIGNED). + +--- 0 row(s) selected. +>>select cast(128 as tinyint) from t022t1; + +*** ERROR[8411] A numeric overflow occurred during an arithmetic computation or data conversion. Conversion of Source Type:SMALLINT SIGNED(REC_BIN16_SIGNED) Source Value:128 to Target Type:TINYINT SIGNED(REC_BIN8_SIGNED). + +--- 0 row(s) selected. +>>select cast(256 as tinyint unsigned) from t022t1; + +*** ERROR[8411] A numeric overflow occurred during an arithmetic computation or data conversion. Conversion of Source Type:SMALLINT SIGNED(REC_BIN16_SIGNED) Source Value:256 to Target Type:TINYINT UNSIGNED(REC_BIN8_UNSIGNED). + +--- 0 row(s) selected. +>>select cast(-1 as tinyint unsigned) from t022t1; + +*** ERROR[8432] A negative value cannot be converted to an unsigned numeric datatype. + +--- 0 row(s) selected. +>> >>-- tests for DATE, TIME, TIMESTAMP >>select cast ('12.07.1961 03.04.55.123456' as timestamp) from t022t2; @@ -7234,13 +7321,6 @@ Hello --- 0 row(s) selected. >> ->>-- Floating point results are different depending on whether you are ->>-- running on NSK (Tandem floating point) or NT (IEEE floating point) ->>?ifNSK ->>-- results: 0 rows selected ->>select cast('66.2' as float) from t022t1 where cast('66.2' as float) = 66.2; ->>?ifNSK ->>?ifNT >>-- results: 1 row selected >>select cast('66.2' as float) from t022t1 where cast('66.2' as float) = 66.2; @@ -7250,7 +7330,6 @@ Hello 6.62000000000000128E+001 --- 1 row(s) selected. ->>?ifNT >> >>-- to test comparisons between signed and unsigned numbers. >> @@ -8952,7 +9031,7 @@ Hello (EXPR) (EXPR) (EXPR) ------------- ------------- -------------------------- -10:13:14.0000 10:13:14.0000 2016-02-19 15:26:59.794585 +10:13:14.0000 10:13:14.0000 2016-06-11 16:52:59.057377 --- 1 row(s) selected. >>--test on precision of time @@ -9157,11 +9236,6 @@ float access 1.1754943E-038 2.22507385850720128E-308 --- 5 row(s) selected. >> ->>-- This CQD is required, otherwise TANDEM float will show up in showplan ->>control query default FLOATTYPE 'IEEE'; - ---- SQL operation complete. ->> >>-- Start the basic tests >>-- New PCode instructions for FLOAT64 and FLOAT32: GT and LE >>select c1 - 20.00, c2 + 20.00 from t022fltcmp where c1 > 10.02 and c2 <= >>30.02; http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/regress/executor/TEST022 ---------------------------------------------------------------------- diff --git a/core/sql/regress/executor/TEST022 b/core/sql/regress/executor/TEST022 index 9628cee..bf517de 100755 --- a/core/sql/regress/executor/TEST022 +++ b/core/sql/regress/executor/TEST022 @@ -165,6 +165,14 @@ select cast (9 as decimal(1) unsigned) from t022t1; select cast (0 as decimal(9) unsigned) from t022t1; select cast (999999999 as decimal(9) unsigned) from t022t1; +select cast (10 as tinyint) from t022t1; +select cast (-10 as tinyint) from t022t1; +select cast (127 as tinyint) from t022t1; +select cast (-128 as tinyint) from t022t1; +select cast (10 as tinyint unsigned) from t022t1; +select cast (0 as tinyint unsigned) from t022t1; +select cast (255 as tinyint unsigned) from t022t1; + select cast (date'12/31/9999' as timestamp(3)) from t022t1; select cast (timestamp'12/31/9999 11:59:59.999999 pm' as date) from t022t1; select cast (timestamp'12/31/9999 11:59:59.999999 pm' as time(3)) from t022t1; @@ -301,9 +309,6 @@ select cast (10 as decimal(2) unsigned) from t022t1; select cast (65536 as decimal(5) unsigned) from t022t1; select cast (100000 as decimal(6) unsigned) from t022t1; --- Floating point results are different depending on whether you are --- running on NSK (Tandem floating point) or NT (IEEE floating point) -?ifNSK select cast (-32769 as real) from t022t1; select cast (32768 as real) from t022t1; select cast (-10 as real) from t022t1; @@ -327,32 +332,6 @@ select cast (2147483648 as double precision) from t022t1; select cast (-100000 as double precision) from t022t1; select cast (100000 as double precision) from t022t1; select cast (4294967296 as double precision) from t022t1; -?ifNSK -?ifNT -select cast (-32769 as real) from t022t1; -select cast (32768 as real) from t022t1; -select cast (-10 as real) from t022t1; -select cast (10 as real) from t022t1; -select cast (-1 as real) from t022t1; -select cast (65536 as real) from t022t1; -select cast (-2147483649 as real) from t022t1; -select cast (9999999999 as real) from t022t1; -select cast (-100000 as real) from t022t1; -select cast (100000 as real) from t022t1; -select cast (9999999999 as real) from t022t1; - -select cast (-32769 as double precision) from t022t1; -select cast (32768 as double precision) from t022t1; -select cast (-10 as double precision) from t022t1; -select cast (10 as double precision) from t022t1; -select cast (-1 as double precision) from t022t1; -select cast (65536 as double precision) from t022t1; -select cast (-2147483649 as double precision) from t022t1; -select cast (2147483648 as double precision) from t022t1; -select cast (-100000 as double precision) from t022t1; -select cast (100000 as double precision) from t022t1; -select cast (4294967296 as double precision) from t022t1; -?ifNT select cast ('Hello, world!' as char(13)) from t022t2; select cast ('Hello, world!' as varchar(13)) from t022t2; @@ -519,6 +498,12 @@ select cast (cast (10 as double precision) as decimal(1)) from t022t1; select cast (cast (-1 as double precision) as decimal(1) unsigned) from t022t1; select cast (cast (10 as double precision) as decimal(1) unsigned) from t022t1; +-- negative tests for tinyint +select cast(-129 as tinyint) from t022t1; +select cast(128 as tinyint) from t022t1; +select cast(256 as tinyint unsigned) from t022t1; +select cast(-1 as tinyint unsigned) from t022t1; + -- tests for DATE, TIME, TIMESTAMP select cast ('12.07.1961 03.04.55.123456' as timestamp) from t022t2; select cast ('12.07.1961 03.04.55.123456' as timestamp(3)) from t022t2; @@ -575,16 +560,8 @@ select cast (1 as numeric(9) unsigned) / select cast (1 as double precision) / cast (0 as double precision) from t022t1; --- Floating point results are different depending on whether you are --- running on NSK (Tandem floating point) or NT (IEEE floating point) -?ifNSK --- results: 0 rows selected -select cast('66.2' as float) from t022t1 where cast('66.2' as float) = 66.2; -?ifNSK -?ifNT -- results: 1 row selected select cast('66.2' as float) from t022t1 where cast('66.2' as float) = 66.2; -?ifNT -- to test comparisons between signed and unsigned numbers. @@ -1155,9 +1132,6 @@ insert into t022fltcmp values('float access', 1.17549436e-38, select * from t022fltcmp; --- This CQD is required, otherwise TANDEM float will show up in showplan -control query default FLOATTYPE 'IEEE'; - -- Start the basic tests -- New PCode instructions for FLOAT64 and FLOAT32: GT and LE select c1 - 20.00, c2 + 20.00 from t022fltcmp where c1 > 10.02 and c2 <= 30.02; http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/regress/hive/EXPECTED005 ---------------------------------------------------------------------- diff --git a/core/sql/regress/hive/EXPECTED005 b/core/sql/regress/hive/EXPECTED005 index 0c505e3..7e59185 100644 --- a/core/sql/regress/hive/EXPECTED005 +++ b/core/sql/regress/hive/EXPECTED005 @@ -436,7 +436,7 @@ ID CHAPTER ENGLISH TRANSLATOR TINT SM I BIG STR F D T DT VC ------ ------ ----------- -------------------- ------------------------- --------------- ------------------------- -------------------------- ---------- ---------- - 201 202 203 204 two hundred 2.0000000E+002 2.00000000000000000E+002 2022-02-02 22:22:22.222222 2022-02-02 varchar + 101 202 203 204 two hundred 2.0000000E+002 2.00000000000000000E+002 2022-02-02 22:22:22.222222 2022-02-02 varchar --- 1 row(s) selected. >>insert into tbl_type_temp select * from tbl_type; @@ -447,7 +447,7 @@ TINT SM I BIG STR F TINT SM I BIG STR F D T DT VC ------ ------ ----------- -------------------- ------------------------- --------------- ------------------------- -------------------------- ---------- ---------- - 201 202 203 204 two hundred 2.0000000E+002 2.00000000000000000E+002 2022-02-02 22:22:22.222222 2022-02-02 varchar + 101 202 203 204 two hundred 2.0000000E+002 2.00000000000000000E+002 2022-02-02 22:22:22.222222 2022-02-02 varchar --- 1 row(s) selected. >> @@ -555,7 +555,7 @@ C1 C2 C3 C4 C ? ? c ? ? 2017-01-01 10:10:10.000000 1.01000000000000000E+000 1 ? ? ? ? ? ? ? 1 1 averylongstring -1.0000000E+000 0 2017-01-01 10:10:10.000000 1.00010000000000000E+002 1 - 2 2 good 1.1000000E+000 2 2017-01-01 10:10:10.000000 2.00000000000000000E+002 1000 + 2 2 good 1.1000000E+000 2 2017-01-01 10:10:10.000000 2.00000000000000000E+002 100 3 3 good 1.0000000E+000 2 2017-01-01 10:10:10.000000 2.10000000000000000E+002 10 ? 4294967295 good 3.3999999E+038 ? 2017-01-01 10:10:10.000000 1.69999999999999968E+308 10 0 9999999999 bad ? ? ? ? ? http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/regress/hive/tbl_bad.data ---------------------------------------------------------------------- diff --git a/core/sql/regress/hive/tbl_bad.data b/core/sql/regress/hive/tbl_bad.data index b2f3a4c..36f8f5d 100644 --- a/core/sql/regress/hive/tbl_bad.data +++ b/core/sql/regress/hive/tbl_bad.data @@ -2,7 +2,7 @@ a|b|c|d|e|f|g| a||c| |e|2017-01-01 10:10:10|1.01|1 | | | | | | | 1|1|averylongstring|-1|0|2017-01-01 10:10:10.000|100.01|1 -2|2|good|1.1|2|2017-01-01 10:10:10.000000|2E+002|1000 +2|2|good|1.1|2|2017-01-01 10:10:10.000000|2E+002|100 3|3|good|1|2|2017-01-01 10:10:10|2.1E+002|10 4294967295|4294967295|good|3.40E+038|65535|2017-01-01 10:10:10|1.7E+308|10 0|9999999999|bad|4.0E+038|65536|2017-15-01 10:10:10|2.1E+309|65537 http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/regress/hive/tbl_type.data ---------------------------------------------------------------------- diff --git a/core/sql/regress/hive/tbl_type.data b/core/sql/regress/hive/tbl_type.data index c780fb3..99c4827 100644 --- a/core/sql/regress/hive/tbl_type.data +++ b/core/sql/regress/hive/tbl_type.data @@ -1 +1 @@ -201|202|203|204|two hundred|2E2|2E+002|2022-02-02 22:22:22.222222|2022-02-02|varchar +101|202|203|204|two hundred|2E2|2E+002|2022-02-02 22:22:22.222222|2022-02-02|varchar http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/regress/seabase/EXPECTED003 ---------------------------------------------------------------------- diff --git a/core/sql/regress/seabase/EXPECTED003 b/core/sql/regress/seabase/EXPECTED003 new file mode 100644 index 0000000..16ca7b0 --- /dev/null +++ b/core/sql/regress/seabase/EXPECTED003 @@ -0,0 +1,425 @@ +>> +>>cqd traf_tinyint_support 'ON'; + +--- SQL operation complete. +>>cqd traf_tinyint_return_values 'ON'; + +--- SQL operation complete. +>>cqd traf_tinyint_input_params 'ON'; + +--- SQL operation complete. +>> +>>obey TEST003(setup); +>>create table t003t1(a tinyint not null primary key, b tinyint, ++> c tinyint unsigned default 10 not null, d tinyint unsigned); + +--- SQL operation complete. +>>invoke t003t1; + +-- Definition of Trafodion table TRAFODION.SCH.T003T1 +-- Definition current Tue Jun 14 17:33:52 2016 + + ( + A TINYINT NO DEFAULT NOT NULL NOT DROPPABLE + , B TINYINT DEFAULT NULL + , C TINYINT UNSIGNED DEFAULT 10 NOT NULL NOT + DROPPABLE + , D TINYINT UNSIGNED DEFAULT NULL + ) + PRIMARY KEY (A ASC) + +--- SQL operation complete. +>> +>>create table t003t1_like like t003t1; + +--- SQL operation complete. +>>invoke t003t1_like; + +-- Definition of Trafodion table TRAFODION.SCH.T003T1_LIKE +-- Definition current Tue Jun 14 17:34:00 2016 + + ( + A TINYINT NO DEFAULT NOT NULL NOT DROPPABLE + , B TINYINT DEFAULT NULL + , C TINYINT UNSIGNED DEFAULT 10 NOT NULL NOT + DROPPABLE + , D TINYINT UNSIGNED DEFAULT NULL + ) + PRIMARY KEY (A ASC) + +--- SQL operation complete. +>> +>>create table t003t1_as as select * from t003t1; + +--- 0 row(s) inserted. +>>invoke t003t1_as; + +-- Definition of Trafodion table TRAFODION.SCH.T003T1_AS +-- Definition current Tue Jun 14 17:34:03 2016 + + ( + SYSKEY LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE + , A TINYINT NO DEFAULT NOT NULL NOT DROPPABLE + , B TINYINT DEFAULT NULL + , C TINYINT UNSIGNED NO DEFAULT NOT NULL NOT + DROPPABLE + , D TINYINT UNSIGNED DEFAULT NULL + ) + +--- SQL operation complete. +>> +>>obey TEST003(dml); +>>insert into t003t1 values (1, 2, 3, 4); + +--- 1 row(s) inserted. +>>insert into t003t1 values (-1, -2, 255, 255); + +--- 1 row(s) inserted. +>>insert into t003t1 values (-128, 127, 0, 0); + +--- 1 row(s) inserted. +>> +>>select * from t003t1; + +A B C D +---- ---- --- --- + +-128 127 0 0 + -1 -2 255 255 + 1 2 3 4 + +--- 3 row(s) selected. +>> +>>insert into t003t1_as select * from t003t1; + +--- 3 row(s) inserted. +>>select * from t003t1_as; + +A B C D +---- ---- --- --- + +-128 127 0 0 + -1 -2 255 255 + 1 2 3 4 + +--- 3 row(s) selected. +>> +>>select * from t003t1 where a = 1; + +A B C D +---- ---- --- --- + + 1 2 3 4 + +--- 1 row(s) selected. +>>select * from t003t1 where a = -1; + +A B C D +---- ---- --- --- + + -1 -2 255 255 + +--- 1 row(s) selected. +>>select * from t003t1 where a < 1; + +A B C D +---- ---- --- --- + +-128 127 0 0 + -1 -2 255 255 + +--- 2 row(s) selected. +>>select * from t003t1 where a <= -1; + +A B C D +---- ---- --- --- + +-128 127 0 0 + -1 -2 255 255 + +--- 2 row(s) selected. +>>select * from t003t1 where a < 1000; + +A B C D +---- ---- --- --- + +-128 127 0 0 + -1 -2 255 255 + 1 2 3 4 + +--- 3 row(s) selected. +>>select * from t003t1 where a > -1000; + +A B C D +---- ---- --- --- + +-128 127 0 0 + -1 -2 255 255 + 1 2 3 4 + +--- 3 row(s) selected. +>> +>>select * from t003t1 where d = 4; + +A B C D +---- ---- --- --- + + 1 2 3 4 + +--- 1 row(s) selected. +>>select * from t003t1 where d < -1; + +--- 0 row(s) selected. +>>select * from t003t1 where d < 1000; + +A B C D +---- ---- --- --- + +-128 127 0 0 + -1 -2 255 255 + 1 2 3 4 + +--- 3 row(s) selected. +>>select * from t003t1 where d > -1000; + +A B C D +---- ---- --- --- + +-128 127 0 0 + -1 -2 255 255 + 1 2 3 4 + +--- 3 row(s) selected. +>> +>>select a+10 from t003t1 where a = 1 or a = -1; + +(EXPR) +------ + + 9 + 11 + +--- 2 row(s) selected. +>> +>>select cast(100 as tinyint unsigned) from (values(1)) x(a); + +(EXPR) +------ + + 100 + +--- 1 row(s) selected. +>>select cast(-100 as tinyint) from (values(1)) x(a); + +(EXPR) +------ + + -100 + +--- 1 row(s) selected. +>> +>>select cast(a as char(10)), cast (b as varchar(11)) from t003t1; + +(EXPR) (EXPR) +---------- ----------- + +-128 127 +-1 -2 +1 2 + +--- 3 row(s) selected. +>> +>>prepare s from insert into t003t1 values (?, ?, ?, ?); + +--- SQL command prepared. +>>execute s using -3, 10, 251, 0; + +--- 1 row(s) inserted. +>>select * from t003t1; + +A B C D +---- ---- --- --- + +-128 127 0 0 + -3 10 251 0 + -1 -2 255 255 + 1 2 3 4 + +--- 4 row(s) selected. +>> +>>begin work; + +--- SQL operation complete. +>>delete from t003t1 where b = -2; + +--- 1 row(s) deleted. +>>select * from t003t1; + +A B C D +---- ---- --- --- + +-128 127 0 0 + -3 10 251 0 + 1 2 3 4 + +--- 3 row(s) selected. +>>rollback work; + +--- SQL operation complete. +>> +>>begin work; + +--- SQL operation complete. +>>update t003t1 set b = b + 1 where b <> 127; + +--- 3 row(s) updated. +>>select * from t003t1; + +A B C D +---- ---- --- --- + +-128 127 0 0 + -3 11 251 0 + -1 -1 255 255 + 1 3 3 4 + +--- 4 row(s) selected. +>>rollback work; + +--- SQL operation complete. +>> +>>obey TEST003(tinyhive); +>>sh echo "drop table ttiny;" > TEST003_junk; +>>sh regrhive.ksh -f TEST003_junk; +>> +>>sh echo "create table ttiny(a tinyint, b tinyint);" > TEST003_junk; +>>sh regrhive.ksh -f TEST003_junk; +>> +>>sh echo "insert into ttiny values (1, -1);" > TEST003_junk; +>>sh regrhive.ksh -f TEST003_junk; +>> +>>invoke hive.hive.ttiny; + +-- Definition of hive table TTINY +-- Definition current Tue Jun 14 17:34:44 2016 + + ( + A TINYINT + , B TINYINT + ) + /* stored as text */ + +--- SQL operation complete. +>>select * from hive.hive.ttiny; + +A B +---- ---- + + 1 -1 + +--- 1 row(s) selected. +>>insert into hive.hive.ttiny values (127, 10), (-128, -50); + +--- 2 row(s) inserted. +>>select * from hive.hive.ttiny; + +A B +---- ---- + + 1 -1 + 127 10 +-128 -50 + +--- 3 row(s) selected. +>>insert overwrite table hive.hive.ttiny select a, b from t003t1; + +--- 4 row(s) inserted. +>>select * from hive.hive.ttiny; + +A B +---- ---- + +-128 127 + -3 10 + -1 -2 + 1 2 + +--- 4 row(s) selected. +>> +>>obey TEST003(errors); +>>update t003t1 set b = b + 1; + +*** ERROR[8411] A numeric overflow occurred during an arithmetic computation or data conversion. Conversion of Source Type:SMALLINT SIGNED(REC_BIN16_SIGNED) Source Value:128 to Target Type:TINYINT SIGNED(REC_BIN8_SIGNED). + +--- 0 row(s) updated. +>> +>>delete from t003t1; + +--- 4 row(s) deleted. +>> +>>insert into t003t1 values (128, 2, 3, 4); + +*** ERROR[8411] A numeric overflow occurred during an arithmetic computation or data conversion. Conversion of Source Type:SMALLINT SIGNED(REC_BIN16_SIGNED) Source Value:128 to Target Type:TINYINT SIGNED(REC_BIN8_SIGNED). + +--- 0 row(s) inserted. +>>insert into t003t1 values (2, -129, 3, 4); + +*** ERROR[8411] A numeric overflow occurred during an arithmetic computation or data conversion. Conversion of Source Type:SMALLINT SIGNED(REC_BIN16_SIGNED) Source Value:-129 to Target Type:TINYINT SIGNED(REC_BIN8_SIGNED). + +--- 0 row(s) inserted. +>>insert into t003t1 values (3, 4, 256, 4); + +*** ERROR[8411] A numeric overflow occurred during an arithmetic computation or data conversion. Conversion of Source Type:SMALLINT SIGNED(REC_BIN16_SIGNED) Source Value:256 to Target Type:TINYINT UNSIGNED(REC_BIN8_UNSIGNED). + +--- 0 row(s) inserted. +>>insert into t003t1 values (4, 4, 256, -4); + +*** ERROR[8411] A numeric overflow occurred during an arithmetic computation or data conversion. Conversion of Source Type:SMALLINT SIGNED(REC_BIN16_SIGNED) Source Value:256 to Target Type:TINYINT UNSIGNED(REC_BIN8_UNSIGNED). + +--- 0 row(s) inserted. +>> +>>select cast(-1 as tinyint unsigned) from (values(1)) x(a); + +*** ERROR[8432] A negative value cannot be converted to an unsigned numeric datatype. + +--- 0 row(s) selected. +>>select cast(256 as tinyint unsigned) from (values(1)) x(a); + +*** ERROR[8411] A numeric overflow occurred during an arithmetic computation or data conversion. Conversion of Source Type:SMALLINT SIGNED(REC_BIN16_SIGNED) Source Value:256 to Target Type:TINYINT UNSIGNED(REC_BIN8_UNSIGNED). + +--- 0 row(s) selected. +>>select cast(-129 as tinyint) from (values(1)) x(a); + +*** ERROR[8411] A numeric overflow occurred during an arithmetic computation or data conversion. Conversion of Source Type:SMALLINT SIGNED(REC_BIN16_SIGNED) Source Value:-129 to Target Type:TINYINT SIGNED(REC_BIN8_SIGNED). + +--- 0 row(s) selected. +>>select cast(128 as tinyint) from (values(1)) x(a); + +*** ERROR[8411] A numeric overflow occurred during an arithmetic computation or data conversion. Conversion of Source Type:SMALLINT SIGNED(REC_BIN16_SIGNED) Source Value:128 to Target Type:TINYINT SIGNED(REC_BIN8_SIGNED). + +--- 0 row(s) selected. +>> +>>prepare s from insert into t003t1 values (?, ?, ?, ?); + +--- SQL command prepared. +>>execute s using 128, 2, 3, 4; + +*** ERROR[8411] A numeric overflow occurred during an arithmetic computation or data conversion. Conversion of Source Type:CHAR(REC_BYTE_F_ASCII) Source Value:0x313238 to Target Type:TINYINT SIGNED(REC_BIN8_SIGNED). + +*** ERROR[15015] PARAM ?(UNNAMED_1) (value 128) cannot be converted to type TINYINT. + +--- 0 row(s) inserted. +>>execute s using 4, 4, 256, -4; + +*** ERROR[8411] A numeric overflow occurred during an arithmetic computation or data conversion. Conversion of Source Type:CHAR(REC_BYTE_F_ASCII) Source Value:0x323536 to Target Type:TINYINT UNSIGNED(REC_BIN8_UNSIGNED). + +*** ERROR[15015] PARAM ?(UNNAMED_3) (value 256) cannot be converted to type TINYINT UNSIGNED. + +*** ERROR[8411] A numeric overflow occurred during an arithmetic computation or data conversion. Conversion of Source Type:CHAR(REC_BYTE_F_ASCII) Source Value:0x2D34 to Target Type:TINYINT UNSIGNED(REC_BIN8_UNSIGNED). + +*** ERROR[15015] PARAM ?(UNNAMED_4) (value -4) cannot be converted to type TINYINT UNSIGNED. + +--- 0 row(s) inserted. +>> +>> +>>log; http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/88ec4fea/core/sql/regress/seabase/TEST003 ---------------------------------------------------------------------- diff --git a/core/sql/regress/seabase/TEST003 b/core/sql/regress/seabase/TEST003 new file mode 100644 index 0000000..f55a6ca --- /dev/null +++ b/core/sql/regress/seabase/TEST003 @@ -0,0 +1,138 @@ +-- @@@ START COPYRIGHT @@@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. +-- +-- @@@ END COPYRIGHT @@@ + +-- Tests for tinyint datatype + + +obey TEST003(clean_up); + +log LOG003 clear; + +cqd traf_tinyint_support 'ON'; +cqd traf_tinyint_return_values 'ON'; +cqd traf_tinyint_input_params 'ON'; + +obey TEST003(setup); +obey TEST003(dml); +obey TEST003(tinyhive); +obey TEST003(errors); +log; +exit; + +?section setup +create table t003t1(a tinyint not null primary key, b tinyint, + c tinyint unsigned default 10 not null, d tinyint unsigned); +invoke t003t1; + +create table t003t1_like like t003t1; +invoke t003t1_like; + +create table t003t1_as as select * from t003t1; +invoke t003t1_as; + +?section dml +insert into t003t1 values (1, 2, 3, 4); +insert into t003t1 values (-1, -2, 255, 255); +insert into t003t1 values (-128, 127, 0, 0); + +select * from t003t1; + +insert into t003t1_as select * from t003t1; +select * from t003t1_as; + +select * from t003t1 where a = 1; +select * from t003t1 where a = -1; +select * from t003t1 where a < 1; +select * from t003t1 where a <= -1; +select * from t003t1 where a < 1000; +select * from t003t1 where a > -1000; + +select * from t003t1 where d = 4; +select * from t003t1 where d < -1; +select * from t003t1 where d < 1000; +select * from t003t1 where d > -1000; + +select a+10 from t003t1 where a = 1 or a = -1; + +select cast(100 as tinyint unsigned) from (values(1)) x(a); +select cast(-100 as tinyint) from (values(1)) x(a); + +select cast(a as char(10)), cast (b as varchar(11)) from t003t1; + +prepare s from insert into t003t1 values (?, ?, ?, ?); +execute s using -3, 10, 251, 0; +select * from t003t1; + +begin work; +delete from t003t1 where b = -2; +select * from t003t1; +rollback work; + +begin work; +update t003t1 set b = b + 1 where b <> 127; +select * from t003t1; +rollback work; + +?section tinyhive +sh echo "drop table ttiny;" > TEST003_junk; +sh regrhive.ksh -f TEST003_junk; + +sh echo "create table ttiny(a tinyint, b tinyint);" > TEST003_junk; +sh regrhive.ksh -f TEST003_junk; + +sh echo "insert into ttiny values (1, -1);" > TEST003_junk; +sh regrhive.ksh -f TEST003_junk; + +invoke hive.hive.ttiny; +select * from hive.hive.ttiny; +insert into hive.hive.ttiny values (127, 10), (-128, -50); +select * from hive.hive.ttiny; +insert overwrite table hive.hive.ttiny select a, b from t003t1; +select * from hive.hive.ttiny; + +?section errors +update t003t1 set b = b + 1; + +delete from t003t1; + +insert into t003t1 values (128, 2, 3, 4); +insert into t003t1 values (2, -129, 3, 4); +insert into t003t1 values (3, 4, 256, 4); +insert into t003t1 values (4, 4, 256, -4); + +select cast(-1 as tinyint unsigned) from (values(1)) x(a); +select cast(256 as tinyint unsigned) from (values(1)) x(a); +select cast(-129 as tinyint) from (values(1)) x(a); +select cast(128 as tinyint) from (values(1)) x(a); + +prepare s from insert into t003t1 values (?, ?, ?, ?); +execute s using 128, 2, 3, 4; +execute s using 4, 4, 256, -4; + + +?section clean_up +drop table t003t1; +drop table t003t1_like; +drop table t003t1_as; + + + +
