From 69486310f298ea3a7343aa64afe846d818c59327 Mon Sep 17 00:00:00 2001 From: drrtuy Date: Thu, 16 Aug 2018 13:01:04 +0300 Subject: [PATCH] MCOL-1637 Return limit value comparision to fix the regression. --- dbcon/joblist/jlf_subquery.cpp | 4 ++-- dbcon/joblist/joblistfactory.cpp | 2 +- dbcon/mysql/ha_calpont_execplan.cpp | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dbcon/joblist/jlf_subquery.cpp b/dbcon/joblist/jlf_subquery.cpp index add3dc533..1e4eaeeec 100644 --- a/dbcon/joblist/jlf_subquery.cpp +++ b/dbcon/joblist/jlf_subquery.cpp @@ -756,8 +756,8 @@ int doFromSubquery(CalpontExecutionPlan* ep, const string& alias, const string& void addOrderByAndLimit(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo) { // make sure there is a LIMIT -// if (csep->orderByCols().size() > 0 csep->limitNum() == (uint64_t) - 1) -// return; + if (csep->orderByCols().size() > 0 && csep->limitNum() == (uint64_t) - 1) + return; jobInfo.limitStart = csep->limitStart(); jobInfo.limitCount = csep->limitNum(); diff --git a/dbcon/joblist/joblistfactory.cpp b/dbcon/joblist/joblistfactory.cpp index 6fa0adbab..8c0615d83 100644 --- a/dbcon/joblist/joblistfactory.cpp +++ b/dbcon/joblist/joblistfactory.cpp @@ -1843,7 +1843,7 @@ void makeVtableModeSteps(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo, JobStepVector& querySteps, JobStepVector& projectSteps, DeliveredTableMap& deliverySteps) { // @bug4848, enhance and unify limit handling. -// if (csep->limitNum() != (uint64_t) - 1) + if (csep->limitNum() != (uint64_t) - 1) { // special case for outer query order by limit -- return all if (jobInfo.subId == 0 && csep->hasOrderBy()) diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index 59eecb631..f39ef1c96 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -10110,6 +10110,11 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro { csep->limitNum(((Item_int*)gi.groupByTables->select_lex->select_limit)->val_int()); } + else + { + if (csep->hasOrderBy()) + csep->limitNum((uint64_t) - 2); + } if (gi.groupByTables->select_lex->offset_limit) {