You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-07 03:22:57 +03:00
1. Execution plan now sets limitNum and limitOffset for all cases if an explicit limit is supplied in the query.
2. Fallback to using sql_select_limit system variable value if an explicit limit is not supplied. 3. Remove checks that did not allow (2^64 - 1) as a valid limit value.
This commit is contained in:
@@ -767,10 +767,6 @@ int doFromSubquery(CalpontExecutionPlan* ep, const string& alias, const string&
|
|||||||
|
|
||||||
void addOrderByAndLimit(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo)
|
void addOrderByAndLimit(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo)
|
||||||
{
|
{
|
||||||
// make sure there is a LIMIT
|
|
||||||
if (csep->orderByCols().size() > 0 && csep->limitNum() == (uint64_t) - 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
jobInfo.limitStart = csep->limitStart();
|
jobInfo.limitStart = csep->limitStart();
|
||||||
jobInfo.limitCount = csep->limitNum();
|
jobInfo.limitCount = csep->limitNum();
|
||||||
|
|
||||||
|
@@ -1712,29 +1712,24 @@ void parseExecutionPlan(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo,
|
|||||||
void makeVtableModeSteps(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo,
|
void makeVtableModeSteps(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo,
|
||||||
JobStepVector& querySteps, JobStepVector& projectSteps, DeliveredTableMap& deliverySteps)
|
JobStepVector& querySteps, JobStepVector& projectSteps, DeliveredTableMap& deliverySteps)
|
||||||
{
|
{
|
||||||
// @bug4848, enhance and unify limit handling.
|
// special case for outer query order by limit -- return all
|
||||||
if (csep->limitNum() != (uint64_t) - 1)
|
if (jobInfo.subId == 0 && csep->hasOrderBy() && !csep->specHandlerProcessed())
|
||||||
{
|
{
|
||||||
// special case for outer query order by limit -- return all
|
jobInfo.limitCount = (uint64_t) - 1;
|
||||||
if (jobInfo.subId == 0 && csep->hasOrderBy() && !csep->specHandlerProcessed())
|
}
|
||||||
{
|
|
||||||
jobInfo.limitCount = (uint64_t) - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// support order by and limit in sub-query/union or
|
// support order by and limit in sub-query/union or
|
||||||
// GROUP BY handler processed outer query order
|
// GROUP BY handler processed outer query order
|
||||||
else if (csep->orderByCols().size() > 0)
|
else if (csep->orderByCols().size() > 0)
|
||||||
{
|
{
|
||||||
addOrderByAndLimit(csep, jobInfo);
|
addOrderByAndLimit(csep, jobInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// limit without order by in any query
|
|
||||||
else
|
|
||||||
{
|
|
||||||
jobInfo.limitStart = csep->limitStart();
|
|
||||||
jobInfo.limitCount = csep->limitNum();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// limit without order by in any query
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jobInfo.limitStart = csep->limitStart();
|
||||||
|
jobInfo.limitCount = csep->limitNum();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bug 2123. Added overrideLargeSideEstimate parm below. True if the query was written
|
// Bug 2123. Added overrideLargeSideEstimate parm below. True if the query was written
|
||||||
|
@@ -7842,26 +7842,13 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// relate to bug4848. let mysql drive limit when limit session variable set.
|
csep->limitStart(limitOffset);
|
||||||
// do not set in csep. @bug5096. ignore session limit setting for dml
|
csep->limitNum(limitNum);
|
||||||
if (gwi.thd->variables.select_limit == (uint64_t) - 1 &&
|
|
||||||
!csep->hasOrderBy())
|
|
||||||
{
|
|
||||||
csep->limitStart(limitOffset);
|
|
||||||
csep->limitNum(limitNum);
|
|
||||||
}
|
|
||||||
// Pushdown queries w ORDER BY and LIMIT
|
|
||||||
else if (isPushdownHand && csep->hasOrderBy())
|
|
||||||
{
|
|
||||||
csep->limitStart(limitOffset);
|
|
||||||
csep->limitNum(limitNum);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Pushdown queries with ORDER BY w/o explicit limit
|
// If an explicit limit is not specified, use the system variable value
|
||||||
else if (isPushdownHand && csep->hasOrderBy())
|
else
|
||||||
{
|
{
|
||||||
// We must set this to activate LimitedOrderBy in ExeMgr
|
csep->limitNum(gwi.thd->variables.select_limit);
|
||||||
csep->limitNum((uint64_t) - 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't currently support limit with correlated subquery
|
// We don't currently support limit with correlated subquery
|
||||||
|
Reference in New Issue
Block a user