diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2018-12-19 18:57:14 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2018-12-19 18:57:14 +0530 |
commit | 82a4d55d5c569a9adfbd863c928bd357c2e5afed (patch) | |
tree | e5c4521559a1639166012671dc4478204b69081c /sql | |
parent | 0c2fc9b3da467132cba7fd3a9d92995c98057f06 (diff) | |
download | mariadb-git-82a4d55d5c569a9adfbd863c928bd357c2e5afed.tar.gz |
MDEV-15424: Unreasonable SQL Error (1356) on select from view
While printing a view containing a window function we were printing it as an
Item_field object instead of an Item_window_func object. This is incorrect and this
leads to us throwing an error ER_VIEW_INVALID.
Fixed by adjusting the Item_ref:print function.
Also made UDF function aware if there arguments have window function.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.cc | 4 | ||||
-rw-r--r-- | sql/item_func.cc | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/sql/item.cc b/sql/item.cc index 1c0b6cc4043..761c9fbec3d 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -7815,7 +7815,9 @@ void Item_ref::print(String *str, enum_query_type query_type) { if (ref) { - if ((*ref)->type() != Item::CACHE_ITEM && ref_type() != VIEW_REF && + if ((*ref)->type() != Item::CACHE_ITEM && + (*ref)->type() != Item::WINDOW_FUNC_ITEM && + ref_type() != VIEW_REF && !table_name && name && alias_name_used) { THD *thd= current_thd; diff --git a/sql/item_func.cc b/sql/item_func.cc index 512c8fccab0..89ca25bbfd4 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3484,6 +3484,8 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func, if (item->maybe_null) func->maybe_null=1; func->with_sum_func= func->with_sum_func || item->with_sum_func; + func->with_window_func= func->with_window_func || + item->with_window_func; func->with_field= func->with_field || item->with_field; func->with_param= func->with_param || item->with_param; func->with_subselect|= item->with_subselect; |