You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-1449. Fix the regression caused by changes in idborderby code for MCOL-1052. Add LIMIT and OFFSET support for group by handler.
This commit is contained in:
committed by
Roman Nozdrin
parent
e79daac8a9
commit
1a1f3ea506
@ -77,14 +77,9 @@ void LimitedOrderBy::initialize(const RowGroup& rg, const JobInfo& jobInfo)
|
||||
map<uint32_t, uint32_t>::iterator j = keyToIndexMap.find(i->first);
|
||||
idbassert(j != keyToIndexMap.end());
|
||||
|
||||
// MCOL-1052 Ordering direction in CSEP differs from
|
||||
// internal direction representation.
|
||||
if (i->second)
|
||||
fOrderByCond.push_back(IdbSortSpec(j->second, false));
|
||||
else
|
||||
fOrderByCond.push_back(IdbSortSpec(j->second, true));
|
||||
|
||||
//fOrderByCond.push_back(IdbSortSpec(j->second, i->second));
|
||||
// TODO Ordering direction in CSEP differs from
|
||||
// internal direction representation. This behavior should be fixed
|
||||
fOrderByCond.push_back(IdbSortSpec(j->second, i->second));
|
||||
}
|
||||
|
||||
// limit row count info
|
||||
@ -182,8 +177,8 @@ void LimitedOrderBy::finalize()
|
||||
if (fRowGroup.getRowCount() > 0)
|
||||
fDataQueue.push(fData);
|
||||
|
||||
// MCOL-1052 The removed check effectivly disables sorting to happen,
|
||||
// since fStart = 0;
|
||||
// MCOL-1052 The removed check effectively disables sorting,
|
||||
// since fStart = 0 if there is no OFFSET;
|
||||
if (true)
|
||||
{
|
||||
uint64_t newSize = fRowsPerRG * fRowGroup.getRowSize();
|
||||
|
@ -8009,6 +8009,10 @@ int cp_get_group_plan(THD* thd, SCSEP& csep, cal_impl_if::cal_group_info& gi)
|
||||
gwi.thd = thd;
|
||||
int status = getGroupPlan(gwi, select_lex, csep, gi);
|
||||
|
||||
cerr << "---------------- cp_get_group_plan EXECUTION PLAN ----------------" << endl;
|
||||
cerr << *csep << endl ;
|
||||
cerr << "-------------- EXECUTION PLAN END --------------\n" << endl;
|
||||
|
||||
if (status > 0)
|
||||
return ER_INTERNAL_ERROR;
|
||||
else if (status < 0)
|
||||
@ -9877,6 +9881,31 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
|
||||
select_query += ord_cols;
|
||||
}
|
||||
}
|
||||
// LIMIT and OFFSET are extracted from TABLE_LIST elements.
|
||||
// All of JOIN-ed tables contain relevant limit and offset.
|
||||
if (gi.groupByTables->select_lex->select_limit)
|
||||
{
|
||||
csep->limitNum(((Item_int*)gi.groupByTables->select_lex->select_limit)->val_int());
|
||||
}
|
||||
|
||||
if (gi.groupByTables->select_lex->offset_limit)
|
||||
{
|
||||
csep->limitStart(((Item_int*)gi.groupByTables->select_lex->offset_limit)->val_int());
|
||||
}
|
||||
|
||||
//gwi.thd->infinidb_vtable.select_vtable_query.free();
|
||||
//gwi.thd->infinidb_vtable.select_vtable_query.append(select_query.c_str(), select_query.length());
|
||||
|
||||
// We don't currently support limit with correlated subquery
|
||||
if (csep->limitNum() != (uint64_t) - 1 &&
|
||||
gwi.subQuery && !gwi.correlatedTbNameVec.empty())
|
||||
{
|
||||
gwi.fatalParseError = true;
|
||||
gwi.parseErrorText = IDBErrorInfo::instance()->errorMsg(ERR_NON_SUPPORT_LIMIT_SUB);
|
||||
setError(gwi.thd, ER_INTERNAL_ERROR, gwi.parseErrorText, gwi);
|
||||
return ER_CHECK_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
} // ORDER BY processing ends here
|
||||
|
||||
if ( gi.groupByDistinct )
|
||||
|
@ -5581,14 +5581,19 @@ internal_error:
|
||||
*/
|
||||
/***********************************************************
|
||||
* DESCRIPTION:
|
||||
* Return a result record for each group_by_handler::next_row() call.
|
||||
* Return a result record for each
|
||||
* group_by_handler::next_row() call.
|
||||
* PARAMETERS:
|
||||
* group_hand - group by handler, that preserves initial table and items lists. .
|
||||
* table - TABLE pointer The table to save the result set in.
|
||||
* group_hand - group by handler, that preserves initial
|
||||
* table and items lists. .
|
||||
* table - TABLE pointer The table to save the result
|
||||
* set in.
|
||||
* RETURN:
|
||||
* 0 if success
|
||||
* HA_ERR_END_OF_FILE if the record set has come to an end
|
||||
* others if something went wrong whilst getting the result set
|
||||
* HA_ERR_END_OF_FILE if the record set has come to
|
||||
* an end
|
||||
* others if something went wrong whilst getting the
|
||||
* result set
|
||||
***********************************************************/
|
||||
int ha_calpont_impl_group_by_next(ha_calpont_group_by_handler* group_hand, TABLE* table)
|
||||
{
|
||||
|
@ -59,6 +59,7 @@ class IdbCompare;
|
||||
struct IdbSortSpec
|
||||
{
|
||||
int fIndex;
|
||||
// TODO There are three ordering specs since 10.2
|
||||
int fAsc; // <ordering specification> ::= ASC | DESC
|
||||
int fNf; // <null ordering> ::= NULLS FIRST | NULLS LAST
|
||||
|
||||
|
Reference in New Issue
Block a user