1
0
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:
Roman Nozdrin
2018-05-23 15:06:16 +03:00
committed by Roman Nozdrin
parent e79daac8a9
commit 1a1f3ea506
4 changed files with 46 additions and 16 deletions

View File

@ -77,14 +77,9 @@ void LimitedOrderBy::initialize(const RowGroup& rg, const JobInfo& jobInfo)
map<uint32_t, uint32_t>::iterator j = keyToIndexMap.find(i->first); map<uint32_t, uint32_t>::iterator j = keyToIndexMap.find(i->first);
idbassert(j != keyToIndexMap.end()); idbassert(j != keyToIndexMap.end());
// MCOL-1052 Ordering direction in CSEP differs from // TODO Ordering direction in CSEP differs from
// internal direction representation. // internal direction representation. This behavior should be fixed
if (i->second) fOrderByCond.push_back(IdbSortSpec(j->second, 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));
} }
// limit row count info // limit row count info
@ -182,8 +177,8 @@ void LimitedOrderBy::finalize()
if (fRowGroup.getRowCount() > 0) if (fRowGroup.getRowCount() > 0)
fDataQueue.push(fData); fDataQueue.push(fData);
// MCOL-1052 The removed check effectivly disables sorting to happen, // MCOL-1052 The removed check effectively disables sorting,
// since fStart = 0; // since fStart = 0 if there is no OFFSET;
if (true) if (true)
{ {
uint64_t newSize = fRowsPerRG * fRowGroup.getRowSize(); uint64_t newSize = fRowsPerRG * fRowGroup.getRowSize();

View File

@ -8009,6 +8009,10 @@ int cp_get_group_plan(THD* thd, SCSEP& csep, cal_impl_if::cal_group_info& gi)
gwi.thd = thd; gwi.thd = thd;
int status = getGroupPlan(gwi, select_lex, csep, gi); 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) if (status > 0)
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
else if (status < 0) 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; 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 } // ORDER BY processing ends here
if ( gi.groupByDistinct ) if ( gi.groupByDistinct )

View File

@ -5581,14 +5581,19 @@ internal_error:
*/ */
/*********************************************************** /***********************************************************
* DESCRIPTION: * 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: * PARAMETERS:
* group_hand - group by handler, that preserves initial table and items lists. . * group_hand - group by handler, that preserves initial
* table - TABLE pointer The table to save the result set in. * table and items lists. .
* table - TABLE pointer The table to save the result
* set in.
* RETURN: * RETURN:
* 0 if success * 0 if success
* HA_ERR_END_OF_FILE if the record set has come to an end * HA_ERR_END_OF_FILE if the record set has come to
* others if something went wrong whilst getting the result set * 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) int ha_calpont_impl_group_by_next(ha_calpont_group_by_handler* group_hand, TABLE* table)
{ {

View File

@ -59,7 +59,8 @@ class IdbCompare;
struct IdbSortSpec struct IdbSortSpec
{ {
int fIndex; int fIndex;
int fAsc; // <ordering specification> ::= ASC | DESC // TODO There are three ordering specs since 10.2
int fAsc; // <ordering specification> ::= ASC | DESC
int fNf; // <null ordering> ::= NULLS FIRST | NULLS LAST int fNf; // <null ordering> ::= NULLS FIRST | NULLS LAST
IdbSortSpec() : fIndex(-1), fAsc(1), fNf(1) {} IdbSortSpec() : fIndex(-1), fAsc(1), fNf(1) {}