summaryrefslogtreecommitdiff
path: root/sql/sql_union.cc
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2021-07-31 23:19:51 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2021-07-31 23:19:51 +0200
commitae6bdc6769646a09a8d4d08a42a69174ea677768 (patch)
treec80afdd0e3238dc5092fdcb1439f1390f9a9040b /sql/sql_union.cc
parenta49f5525bbe1bb1f4320bd0db066068a81af62d9 (diff)
parent7841a7eb09208f52fcbab7e80e38c7ca29b1339e (diff)
downloadmariadb-git-ae6bdc6769646a09a8d4d08a42a69174ea677768.tar.gz
Merge branch '10.4' into 10.5
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r--sql/sql_union.cc35
1 files changed, 32 insertions, 3 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index b88d78c0db3..b746b510140 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -30,6 +30,7 @@
#include "filesort.h" // filesort_free_buffers
#include "sql_view.h"
#include "sql_cte.h"
+#include "item_windowfunc.h"
bool mysql_union(THD *thd, LEX *lex, select_result *result,
SELECT_LEX_UNIT *unit, ulong setup_tables_done_option)
@@ -1687,7 +1688,8 @@ cont:
Test if the aggregated data type is OK for a UNION element.
E.g. in case of string data, DERIVATION_NONE is not allowed.
*/
- if (type->type_handler()->union_element_finalize(type))
+ if (type->type() == Item::TYPE_HOLDER && type->type_handler()->
+ union_element_finalize(static_cast<Item_type_holder*>(type)))
goto err;
}
@@ -2561,7 +2563,8 @@ bool st_select_lex_unit::cleanup()
{
DBUG_RETURN(FALSE);
}
- if (with_element && with_element->is_recursive && union_result)
+ if (with_element && with_element->is_recursive && union_result &&
+ with_element->rec_outer_references)
{
select_union_recursive *result= with_element->rec_result;
if (++result->cleanup_count == with_element->rec_outer_references)
@@ -2730,6 +2733,29 @@ static void cleanup_order(ORDER *order)
}
+static void cleanup_window_funcs(List<Item_window_func> &win_funcs)
+{
+ List_iterator_fast<Item_window_func> it(win_funcs);
+ Item_window_func *win_func;
+ while ((win_func= it++))
+ {
+ Window_spec *win_spec= win_func->window_spec;
+ if (!win_spec)
+ continue;
+ if (win_spec->save_partition_list)
+ {
+ win_spec->partition_list= win_spec->save_partition_list;
+ win_spec->save_partition_list= NULL;
+ }
+ if (win_spec->save_order_list)
+ {
+ win_spec->order_list= win_spec->save_order_list;
+ win_spec->save_order_list= NULL;
+ }
+ }
+}
+
+
bool st_select_lex::cleanup()
{
bool error= FALSE;
@@ -2741,6 +2767,8 @@ bool st_select_lex::cleanup()
cleanup_order(group_list.first);
cleanup_ftfuncs(this);
+ cleanup_window_funcs(window_funcs);
+
if (join)
{
List_iterator<TABLE_LIST> ti(leaf_tables);
@@ -2767,7 +2795,8 @@ bool st_select_lex::cleanup()
for (SELECT_LEX_UNIT *lex_unit= first_inner_unit(); lex_unit ;
lex_unit= lex_unit->next_unit())
{
- if (lex_unit->with_element && lex_unit->with_element->is_recursive)
+ if (lex_unit->with_element && lex_unit->with_element->is_recursive &&
+ lex_unit->with_element->rec_outer_references)
continue;
error= (bool) ((uint) error | (uint) lex_unit->cleanup());
}