diff --git a/dbcon/dmlpackageproc/commandpackageprocessor.cpp b/dbcon/dmlpackageproc/commandpackageprocessor.cpp index 994687724..d18f7076c 100644 --- a/dbcon/dmlpackageproc/commandpackageprocessor.cpp +++ b/dbcon/dmlpackageproc/commandpackageprocessor.cpp @@ -430,14 +430,7 @@ CommandPackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage) if (!cpInvalidated) { - // The code below assumes that in case of COMMIT all ranges for all touched LBIDs - // are either correctly set or correctly reset. - // It is also assumes that ROLLBACK or other operations but COMMIT may not return ranges - // to state that is correct. This is why we invalidate extents when we are not committing. - if (stmt != "COMMIT") - { - fDbrm->invalidateUncommittedExtentLBIDs(0, &lbidList); - } + fDbrm->invalidateUncommittedExtentLBIDs(0, &lbidList); } } } diff --git a/mysql-test/columnstore/basic/r/udf_calshowpartitions.result b/mysql-test/columnstore/basic/r/udf_calshowpartitions.result index f8567cd7e..86afab0e0 100644 --- a/mysql-test/columnstore/basic/r/udf_calshowpartitions.result +++ b/mysql-test/columnstore/basic/r/udf_calshowpartitions.result @@ -1,7 +1,6 @@ # # MCOL-4614 calShowPartitions() precision loss for huge narrow decimal # -CREATE FUNCTION calshowpartitions RETURNS STRING SONAME "ha_columnstore.so"; CREATE TABLE t1 (a DECIMAL(17,1)) ENGINE=ColumnStore; INSERT INTO t1 VALUES (-8999999999999999.9); SELECT * FROM t1 WHERE a=0; @@ -11,4 +10,3 @@ calshowpartitions('t1','a') Part# Min Max Status 0.0.1 -8999999999999999.9 -8999999999999999.9 Enabled DROP TABLE IF EXISTS t1; -DROP FUNCTION calshowpartitions; diff --git a/mysql-test/columnstore/basic/t/udf_calshowpartitions.test b/mysql-test/columnstore/basic/t/udf_calshowpartitions.test index 37f448be2..64526d86f 100644 --- a/mysql-test/columnstore/basic/t/udf_calshowpartitions.test +++ b/mysql-test/columnstore/basic/t/udf_calshowpartitions.test @@ -1,11 +1,16 @@ ---source include/testdb_only.inc --source ../include/have_columnstore.inc --echo # --echo # MCOL-4614 calShowPartitions() precision loss for huge narrow decimal --echo # -CREATE FUNCTION calshowpartitions RETURNS STRING SONAME "ha_columnstore.so"; +let $func_exists=`SELECT COUNT(*) FROM mysql.func WHERE name='calshowpartitions'`; +--disable_query_log +if (!$func_exists) +{ + CREATE FUNCTION calshowpartitions RETURNS STRING SONAME "ha_columnstore.so"; +} +--enable_query_log CREATE TABLE t1 (a DECIMAL(17,1)) ENGINE=ColumnStore; INSERT INTO t1 VALUES (-8999999999999999.9); @@ -13,4 +18,9 @@ SELECT * FROM t1 WHERE a=0; SELECT calshowpartitions('t1','a'); DROP TABLE IF EXISTS t1; -DROP FUNCTION calshowpartitions; +--disable_query_log +if (!$func_exists) +{ + DROP FUNCTION calshowpartitions; +} +--enable_query_log diff --git a/versioning/BRM/brmtypes.h b/versioning/BRM/brmtypes.h index 871d7dee9..93abec9b9 100644 --- a/versioning/BRM/brmtypes.h +++ b/versioning/BRM/brmtypes.h @@ -146,8 +146,9 @@ typedef struct _SIDTIDEntry SIDTIDEntry; // for multiple extents. // Special seqNum field values. -#define SEQNUM_MARK_INVALID (-1) -#define SEQNUM_MARK_INVALID_SET_RANGE (-2) +#define SEQNUM_MARK_INVALID (-1) +#define SEQNUM_MARK_INVALID_SET_RANGE (-2) +#define SEQNUM_MARK_UPDATING_INVALID_SET_RANGE (-3) // Used in vectors. struct CPInfo diff --git a/versioning/BRM/dbrm.cpp b/versioning/BRM/dbrm.cpp index 3f59efe4b..2dc51633c 100644 --- a/versioning/BRM/dbrm.cpp +++ b/versioning/BRM/dbrm.cpp @@ -4594,7 +4594,7 @@ void DBRM::invalidateUncommittedExtentLBIDs(execplan::CalpontSystemCatalog::SCN aInfo.isBinaryColumn = false; } - aInfo.seqNum = SEQNUM_MARK_INVALID_SET_RANGE; + aInfo.seqNum = SEQNUM_MARK_UPDATING_INVALID_SET_RANGE; cpInfos.push_back(aInfo); } diff --git a/versioning/BRM/extentmap.cpp b/versioning/BRM/extentmap.cpp index 61f4ac206..df4b27b79 100644 --- a/versioning/BRM/extentmap.cpp +++ b/versioning/BRM/extentmap.cpp @@ -347,8 +347,16 @@ int ExtentMap::_markInvalid(const LBID_t lbid, const execplan::CalpontSystemCata if (isUnsigned(colDataType)) { - fExtentMap[i].partition.cprange.bigLoVal = -1; - fExtentMap[i].partition.cprange.bigHiVal = 0; + if (fExtentMap[i].colWid != datatypes::MAXDECIMALWIDTH) + { + fExtentMap[i].partition.cprange.loVal = numeric_limits::max(); + fExtentMap[i].partition.cprange.hiVal = numeric_limits::min(); + } + else + { + fExtentMap[i].partition.cprange.bigLoVal = -1; // XXX: unsigned wide decimals do not exceed rang of signed wide decimals. + fExtentMap[i].partition.cprange.bigHiVal = 0; + } } else { @@ -704,6 +712,26 @@ void ExtentMap::setExtentsMaxMin(const CPMaxMinMap_t& cpMap, bool firstNode, boo incSeqNum(fExtentMap[i].partition.cprange.sequenceNum); extentsUpdated++; } + else if (it->second.seqNum == SEQNUM_MARK_UPDATING_INVALID_SET_RANGE) + { + makeUndoRecord(&fExtentMap[i], sizeof(struct EMEntry)); + if (fExtentMap[i].partition.cprange.isValid == CP_UPDATING) + { + if (it->second.isBinaryColumn) + { + fExtentMap[i].partition.cprange.bigHiVal = it->second.bigMax; + fExtentMap[i].partition.cprange.bigLoVal = it->second.bigMin; + } + else + { + fExtentMap[i].partition.cprange.hiVal = it->second.max; + fExtentMap[i].partition.cprange.loVal = it->second.min; + } + fExtentMap[i].partition.cprange.isValid = CP_INVALID; + } + incSeqNum(fExtentMap[i].partition.cprange.sequenceNum); + extentsUpdated++; + } // else sequence has changed since start of the query. Don't update the EM entry. else { @@ -725,14 +753,14 @@ void ExtentMap::setExtentsMaxMin(const CPMaxMinMap_t& cpMap, bool firstNode, boo for (i = 0; i < entries; i++) { if (fExtentMap[i].range.start == it->first) - { + { break; - } - } - if (i < entries) - { + } + } + if (i < entries) + { continue; - } + } oss << " " << it->first; }