1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

Merge pull request #875 from tntnatbry/fix-gbh-aggregate

Build an aggregate column from the extended select list in the group by handler.
This commit is contained in:
Andrew Hutchings
2019-09-26 08:47:56 +01:00
committed by GitHub
2 changed files with 14 additions and 4 deletions

View File

@ -3121,7 +3121,7 @@ CalpontSystemCatalog::ColType colType_MysqlToIDB (const Item* item)
return ct; return ct;
} }
ReturnedColumn* buildReturnedColumn(Item* item, gp_walk_info& gwi, bool& nonSupport, bool pushdownHand) ReturnedColumn* buildReturnedColumn(Item* item, gp_walk_info& gwi, bool& nonSupport, bool pushdownHand, bool isRefItem)
{ {
ReturnedColumn* rc = NULL; ReturnedColumn* rc = NULL;
@ -3141,6 +3141,12 @@ ReturnedColumn* buildReturnedColumn(Item* item, gp_walk_info& gwi, bool& nonSupp
case Item::FIELD_ITEM: case Item::FIELD_ITEM:
{ {
Item_field* ifp = (Item_field*)item; Item_field* ifp = (Item_field*)item;
if (isRefItem && gwi.isGroupByHandler && !gwi.extSelAggColsItems.empty())
{
return buildAggFrmTempField(ifp, gwi);
}
return buildSimpleColumn(ifp, gwi); return buildSimpleColumn(ifp, gwi);
} }
case Item::CONST_ITEM: case Item::CONST_ITEM:
@ -5615,7 +5621,7 @@ void gp_walk(const Item* item, void* arg)
if (col->type() != Item::COND_ITEM) if (col->type() != Item::COND_ITEM)
{ {
rc = buildReturnedColumn(col, *gwip, gwip->fatalParseError); rc = buildReturnedColumn(col, *gwip, gwip->fatalParseError, false, true);
if ( col->type() == Item::FIELD_ITEM ) if ( col->type() == Item::FIELD_ITEM )
gwip->fatalParseError = false; gwip->fatalParseError = false;
@ -8108,6 +8114,7 @@ int cp_get_group_plan(THD* thd, SCSEP& csep, cal_impl_if::cal_group_info& gi)
SELECT_LEX *select_lex = gi.groupByTables->select_lex; SELECT_LEX *select_lex = gi.groupByTables->select_lex;
gp_walk_info gwi; gp_walk_info gwi;
gwi.thd = thd; gwi.thd = thd;
gwi.isGroupByHandler = true;
int status = getGroupPlan(gwi, *select_lex, csep, gi); int status = getGroupPlan(gwi, *select_lex, csep, gi);
#ifdef DEBUG_WALK_COND #ifdef DEBUG_WALK_COND

View File

@ -157,6 +157,8 @@ struct gp_walk_info
bool cs_vtable_is_update_with_derive; bool cs_vtable_is_update_with_derive;
bool cs_vtable_impossible_where_on_union; bool cs_vtable_impossible_where_on_union;
bool isGroupByHandler;
gp_walk_info() : sessionid(0), gp_walk_info() : sessionid(0),
fatalParseError(false), fatalParseError(false),
condPush(false), condPush(false),
@ -175,7 +177,8 @@ struct gp_walk_info
recursionHWM(0), recursionHWM(0),
inCaseStmt(false), inCaseStmt(false),
cs_vtable_is_update_with_derive(false), cs_vtable_is_update_with_derive(false),
cs_vtable_impossible_where_on_union(false) cs_vtable_impossible_where_on_union(false),
isGroupByHandler(false)
{} {}
~gp_walk_info() {} ~gp_walk_info() {}
@ -358,7 +361,7 @@ const std::string bestTableName(const Item_field* ifp);
bool isMCSTable(TABLE* table_ptr); bool isMCSTable(TABLE* table_ptr);
// execution plan util functions prototypes // execution plan util functions prototypes
execplan::ReturnedColumn* buildReturnedColumn(Item* item, gp_walk_info& gwi, bool& nonSupport, bool pushdownHand = false); execplan::ReturnedColumn* buildReturnedColumn(Item* item, gp_walk_info& gwi, bool& nonSupport, bool pushdownHand = false, bool isRefItem = false);
execplan::ReturnedColumn* buildFunctionColumn(Item_func* item, gp_walk_info& gwi, bool& nonSupport, bool pushdownHand = false, bool selectBetweenIn = false); execplan::ReturnedColumn* buildFunctionColumn(Item_func* item, gp_walk_info& gwi, bool& nonSupport, bool pushdownHand = false, bool selectBetweenIn = false);
execplan::ArithmeticColumn* buildArithmeticColumn(Item_func* item, gp_walk_info& gwi, bool& nonSupport, bool pushdownHand = false); execplan::ArithmeticColumn* buildArithmeticColumn(Item_func* item, gp_walk_info& gwi, bool& nonSupport, bool pushdownHand = false);
execplan::ConstantColumn* buildDecimalColumn(Item* item, gp_walk_info& gwi); execplan::ConstantColumn* buildDecimalColumn(Item* item, gp_walk_info& gwi);