From e5d76e142be7edcbbf0817f5bea594ddffc84973 Mon Sep 17 00:00:00 2001 From: David Hall Date: Thu, 28 Mar 2019 15:25:49 -0600 Subject: [PATCH 1/8] MCOL-1559 Some string trailing blank stuff --- dbcon/joblist/jlf_execplantojoblist.cpp | 2 ++ dbcon/joblist/lbidlist.cpp | 1 + dbcon/mysql/ha_calpont_execplan.cpp | 2 ++ primitives/primproc/dictstep.cpp | 2 ++ primitives/primproc/primitiveserver.cpp | 2 ++ 5 files changed, 9 insertions(+) diff --git a/dbcon/joblist/jlf_execplantojoblist.cpp b/dbcon/joblist/jlf_execplantojoblist.cpp index f3782c9d5..24ec7f50e 100644 --- a/dbcon/joblist/jlf_execplantojoblist.cpp +++ b/dbcon/joblist/jlf_execplantojoblist.cpp @@ -36,6 +36,7 @@ using namespace std; #include #include #include +#include namespace ba = boost::algorithm; #include "calpontexecutionplan.h" @@ -1635,6 +1636,7 @@ const JobStepVector doSimpleFilter(SimpleFilter* sf, JobInfo& jobInfo) } string constval(cc->constval()); + boost::trim_right_if(constval, boost::is_any_of(" ")); CalpontSystemCatalog::OID dictOid = 0; diff --git a/dbcon/joblist/lbidlist.cpp b/dbcon/joblist/lbidlist.cpp index c317defc9..7852562ef 100644 --- a/dbcon/joblist/lbidlist.cpp +++ b/dbcon/joblist/lbidlist.cpp @@ -749,6 +749,7 @@ bool LBIDList::CasualPartitionPredicate(const int64_t Min, int64_t tMax = Max; dataconvert::DataConvert::trimWhitespace(tMin); dataconvert::DataConvert::trimWhitespace(tMax); + dataconvert::DataConvert::trimWhitespace(value); scan = compareVal(order_swap(tMin), order_swap(tMax), order_swap(value), op, lcf); diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index 1094ffc37..e3bf14ad2 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -49,6 +49,7 @@ using namespace std; #include #include +#include #include #include @@ -4868,6 +4869,7 @@ void gp_walk(const Item* item, void* arg) { cval.assign(str->ptr(), str->length()); } +// boost::trim_right_if(cval, boost::is_any_of(" ")); gwip->rcWorkStack.push(new ConstantColumn(cval)); break; diff --git a/primitives/primproc/dictstep.cpp b/primitives/primproc/dictstep.cpp index abd99ada3..47bfeac25 100644 --- a/primitives/primproc/dictstep.cpp +++ b/primitives/primproc/dictstep.cpp @@ -30,6 +30,7 @@ #include #include +#include #include "bpp.h" #include "primitiveserver.h" @@ -93,6 +94,7 @@ void DictStep::createCommand(ByteStream& bs) for (uint32_t i = 0; i < filterCount; i++) { bs >> strTmp; + boost::trim_right_if(strTmp, boost::is_any_of(" ")); //cout << " " << strTmp << endl; eqFilter->insert(strTmp); } diff --git a/primitives/primproc/primitiveserver.cpp b/primitives/primproc/primitiveserver.cpp index 76ff8ef3c..9359556e9 100644 --- a/primitives/primproc/primitiveserver.cpp +++ b/primitives/primproc/primitiveserver.cpp @@ -28,6 +28,7 @@ #include #include #include +#include //#define NDEBUG #include #include @@ -1804,6 +1805,7 @@ private: for (i = 0; i < count; i++) { *bs >> str; + boost::trim_right_if(str, boost::is_any_of(" ")); filter->insert(str); } From aa802f44c534a21ff447b3025ae3e07ac323e337 Mon Sep 17 00:00:00 2001 From: David Hall Date: Fri, 29 Mar 2019 08:37:16 -0600 Subject: [PATCH 2/8] MCOL-1559 trailing white space comparison --- dbcon/execplan/predicateoperator.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dbcon/execplan/predicateoperator.h b/dbcon/execplan/predicateoperator.h index b83931394..f81f189bb 100644 --- a/dbcon/execplan/predicateoperator.h +++ b/dbcon/execplan/predicateoperator.h @@ -36,6 +36,7 @@ #endif #include #include +#include #include "expressionparser.h" #include "returnedcolumn.h" @@ -460,11 +461,17 @@ inline bool PredicateOperator::getBoolVal(rowgroup::Row& row, bool& isNull, Retu return false; const std::string& val1 = lop->getStrVal(row, isNull); - if (isNull) return false; - return strCompare(val1, rop->getStrVal(row, isNull)) && !isNull; + const std::string& val2 = rop->getStrVal(row, isNull); + if (isNull) + return false; + + boost::trim_right_if(val1, boost::is_any_of(" ")); + boost::trim_right_if(val2, boost::is_any_of(" ")); + + return strCompare(val1, val2); } //FIXME: ??? From 8d553ae9fbbe8ddcc984966a45f632a1896fdf81 Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 2 Apr 2019 11:14:40 -0600 Subject: [PATCH 3/8] MCOL-1559 trim spaces before compare --- dbcon/execplan/predicateoperator.h | 4 ++-- dbcon/mysql/ha_calpont_execplan.cpp | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/dbcon/execplan/predicateoperator.h b/dbcon/execplan/predicateoperator.h index f81f189bb..70209df5b 100644 --- a/dbcon/execplan/predicateoperator.h +++ b/dbcon/execplan/predicateoperator.h @@ -460,11 +460,11 @@ inline bool PredicateOperator::getBoolVal(rowgroup::Row& row, bool& isNull, Retu if (isNull) return false; - const std::string& val1 = lop->getStrVal(row, isNull); + std::string val1 = lop->getStrVal(row, isNull); if (isNull) return false; - const std::string& val2 = rop->getStrVal(row, isNull); + std::string val2 = rop->getStrVal(row, isNull); if (isNull) return false; diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index e3bf14ad2..1094ffc37 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -49,7 +49,6 @@ using namespace std; #include #include -#include #include #include @@ -4869,7 +4868,6 @@ void gp_walk(const Item* item, void* arg) { cval.assign(str->ptr(), str->length()); } -// boost::trim_right_if(cval, boost::is_any_of(" ")); gwip->rcWorkStack.push(new ConstantColumn(cval)); break; From 5b581f53cbe1c0a7b27ac63fdddcffeccd866103 Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 9 Apr 2019 13:09:29 -0500 Subject: [PATCH 4/8] MCOL-1559 trailing space compare --- dbcon/execplan/predicateoperator.h | 12 ++++++++++-- dbcon/joblist/jlf_execplantojoblist.cpp | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dbcon/execplan/predicateoperator.h b/dbcon/execplan/predicateoperator.h index 70209df5b..daa078948 100644 --- a/dbcon/execplan/predicateoperator.h +++ b/dbcon/execplan/predicateoperator.h @@ -456,11 +456,19 @@ inline bool PredicateOperator::getBoolVal(rowgroup::Row& row, bool& isNull, Retu isNull = false; return !ret; } +#if 0 + if (isNull) + return false; + + const std::string& val1 = lop->getStrVal(row, isNull); if (isNull) return false; - std::string val1 = lop->getStrVal(row, isNull); + return strCompare(val1, rop->getStrVal(row, isNull)) && !isNull; +#endif + // MCOL-1559 + std::string val1 = lop->getStrVal(row, isNull); if (isNull) return false; @@ -472,7 +480,7 @@ inline bool PredicateOperator::getBoolVal(rowgroup::Row& row, bool& isNull, Retu boost::trim_right_if(val2, boost::is_any_of(" ")); return strCompare(val1, val2); - } + } //FIXME: ??? case execplan::CalpontSystemCatalog::VARBINARY: diff --git a/dbcon/joblist/jlf_execplantojoblist.cpp b/dbcon/joblist/jlf_execplantojoblist.cpp index 24ec7f50e..4bd41530d 100644 --- a/dbcon/joblist/jlf_execplantojoblist.cpp +++ b/dbcon/joblist/jlf_execplantojoblist.cpp @@ -1636,7 +1636,7 @@ const JobStepVector doSimpleFilter(SimpleFilter* sf, JobInfo& jobInfo) } string constval(cc->constval()); - boost::trim_right_if(constval, boost::is_any_of(" ")); +// boost::trim_right_if(constval, boost::is_any_of(" ")); CalpontSystemCatalog::OID dictOid = 0; From e2cb6444843494e62ae8eacb0a1c3425400b7f69 Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 9 Apr 2019 16:34:45 -0500 Subject: [PATCH 5/8] MCOL-1559 trailing space compare --- dbcon/execplan/predicateoperator.h | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/dbcon/execplan/predicateoperator.h b/dbcon/execplan/predicateoperator.h index daa078948..08f0c40cf 100644 --- a/dbcon/execplan/predicateoperator.h +++ b/dbcon/execplan/predicateoperator.h @@ -456,18 +456,8 @@ inline bool PredicateOperator::getBoolVal(rowgroup::Row& row, bool& isNull, Retu isNull = false; return !ret; } -#if 0 - if (isNull) - return false; - const std::string& val1 = lop->getStrVal(row, isNull); - - if (isNull) - return false; - - return strCompare(val1, rop->getStrVal(row, isNull)) && !isNull; -#endif - // MCOL-1559 + // MCOL-1559 std::string val1 = lop->getStrVal(row, isNull); if (isNull) return false; From b6484dda4aa5703606cf74fe77e29101625cff33 Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 9 Apr 2019 16:57:21 -0500 Subject: [PATCH 6/8] MCOL-1559 trim constant varchar string before adding filter --- dbcon/joblist/jlf_execplantojoblist.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbcon/joblist/jlf_execplantojoblist.cpp b/dbcon/joblist/jlf_execplantojoblist.cpp index 4bd41530d..2cad5870e 100644 --- a/dbcon/joblist/jlf_execplantojoblist.cpp +++ b/dbcon/joblist/jlf_execplantojoblist.cpp @@ -1636,8 +1636,6 @@ const JobStepVector doSimpleFilter(SimpleFilter* sf, JobInfo& jobInfo) } string constval(cc->constval()); -// boost::trim_right_if(constval, boost::is_any_of(" ")); - CalpontSystemCatalog::OID dictOid = 0; CalpontSystemCatalog::ColType ct = sc->colType(); @@ -1676,6 +1674,8 @@ const JobStepVector doSimpleFilter(SimpleFilter* sf, JobInfo& jobInfo) pds->cardinality(sc->cardinality()); //Add the filter + // MCOL-1559 trim before adding. + boost::trim_right_if(constval, boost::is_any_of(" ")); pds->addFilter(cop, constval); // data list for pcolstep output From d78944d9ff894f677b63726d3e4f0a89763c8521 Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 9 Apr 2019 17:08:03 -0500 Subject: [PATCH 7/8] MCOL-1559 backout trim before setting compare. Shouldn't do this in all cases. --- dbcon/joblist/jlf_execplantojoblist.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/dbcon/joblist/jlf_execplantojoblist.cpp b/dbcon/joblist/jlf_execplantojoblist.cpp index 2cad5870e..e9068b5e8 100644 --- a/dbcon/joblist/jlf_execplantojoblist.cpp +++ b/dbcon/joblist/jlf_execplantojoblist.cpp @@ -1674,8 +1674,6 @@ const JobStepVector doSimpleFilter(SimpleFilter* sf, JobInfo& jobInfo) pds->cardinality(sc->cardinality()); //Add the filter - // MCOL-1559 trim before adding. - boost::trim_right_if(constval, boost::is_any_of(" ")); pds->addFilter(cop, constval); // data list for pcolstep output From 28e743bf38e6cc143d21e047cfcc7af105a665c5 Mon Sep 17 00:00:00 2001 From: David Hall Date: Wed, 10 Apr 2019 08:46:15 -0500 Subject: [PATCH 8/8] MCOL-1559 remove unused boost/trim header --- dbcon/joblist/jlf_execplantojoblist.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/dbcon/joblist/jlf_execplantojoblist.cpp b/dbcon/joblist/jlf_execplantojoblist.cpp index e9068b5e8..fff1b12fb 100644 --- a/dbcon/joblist/jlf_execplantojoblist.cpp +++ b/dbcon/joblist/jlf_execplantojoblist.cpp @@ -36,7 +36,6 @@ using namespace std; #include #include #include -#include namespace ba = boost::algorithm; #include "calpontexecutionplan.h"