summaryrefslogtreecommitdiff
path: root/sql/sql_cte.cc
diff options
context:
space:
mode:
authorGalina Shalygina <galina.shalygina@mariadb.com>2018-02-20 01:16:50 +0200
committerGalina Shalygina <galina.shalygina@mariadb.com>2018-02-20 01:16:50 +0200
commita128fe4346a466aa8e059baa620a3b689fa21241 (patch)
treef31e3486a56a466d8770b99bdc232b7a4d544f40 /sql/sql_cte.cc
parent84e8e07e8e185fe98ad2932bd32e94424fb9383a (diff)
downloadmariadb-git-a128fe4346a466aa8e059baa620a3b689fa21241.tar.gz
MDEV-14297: Lost name of a explicitly named CTE column used in
the non-recursive CTE via prepared statement The problem appears as the column names of the CTE were allocated on the wrong MEMROOT and after the preparation of the statement they disappear. To fix it in the procedure With_element::rename_columns_of_derived_unit the CTE column names are now allocated in the permanent MEMROOT for the prepared statements and stored procedures.
Diffstat (limited to 'sql/sql_cte.cc')
-rw-r--r--sql/sql_cte.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc
index ac27f1713f9..dd46295d799 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -910,12 +910,19 @@ With_element::rename_columns_of_derived_unit(THD *thd,
my_error(ER_WITH_COL_WRONG_LIST, MYF(0));
return true;
}
+
+ Query_arena *arena, backup;
+ arena= thd->activate_stmt_arena_if_needed(&backup);
+
/* Rename the columns of the first select in the unit */
while ((item= it++, name= nm++))
{
item->set_name(thd, name->str, (uint) name->length, system_charset_info);
item->is_autogenerated_name= false;
}
+
+ if (arena)
+ thd->restore_active_arena(arena, &backup);
}
else
make_valid_column_names(thd, select->item_list);