mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Backport 5.5=>5.1 Patch for Bug#13805127:
Stored program cache produces wrong result in same THD.
This commit is contained in:
@ -305,6 +305,8 @@ void lex_start(THD *thd)
|
||||
lex->select_lex.sql_cache= SELECT_LEX::SQL_CACHE_UNSPECIFIED;
|
||||
lex->select_lex.init_order();
|
||||
lex->select_lex.group_list.empty();
|
||||
if (lex->select_lex.group_list_ptrs)
|
||||
lex->select_lex.group_list_ptrs->clear();
|
||||
lex->describe= 0;
|
||||
lex->subqueries= FALSE;
|
||||
lex->context_analysis_only= 0;
|
||||
@ -1632,6 +1634,8 @@ void st_select_lex::init_select()
|
||||
{
|
||||
st_select_lex_node::init_select();
|
||||
group_list.empty();
|
||||
if (group_list_ptrs)
|
||||
group_list_ptrs->clear();
|
||||
type= db= 0;
|
||||
having= 0;
|
||||
table_join_options= 0;
|
||||
@ -2901,6 +2905,8 @@ static void fix_prepare_info_in_table_list(THD *thd, TABLE_LIST *tbl)
|
||||
The passed WHERE and HAVING are to be saved for the future executions.
|
||||
This function saves it, and returns a copy which can be thrashed during
|
||||
this execution of the statement. By saving/thrashing here we mean only
|
||||
We also save the chain of ORDER::next in group_list, in case
|
||||
the list is modified by remove_const().
|
||||
AND/OR trees.
|
||||
The function also calls fix_prepare_info_in_table_list that saves all
|
||||
ON expressions.
|
||||
@ -2912,6 +2918,19 @@ void st_select_lex::fix_prepare_information(THD *thd, Item **conds,
|
||||
if (!thd->stmt_arena->is_conventional() && first_execution)
|
||||
{
|
||||
first_execution= 0;
|
||||
if (group_list.first)
|
||||
{
|
||||
if (!group_list_ptrs)
|
||||
{
|
||||
void *mem= thd->stmt_arena->alloc(sizeof(Group_list_ptrs));
|
||||
group_list_ptrs= new (mem) Group_list_ptrs(thd->stmt_arena->mem_root);
|
||||
}
|
||||
group_list_ptrs->reserve(group_list.elements);
|
||||
for (ORDER *order= group_list.first; order; order= order->next)
|
||||
{
|
||||
group_list_ptrs->push_back(order);
|
||||
}
|
||||
}
|
||||
if (*conds)
|
||||
{
|
||||
prep_where= *conds;
|
||||
@ -3016,3 +3035,6 @@ bool st_lex::is_partition_management() const
|
||||
alter_info.flags == ALTER_REORGANIZE_PARTITION));
|
||||
}
|
||||
|
||||
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
|
||||
template class Mem_root_array<ORDER*, true>;
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user