diff --git a/dbcon/execplan/calpontsystemcatalog.cpp b/dbcon/execplan/calpontsystemcatalog.cpp index 17e09d857..b7ecfc09a 100644 --- a/dbcon/execplan/calpontsystemcatalog.cpp +++ b/dbcon/execplan/calpontsystemcatalog.cpp @@ -6393,12 +6393,13 @@ boost::any CalpontSystemCatalog::ColType::convertColumnData(const std::string& d } CalpontSystemCatalog::ColType CalpontSystemCatalog::ColType::convertUnionColType( - vector& types) + vector& types, + unsigned int& rc) { idbassert(types.size()); CalpontSystemCatalog::ColType unionedType = types[0]; for (uint64_t i = 1; i < types.size(); i++) - dataconvert::DataConvert::joinColTypeForUnion(unionedType, types[i]); + dataconvert::DataConvert::joinColTypeForUnion(unionedType, types[i], rc); return unionedType; } diff --git a/dbcon/execplan/calpontsystemcatalog.h b/dbcon/execplan/calpontsystemcatalog.h index edd9aecd3..44f38be11 100644 --- a/dbcon/execplan/calpontsystemcatalog.h +++ b/dbcon/execplan/calpontsystemcatalog.h @@ -306,7 +306,7 @@ class CalpontSystemCatalog : public datatypes::SystemCatalog return !(*this == t); } - static ColType convertUnionColType(std::vector&); + static ColType convertUnionColType(std::vector&, unsigned int&); }; /** the structure of a table infomation diff --git a/dbcon/joblist/jlf_tuplejoblist.cpp b/dbcon/joblist/jlf_tuplejoblist.cpp index 857566973..56a3ac2ee 100644 --- a/dbcon/joblist/jlf_tuplejoblist.cpp +++ b/dbcon/joblist/jlf_tuplejoblist.cpp @@ -5102,11 +5102,18 @@ SJSTEP unionQueries(JobStepVector& queries, uint64_t distinctUnionNum, JobInfo& unionStep->inputAssociation(jsaToUnion); unionStep->outputAssociation(jsa); + // This return code in the call to convertUnionColType() below would + // always be 0. This is because convertUnionColType() is also called + // in the connector code in getSelectPlan()/getGroupPlan() which handle + // the non-zero return code scenarios from this function call and error + // out, in which case, the execution does not even get to ExeMgr. + unsigned int dummyUnionedTypeRc = 0; + // get unioned column types for (uint64_t j = 0; j < colCount; ++j) { CalpontSystemCatalog::ColType colType = - CalpontSystemCatalog::ColType::convertUnionColType(queryColTypes[j]); + CalpontSystemCatalog::ColType::convertUnionColType(queryColTypes[j], dummyUnionedTypeRc); types.push_back(colType.colDataType); csNums.push_back(colType.charsetNumber); scale.push_back(colType.scale); diff --git a/dbcon/mysql/ha_mcs_execplan.cpp b/dbcon/mysql/ha_mcs_execplan.cpp index ecd22421b..08c6c45be 100644 --- a/dbcon/mysql/ha_mcs_execplan.cpp +++ b/dbcon/mysql/ha_mcs_execplan.cpp @@ -6819,7 +6819,7 @@ int processFrom(bool& isUnion, SELECT_LEX& select_lex, gp_walk_info& gwi, SCSEP& bool unionSel = false; // UNION master unit check // Existed pushdown handlers won't get in this scope - // except UNION pushdown that is to come. + // MDEV-25080 Union pushdown would enter this scope // is_unit_op() give a segv for derived_handler's SELECT_LEX if (!isUnion && (!isSelectHandlerTop || isSelectLexUnit) && select_lex.master_unit()->is_unit_op()) { @@ -7414,8 +7414,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i return rc; } - bool unionSel = (!isUnion && select_lex.master_unit()->is_unit_op()) ? true : false; - gwi.clauseType = WHERE; if ((rc = processWhere(select_lex, gwi, csep, condStack))) { @@ -7857,25 +7855,32 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i // @bug4388 normalize the project coltypes for union main select list if (!csep->unionVec().empty()) { + unsigned int unionedTypeRc = 0; + for (uint32_t i = 0; i < gwi.returnedCols.size(); i++) { vector coltypes; for (uint32_t j = 0; j < csep->unionVec().size(); j++) { - coltypes.push_back(dynamic_cast(csep->unionVec()[j].get()) - ->returnedCols()[i] - ->resultType()); + CalpontSelectExecutionPlan* unionCsep = + dynamic_cast(csep->unionVec()[j].get()); + coltypes.push_back(unionCsep->returnedCols()[i]->resultType()); // @bug5976. set hasAggregate true for the main column if // one corresponding union column has aggregate - if (dynamic_cast(csep->unionVec()[j].get()) - ->returnedCols()[i] - ->hasAggregate()) + if (unionCsep->returnedCols()[i]->hasAggregate()) gwi.returnedCols[i]->hasAggregate(true); } - gwi.returnedCols[i]->resultType(CalpontSystemCatalog::ColType::convertUnionColType(coltypes)); + gwi.returnedCols[i]->resultType(CalpontSystemCatalog::ColType::convertUnionColType(coltypes, unionedTypeRc)); + + if (unionedTypeRc != 0) + { + gwi.parseErrorText = IDBErrorInfo::instance()->errorMsg(unionedTypeRc); + setError(gwi.thd, ER_CHECK_NOT_IMPLEMENTED, gwi.parseErrorText, gwi); + return ER_CHECK_NOT_IMPLEMENTED; + } } } @@ -8044,6 +8049,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i SRCP minSc; // min width projected column. for count(*) use + bool unionSel = (!isUnion && select_lex.master_unit()->is_unit_op()) ? true : false; + // Group by list. not valid for union main query if (!unionSel) { @@ -9681,25 +9688,32 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro // @bug4388 normalize the project coltypes for union main select list if (!csep->unionVec().empty()) { + unsigned int unionedTypeRc = 0; + for (uint32_t i = 0; i < gwi.returnedCols.size(); i++) { vector coltypes; for (uint32_t j = 0; j < csep->unionVec().size(); j++) { - coltypes.push_back(dynamic_cast(csep->unionVec()[j].get()) - ->returnedCols()[i] - ->resultType()); + CalpontSelectExecutionPlan* unionCsep = + dynamic_cast(csep->unionVec()[j].get()); + coltypes.push_back(unionCsep->returnedCols()[i]->resultType()); // @bug5976. set hasAggregate true for the main column if // one corresponding union column has aggregate - if (dynamic_cast(csep->unionVec()[j].get()) - ->returnedCols()[i] - ->hasAggregate()) + if (unionCsep->returnedCols()[i]->hasAggregate()) gwi.returnedCols[i]->hasAggregate(true); } - gwi.returnedCols[i]->resultType(CalpontSystemCatalog::ColType::convertUnionColType(coltypes)); + gwi.returnedCols[i]->resultType(CalpontSystemCatalog::ColType::convertUnionColType(coltypes, unionedTypeRc)); + + if (unionedTypeRc != 0) + { + gwi.parseErrorText = IDBErrorInfo::instance()->errorMsg(unionedTypeRc); + setError(gwi.thd, ER_CHECK_NOT_IMPLEMENTED, gwi.parseErrorText, gwi); + return ER_CHECK_NOT_IMPLEMENTED; + } } } diff --git a/dbcon/mysql/ha_mcs_pushdown.cpp b/dbcon/mysql/ha_mcs_pushdown.cpp index 3c8c7a70c..9bfb428b6 100644 --- a/dbcon/mysql/ha_mcs_pushdown.cpp +++ b/dbcon/mysql/ha_mcs_pushdown.cpp @@ -738,7 +738,6 @@ int ha_mcs_group_by_handler::end_scan() * thd - THD pointer. * sel_lex - SELECT_LEX* that describes the query. * sel_unit - SELECT_LEX_UNIT* that describes the query. - * Only one of sel_lex and sel_unit is not null. * RETURN: * select_handler if possible * NULL in other case @@ -816,15 +815,15 @@ select_handler* create_columnstore_select_handler_(THD* thd, SELECT_LEX* sel_lex // or unsupported feature. ha_columnstore_select_handler* handler; - if (sel_unit && sel_lex) + if (sel_unit && sel_lex) // partial pushdown of the SELECT_LEX_UNIT { handler = new ha_columnstore_select_handler(thd, sel_lex, sel_unit); } - else if (sel_unit) + else if (sel_unit) // complete pushdown of the SELECT_LEX_UNIT { handler = new ha_columnstore_select_handler(thd, sel_unit); } - else + else // Query only has a SELECT_LEX, no SELECT_LEX_UNIT { handler = new ha_columnstore_select_handler(thd, sel_lex); } diff --git a/mysql-test/columnstore/basic/r/mcol641-union.result b/mysql-test/columnstore/basic/r/mcol641-union.result index d3dce7444..fa798dd8e 100644 --- a/mysql-test/columnstore/basic/r/mcol641-union.result +++ b/mysql-test/columnstore/basic/r/mcol641-union.result @@ -1,3 +1,5 @@ +# MCOL-641 Union Test Cases +# Once MCOL-5417 is supported, the errored out queries below should be fixed. DROP DATABASE IF EXISTS mcol641_union_db; CREATE DATABASE mcol641_union_db; USE mcol641_union_db; @@ -11,63 +13,52 @@ INSERT INTO cs1 values (99999999999999999999999999999999999999, 9999999999999999 INSERT INTO cs1 values (-99999999999999999999999999999999999998, -9999999999999999999999999999.9999999998, -0.99999999999999999999999999999999999998); INSERT INTO cs1 values (-99999999999999999999999999999999999999, -9999999999999999999999999999.9999999999, -0.99999999999999999999999999999999999999); SELECT d1, d1, d2 FROM cs1 UNION SELECT d2, d3, d3 FROM cs1; -d1 d1 d2 -125.0000000000 125.00000000000000000000000000000000000000 1.25000000000000000000000000000000000000 --125.0000000000 -125.00000000000000000000000000000000000000 -1.25000000000000000000000000000000000000 -99999999999999999999999999999999999998.0000000000 999999999999999999999999999.99999999999999999999999999999999999999 999999999999999999999999999.99999999999999999999999999999999999999 -99999999999999999999999999999999999999.0000000000 999999999999999999999999999.99999999999999999999999999999999999999 999999999999999999999999999.99999999999999999999999999999999999999 --99999999999999999999999999999999999998.0000000000 -999999999999999999999999999.99999999999999999999999999999999999999 -999999999999999999999999999.99999999999999999999999999999999999999 --99999999999999999999999999999999999999.0000000000 -999999999999999999999999999.99999999999999999999999999999999999999 -999999999999999999999999999.99999999999999999999999999999999999999 -1.2500000000 0.12500000000000000000000000000000000000 0.12500000000000000000000000000000000000 --1.2500000000 -0.12500000000000000000000000000000000000 -0.12500000000000000000000000000000000000 -9999999999999999999999999999.9999999998 0.99999999999999999999999999999999999998 0.99999999999999999999999999999999999998 -9999999999999999999999999999.9999999999 0.99999999999999999999999999999999999999 0.99999999999999999999999999999999999999 --9999999999999999999999999999.9999999998 -0.99999999999999999999999999999999999998 -0.99999999999999999999999999999999999998 --9999999999999999999999999999.9999999999 -0.99999999999999999999999999999999999999 -0.99999999999999999999999999999999999999 +ERROR 42000: The storage engine for the table doesn't support MCS-2060: Union operation exceeds maximum DECIMAL precision of 38. SELECT d2, d3, d3 FROM cs1 UNION SELECT d1, d1, d2 FROM cs1; -d2 d3 d3 -1.2500000000 0.12500000000000000000000000000000000000 0.12500000000000000000000000000000000000 --1.2500000000 -0.12500000000000000000000000000000000000 -0.12500000000000000000000000000000000000 -9999999999999999999999999999.9999999998 0.99999999999999999999999999999999999998 0.99999999999999999999999999999999999998 -9999999999999999999999999999.9999999999 0.99999999999999999999999999999999999999 0.99999999999999999999999999999999999999 --9999999999999999999999999999.9999999998 -0.99999999999999999999999999999999999998 -0.99999999999999999999999999999999999998 --9999999999999999999999999999.9999999999 -0.99999999999999999999999999999999999999 -0.99999999999999999999999999999999999999 -125.0000000000 125.00000000000000000000000000000000000000 1.25000000000000000000000000000000000000 --125.0000000000 -125.00000000000000000000000000000000000000 -1.25000000000000000000000000000000000000 -99999999999999999999999999999999999998.0000000000 999999999999999999999999999.99999999999999999999999999999999999999 999999999999999999999999999.99999999999999999999999999999999999999 -99999999999999999999999999999999999999.0000000000 999999999999999999999999999.99999999999999999999999999999999999999 999999999999999999999999999.99999999999999999999999999999999999999 --99999999999999999999999999999999999998.0000000000 -999999999999999999999999999.99999999999999999999999999999999999999 -999999999999999999999999999.99999999999999999999999999999999999999 --99999999999999999999999999999999999999.0000000000 -999999999999999999999999999.99999999999999999999999999999999999999 -999999999999999999999999999.99999999999999999999999999999999999999 +ERROR 42000: The storage engine for the table doesn't support MCS-2060: Union operation exceeds maximum DECIMAL precision of 38. SELECT d1, d2, d3 FROM cs1 UNION SELECT d1, d2, d3 FROM cs1; d1 d2 d3 -125 1.2500000000 0.12500000000000000000000000000000000000 -125 -1.2500000000 -0.12500000000000000000000000000000000000 -99999999999999999999999999999999999998 9999999999999999999999999999.9999999998 0.99999999999999999999999999999999999998 -99999999999999999999999999999999999999 9999999999999999999999999999.9999999999 0.99999999999999999999999999999999999999 -99999999999999999999999999999999999998 -9999999999999999999999999999.9999999998 -0.99999999999999999999999999999999999998 -99999999999999999999999999999999999999 -9999999999999999999999999999.9999999999 -0.99999999999999999999999999999999999999 +125 1.2500000000 0.12500000000000000000000000000000000000 +99999999999999999999999999999999999998 9999999999999999999999999999.9999999998 0.99999999999999999999999999999999999998 +99999999999999999999999999999999999999 9999999999999999999999999999.9999999999 0.99999999999999999999999999999999999999 INSERT INTO cs2 VALUES (125, 1.25, 0.125); INSERT INTO cs2 values (99999999999999999999999999999999999998, 9999999999999999999999999999.9999999998, 0.99999999999999999999999999999999999998); INSERT INTO cs2 values (99999999999999999999999999999999999999, 9999999999999999999999999999.9999999999, 0.99999999999999999999999999999999999999); SELECT d1, d1, d2 FROM cs2 UNION SELECT d2, d3, d3 FROM cs2; -d1 d1 d2 -125.0000000000 125.00000000000000000000000000000000000000 1.25000000000000000000000000000000000000 -99999999999999999999999999999999999998.0000000000 999999999999999999999999999.99999999999999999999999999999999999999 999999999999999999999999999.99999999999999999999999999999999999999 -99999999999999999999999999999999999999.0000000000 999999999999999999999999999.99999999999999999999999999999999999999 999999999999999999999999999.99999999999999999999999999999999999999 -1.2500000000 0.12500000000000000000000000000000000000 0.12500000000000000000000000000000000000 -9999999999999999999999999999.9999999998 0.99999999999999999999999999999999999998 0.99999999999999999999999999999999999998 -9999999999999999999999999999.9999999999 0.99999999999999999999999999999999999999 0.99999999999999999999999999999999999999 +ERROR 42000: The storage engine for the table doesn't support MCS-2060: Union operation exceeds maximum DECIMAL precision of 38. SELECT d2, d3, d3 FROM cs2 UNION SELECT d1, d1, d2 FROM cs2; -d2 d3 d3 -1.2500000000 0.12500000000000000000000000000000000000 0.12500000000000000000000000000000000000 -9999999999999999999999999999.9999999998 0.99999999999999999999999999999999999998 0.99999999999999999999999999999999999998 -9999999999999999999999999999.9999999999 0.99999999999999999999999999999999999999 0.99999999999999999999999999999999999999 -125.0000000000 125.00000000000000000000000000000000000000 1.25000000000000000000000000000000000000 -99999999999999999999999999999999999998.0000000000 999999999999999999999999999.99999999999999999999999999999999999999 999999999999999999999999999.99999999999999999999999999999999999999 -99999999999999999999999999999999999999.0000000000 999999999999999999999999999.99999999999999999999999999999999999999 999999999999999999999999999.99999999999999999999999999999999999999 +ERROR 42000: The storage engine for the table doesn't support MCS-2060: Union operation exceeds maximum DECIMAL precision of 38. SELECT d1, d2, d3 FROM cs2 UNION SELECT d1, d2, d3 FROM cs2; d1 d2 d3 125 1.2500000000 0.12500000000000000000000000000000000000 99999999999999999999999999999999999998 9999999999999999999999999999.9999999998 0.99999999999999999999999999999999999998 99999999999999999999999999999999999999 9999999999999999999999999999.9999999999 0.99999999999999999999999999999999999999 +DROP TABLE cs1, cs2; +CREATE TABLE cs1 (d1 DECIMAL(20, 0), d2 DECIMAL(20, 18), d3 DECIMAL(18, 18)) ENGINE=columnstore; +CREATE TABLE cs2 (d1 DECIMAL(20, 0) UNSIGNED, d2 DECIMAL(20, 18) UNSIGNED, d3 DECIMAL(18, 18) UNSIGNED) ENGINE=columnstore; +INSERT INTO cs1 VALUES (12345678901234567890, 12.345678901234567891, 0.123456789012345678); +INSERT INTO cs1 VALUES (-12345678901234567890, -12.345678901234567891, -0.123456789012345678); +INSERT INTO cs1 VALUES (99999999999999999999, 99.999999999999999999, 0.999999999999999999); +INSERT INTO cs1 VALUES (-99999999999999999999, -99.999999999999999999, -0.999999999999999999); +INSERT INTO cs2 VALUES (12345678901234567890, 12.345678901234567891, 0.123456789012345678); +INSERT INTO cs2 VALUES (99999999999999999999, 99.999999999999999999, 0.999999999999999999); +SELECT d1, d1, d2 FROM cs1 UNION SELECT d2, d3, d3 FROM cs1; +d1 d1 d2 +-12.345678901234567891 -0.123456789012345678 -0.123456789012345678 +-12345678901234567890.000000000000000000 -12345678901234567890.000000000000000000 -12.345678901234567891 +-99.999999999999999999 -0.999999999999999999 -0.999999999999999999 +-99999999999999999999.000000000000000000 -99999999999999999999.000000000000000000 -99.999999999999999999 +12.345678901234567891 0.123456789012345678 0.123456789012345678 +12345678901234567890.000000000000000000 12345678901234567890.000000000000000000 12.345678901234567891 +99.999999999999999999 0.999999999999999999 0.999999999999999999 +99999999999999999999.000000000000000000 99999999999999999999.000000000000000000 99.999999999999999999 +SELECT d1, d1, d2 FROM cs2 UNION SELECT d2, d3, d3 FROM cs2; +d1 d1 d2 +12.345678901234567891 0.123456789012345678 0.123456789012345678 +12345678901234567890.000000000000000000 12345678901234567890.000000000000000000 12.345678901234567891 +99.999999999999999999 0.999999999999999999 0.999999999999999999 +99999999999999999999.000000000000000000 99999999999999999999.000000000000000000 99.999999999999999999 DROP DATABASE mcol641_union_db; diff --git a/mysql-test/columnstore/basic/t/mcol641-union.test b/mysql-test/columnstore/basic/t/mcol641-union.test index 5b2ab1aad..5f58a9cd0 100644 --- a/mysql-test/columnstore/basic/t/mcol641-union.test +++ b/mysql-test/columnstore/basic/t/mcol641-union.test @@ -1,5 +1,8 @@ -- source ../include/have_columnstore.inc +--echo # MCOL-641 Union Test Cases +--echo # Once MCOL-5417 is supported, the errored out queries below should be fixed. + --disable_warnings DROP DATABASE IF EXISTS mcol641_union_db; --enable_warnings @@ -19,17 +22,38 @@ INSERT INTO cs1 values (99999999999999999999999999999999999999, 9999999999999999 INSERT INTO cs1 values (-99999999999999999999999999999999999998, -9999999999999999999999999999.9999999998, -0.99999999999999999999999999999999999998); INSERT INTO cs1 values (-99999999999999999999999999999999999999, -9999999999999999999999999999.9999999999, -0.99999999999999999999999999999999999999); +--error ER_CHECK_NOT_IMPLEMENTED SELECT d1, d1, d2 FROM cs1 UNION SELECT d2, d3, d3 FROM cs1; +--error ER_CHECK_NOT_IMPLEMENTED SELECT d2, d3, d3 FROM cs1 UNION SELECT d1, d1, d2 FROM cs1; +--sorted_result SELECT d1, d2, d3 FROM cs1 UNION SELECT d1, d2, d3 FROM cs1; INSERT INTO cs2 VALUES (125, 1.25, 0.125); INSERT INTO cs2 values (99999999999999999999999999999999999998, 9999999999999999999999999999.9999999998, 0.99999999999999999999999999999999999998); INSERT INTO cs2 values (99999999999999999999999999999999999999, 9999999999999999999999999999.9999999999, 0.99999999999999999999999999999999999999); +--error ER_CHECK_NOT_IMPLEMENTED SELECT d1, d1, d2 FROM cs2 UNION SELECT d2, d3, d3 FROM cs2; +--error ER_CHECK_NOT_IMPLEMENTED SELECT d2, d3, d3 FROM cs2 UNION SELECT d1, d1, d2 FROM cs2; +--sorted_result SELECT d1, d2, d3 FROM cs2 UNION SELECT d1, d2, d3 FROM cs2; +DROP TABLE cs1, cs2; +CREATE TABLE cs1 (d1 DECIMAL(20, 0), d2 DECIMAL(20, 18), d3 DECIMAL(18, 18)) ENGINE=columnstore; +CREATE TABLE cs2 (d1 DECIMAL(20, 0) UNSIGNED, d2 DECIMAL(20, 18) UNSIGNED, d3 DECIMAL(18, 18) UNSIGNED) ENGINE=columnstore; +INSERT INTO cs1 VALUES (12345678901234567890, 12.345678901234567891, 0.123456789012345678); +INSERT INTO cs1 VALUES (-12345678901234567890, -12.345678901234567891, -0.123456789012345678); +INSERT INTO cs1 VALUES (99999999999999999999, 99.999999999999999999, 0.999999999999999999); +INSERT INTO cs1 VALUES (-99999999999999999999, -99.999999999999999999, -0.999999999999999999); +INSERT INTO cs2 VALUES (12345678901234567890, 12.345678901234567891, 0.123456789012345678); +INSERT INTO cs2 VALUES (99999999999999999999, 99.999999999999999999, 0.999999999999999999); + +--sorted_result +SELECT d1, d1, d2 FROM cs1 UNION SELECT d2, d3, d3 FROM cs1; +--sorted_result +SELECT d1, d1, d2 FROM cs2 UNION SELECT d2, d3, d3 FROM cs2; + # Clean UP DROP DATABASE mcol641_union_db; diff --git a/utils/dataconvert/dataconvert.cpp b/utils/dataconvert/dataconvert.cpp index 147417aaf..b53f42e74 100644 --- a/utils/dataconvert/dataconvert.cpp +++ b/utils/dataconvert/dataconvert.cpp @@ -2934,7 +2934,8 @@ int64_t DataConvert::stringToTime(const string& data) } void DataConvert::joinColTypeForUnion(datatypes::SystemCatalog::TypeHolderStd& unionedType, - const datatypes::SystemCatalog::TypeHolderStd& type) + const datatypes::SystemCatalog::TypeHolderStd& type, + unsigned int& rc) { // limited support for VARBINARY, no implicit conversion. if (type.colDataType == datatypes::SystemCatalog::VARBINARY || @@ -2974,6 +2975,19 @@ void DataConvert::joinColTypeForUnion(datatypes::SystemCatalog::TypeHolderStd& u case datatypes::SystemCatalog::UBIGINT: case datatypes::SystemCatalog::UDECIMAL: + if (type.scale != 0) + { + const unsigned int digitsBeforeDecimal = type.precision - type.scale; + const unsigned int digitsBeforeDecimalUnion = unionedType.precision - unionedType.scale; + + if ((std::max(digitsBeforeDecimal, digitsBeforeDecimalUnion) + + std::max(type.scale, unionedType.scale)) > datatypes::INT128MAXPRECISION) + { + rc = logging::ERR_UNION_DECIMAL_OVERFLOW; + return; + } + } + unionedType.precision = std::max(type.precision, unionedType.precision); unionedType.scale = std::max(type.scale, unionedType.scale); diff --git a/utils/dataconvert/dataconvert.h b/utils/dataconvert/dataconvert.h index e42514ce7..d77ec57d7 100644 --- a/utils/dataconvert/dataconvert.h +++ b/utils/dataconvert/dataconvert.h @@ -1290,7 +1290,8 @@ class DataConvert EXPORT static int64_t stringToTime(const std::string& data); // bug4388, union type conversion EXPORT static void joinColTypeForUnion(datatypes::SystemCatalog::TypeHolderStd& unionedType, - const datatypes::SystemCatalog::TypeHolderStd& type); + const datatypes::SystemCatalog::TypeHolderStd& type, + unsigned int& rc); static boost::any StringToBit(const datatypes::SystemCatalog::TypeAttributesStd& colType, const datatypes::ConvertFromStringParam& prm, const std::string& dataOrig, diff --git a/utils/loggingcpp/ErrorMessage.txt b/utils/loggingcpp/ErrorMessage.txt index f90366206..64c519865 100755 --- a/utils/loggingcpp/ErrorMessage.txt +++ b/utils/loggingcpp/ErrorMessage.txt @@ -106,6 +106,8 @@ 2058 ERR_DISKAGG_OVERFLOW1 The hash function used produces a lot of hash collisions (1). 2059 ERR_DISKAGG_OVERFLOW2 The hash function used produces a lot of hash collisions (2). +2060 ERR_UNION_DECIMAL_OVERFLOW Union operation exceeds maximum DECIMAL precision of 38. + # Sub-query errors 3001 ERR_NON_SUPPORT_SUB_QUERY_TYPE This subquery type is not supported yet. 3002 ERR_MORE_THAN_1_ROW Subquery returns more than 1 row.