summaryrefslogtreecommitdiff
path: root/sql/sql_lex.cc
diff options
context:
space:
mode:
authorTor Didriksen <tor.didriksen@oracle.com>2012-04-18 13:14:05 +0200
committerTor Didriksen <tor.didriksen@oracle.com>2012-04-18 13:14:05 +0200
commitd612986b365db438f83f2fab10437b0ab3fd38e7 (patch)
tree4d01c9aee49ac506a5ef0f801599bedd03001e6e /sql/sql_lex.cc
parenta9a7e6ea248d411921a12f1c1f5f9e23a464602c (diff)
downloadmariadb-git-d612986b365db438f83f2fab10437b0ab3fd38e7.tar.gz
Backport 5.5=>5.1 Patch for Bug#13805127:
Stored program cache produces wrong result in same THD.
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r--sql/sql_lex.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 4a0553ad59b..fd9367b99f2 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -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