diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-10-21 20:41:24 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-10-21 20:41:24 +0300 |
commit | 4d21a145de11eaff28f98fe4ebed56a803450ce0 (patch) | |
tree | 5c4b00b96e189e3492de198c4080265e81efc832 /sql/sql_select.cc | |
parent | 4f59f9078fd9af1e958f4a30788084598053bf50 (diff) | |
parent | 059a5f11711fd502982abed8781faf9f255fa975 (diff) | |
download | mariadb-git-bb-10.6-MDEV-26769.tar.gz |
Merge 10.6bb-10.6-MDEV-26769
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a50bcce590f..b31e51a737a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -28247,6 +28247,11 @@ void st_select_lex::print(THD *thd, String *str, enum_query_type query_type) //Item List bool first= 1; + /* + outer_select() can not be used here because it is for name resolution + and will return NULL at any end of name resolution chain (view/derived) + */ + bool top_level= (get_master()->get_master() == 0); List_iterator_fast<Item> it(item_list); Item *item; while ((item= it++)) @@ -28256,7 +28261,8 @@ void st_select_lex::print(THD *thd, String *str, enum_query_type query_type) else str->append(','); - if (is_subquery_function() && !item->is_explicit_name()) + if ((is_subquery_function() && !item->is_explicit_name()) || + !item->name.str) { /* Do not print auto-generated aliases in subqueries. It has no purpose @@ -28265,7 +28271,20 @@ void st_select_lex::print(THD *thd, String *str, enum_query_type query_type) item->print(str, query_type); } else - item->print_item_w_name(str, query_type); + { + /* + Do not print illegal names (if it is not top level SELECT). + Top level view checked (and correct name are assigned), + other cases of top level SELECT are not important, because + it is not "table field". + */ + if (top_level || + item->is_explicit_name() || + !check_column_name(item->name.str)) + item->print_item_w_name(str, query_type); + else + item->print(str, query_type); + } } /* |