From 61b55127ac19ea5873528c5f26d81ae69a46f628 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 20 Nov 2020 10:23:13 +0400 Subject: [PATCH] A fix for MCOL-4174 Review/refactor frontend/connector code - The code in ha_mcs_partition.cpp erroneously printed data to a temporary ostringstream "oss" instead of "output". - The left-side adjustfield (applied when printing the range values) unintentionally disappeared during MCOL-4174 refactoring. Restoring left adjustfield in TypeHandler::PrintPartitionValue*(). --- datatypes/mcs_datatype.cpp | 24 +++++++++++++++++------- dbcon/mysql/ha_mcs_partition.cpp | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/datatypes/mcs_datatype.cpp b/datatypes/mcs_datatype.cpp index 493d64fd9..14020b5e1 100644 --- a/datatypes/mcs_datatype.cpp +++ b/datatypes/mcs_datatype.cpp @@ -791,11 +791,21 @@ TypeHandlerXDecimal::format128(const SimpleValue &v, /****************************************************************************/ +class ostringstreamL: public ostringstream +{ +public: + ostringstreamL() + { + setf(ios::left, ios::adjustfield); + } +}; + + string TypeHandler::formatPartitionInfoSInt64( const SystemCatalog::TypeAttributesStd &attr, const MinMaxInfo &pi) const { - ostringstream output; + ostringstreamL output; if (pi.isEmptyOrNullSInt64()) output << setw(30) << "Empty/Null" << setw(30) << "Empty/Null"; @@ -810,7 +820,7 @@ string TypeHandler::formatPartitionInfoUInt64( const SystemCatalog::TypeAttributesStd &attr, const MinMaxInfo &pi) const { - ostringstream output; + ostringstreamL output; if (pi.isEmptyOrNullUInt64()) output << setw(30) << "Empty/Null" << setw(30) << "Empty/Null"; @@ -827,7 +837,7 @@ TypeHandlerXDecimal::formatPartitionInfo128( const SystemCatalog::TypeAttributesStd &attr, const MinMaxInfo &pi) const { - ostringstream output; + ostringstreamL output; if (pi.isEmptyOrNullSInt128()) output << setw(datatypes::Decimal::MAXLENGTH16BYTES) << "Empty/Null" << setw(datatypes::Decimal::MAXLENGTH16BYTES) << "Empty/Null"; @@ -843,7 +853,7 @@ TypeHandlerStr::formatPartitionInfoSmallCharVarchar( const SystemCatalog::TypeAttributesStd &attr, const MinMaxInfo &pi) const { - ostringstream output; + ostringstreamL output; int64_t maxLimit = numeric_limits::max(); int64_t minLimit = numeric_limits::min(); maxLimit = uint64ToStr(maxLimit); @@ -1398,7 +1408,7 @@ string TypeHandler::PrintPartitionValueSInt64( if (!partInfo.isSuitableSInt64(startVal, rfMin, endVal, rfMax)) return ""; - ostringstream oss; + ostringstreamL oss; if (partInfo.min > partInfo.max) oss << setw(30) << "Empty/Null" << setw(30) << "Empty/Null"; else @@ -1419,7 +1429,7 @@ string TypeHandler::PrintPartitionValueUInt64( if (!partInfo.isSuitableUInt64(startVal, rfMin, endVal, rfMax)) return ""; - ostringstream oss; + ostringstreamL oss; if (static_cast(partInfo.min) > static_cast(partInfo.max)) oss << setw(30) << "Empty/Null" << setw(30) << "Empty/Null"; else @@ -1440,7 +1450,7 @@ string TypeHandlerXDecimal::PrintPartitionValue128( if (!partInfo.isSuitableSInt128(startVal, rfMin, endVal, rfMax)) return ""; - ostringstream oss; + ostringstreamL oss; if (partInfo.int128Min > partInfo.int128Max) oss << setw(datatypes::Decimal::MAXLENGTH16BYTES) << "Empty/Null" << setw(datatypes::Decimal::MAXLENGTH16BYTES) << "Empty/Null"; diff --git a/dbcon/mysql/ha_mcs_partition.cpp b/dbcon/mysql/ha_mcs_partition.cpp index e31b40441..a707acb4a 100644 --- a/dbcon/mysql/ha_mcs_partition.cpp +++ b/dbcon/mysql/ha_mcs_partition.cpp @@ -717,7 +717,7 @@ extern "C" else { const datatypes::TypeHandler *h= ct.typeHandler(); - oss << h->formatPartitionInfo(ct, partIt->second); + output << h->formatPartitionInfo(ct, partIt->second); } if (partIt->second.is_disabled())