1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

fix(plugin): MCOL-5236 Take Item from Ref_Item for group by list (#3162) (#3163)

Co-authored-by: Leonid Fedorov <79837786+mariadb-LeonidFedorov@users.noreply.github.com>
This commit is contained in:
Denis Khalikov
2024-06-27 16:25:57 +03:00
committed by GitHub
parent 985cd94402
commit 88e3af4ba5
3 changed files with 76 additions and 12 deletions

View File

@ -498,9 +498,18 @@ bool sortItemIsInGrouping(Item* sort_item, ORDER* groupcol)
// is either Field or Func
// Consider nonConstFunc() check here
if (!found && sort_item->type() == Item::FUNC_ITEM &&
(group_item->type() == Item::FUNC_ITEM || group_item->type() == Item::FIELD_ITEM))
(group_item->type() == Item::FUNC_ITEM || group_item->type() == Item::FIELD_ITEM ||
group_item->type() == Item::REF_ITEM))
{
found = sortItemIsInGroupRec(sort_item, group_item);
// MCOL-5236: see @bug5993 and @bug5916.
Item* item = group_item;
while (item->type() == Item::REF_ITEM)
{
Item_ref* item_ref = static_cast<Item_ref*>(item);
item = *item_ref->ref;
}
found = sortItemIsInGroupRec(sort_item, item);
}
}
@ -8212,18 +8221,18 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
ReturnedColumn* rc = buildSimpleColumn(ifp, gwi);
SimpleColumn* sc = dynamic_cast<SimpleColumn*>(rc);
if (sc)
{
bool found = false;
if (sc)
{
bool found = false;
for (uint32_t j = 0; j < gwi.returnedCols.size(); j++)
{
if (sc->sameColumn(gwi.returnedCols[j].get()))
{
sc->orderPos(j);
found = true;
found = true;
break;
}
}
}
for (uint32_t j = 0; !found && j < gwi.returnedCols.size(); j++)
{
if (strcasecmp(sc->alias().c_str(), gwi.returnedCols[j]->alias().c_str()) == 0)
@ -8233,9 +8242,9 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
break;
}
}
}
else
{
}
else
{
for (uint32_t j = 0; j < gwi.returnedCols.size(); j++)
{
if (ifp->name.length && string(ifp->name.str) == gwi.returnedCols[j].get()->alias())
@ -8245,7 +8254,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
break;
}
}
}
}
if (!rc)
{
@ -9967,7 +9976,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
}
}
srcp->orderPos(groupcol->counter - 1);
srcp->orderPos(groupcol->counter - 1);
gwi.groupByCols.push_back(srcp);
continue;
}