1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-08 14:22:09 +03:00

Save and restore the group by list columns as the server

optimizer can optimize out the constant columns in this list
This commit is contained in:
Gagan Goel
2019-09-12 11:11:46 -04:00
parent 09a482ea21
commit 7599a9379e

View File

@@ -718,6 +718,25 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
return handler; return handler;
} }
// Save the original group_list as it can be mutated by the
// optimizer which calls the remove_const() function
Group_list_ptrs *group_list_ptrs = NULL;
if (select_lex->group_list.first)
{
void *mem = thd->stmt_arena->alloc(sizeof(Group_list_ptrs));
if (!mem || !(group_list_ptrs = new (mem) Group_list_ptrs(thd->stmt_arena->mem_root)) ||
group_list_ptrs->reserve(select_lex->group_list.elements))
{
return handler;
}
for (ORDER *order = select_lex->group_list.first; order; order = order->next)
{
group_list_ptrs->push_back(order);
}
}
bool unsupported_feature = false; bool unsupported_feature = false;
// Select_handler use the short-cut that effectively disables // Select_handler use the short-cut that effectively disables
// INSERT..SELECT, LDI, SELECT..INTO OUTFILE // INSERT..SELECT, LDI, SELECT..INTO OUTFILE
@@ -749,6 +768,17 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
} }
} }
// Restore back the saved group_list
if (group_list_ptrs)
{
select_lex->group_list.empty();
for (size_t i = 0; i < group_list_ptrs->size(); i++)
{
ORDER *order = (*group_list_ptrs)[i];
select_lex->group_list.link_in_list(order, &order->next);
}
}
// Iterate and traverse through the item list and do not create SH // Iterate and traverse through the item list and do not create SH
// if the unsupported (set/get_user_var) functions are present. // if the unsupported (set/get_user_var) functions are present.
TABLE_LIST* table_ptr = select_lex->get_table_list(); TABLE_LIST* table_ptr = select_lex->get_table_list();