diff options
author | Igor Babaev <igor@askmonty.org> | 2023-02-27 10:51:22 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2023-02-27 10:51:22 -0800 |
commit | 841e8877ccb8ef5d692a22b4447383a360557326 (patch) | |
tree | 8885b507ee0218a61ccd38a0fe59d713d1a7dcd1 /sql/sql_select.cc | |
parent | 839c7fcf38ef17f9627f63ebec3e82d814912973 (diff) | |
download | mariadb-git-841e8877ccb8ef5d692a22b4447383a360557326.tar.gz |
MDEV-28603 Invalid view when its definition uses TVC as single-value subquery
Subselect_single_value_engine cannot handle table value constructor used as
subquery. That's why any table value constructor TVC used as subquery is
converted into a select over derived table whose specification is TVC.
Currently the names of the columns of the derived table DT are taken from
the first element of TVC and if the k-th component of the element happens
to be a subquery the text representation of this subquery serves as the
name of the k-th column of the derived table. References of all columns of
the derived table DT compose the select list of the result of the conversion.
If a definition of a view contained a table value constructor used as a
subquery and the view was registered after this conversion had been
applied we could register an invalid view definition if the first element
of TVC contained a subquery as its component: the name of this component
was taken from the original subquery, while the name of the corresponding
column of the derived table was taken from the text representation of the
subquery produced by the function SELECT_LEX::print() and these names were
usually differ from each other.
To avoid registration of such invalid views the function SELECT_LEX::print()
now prints the original TVC instead of the select in which this TVC has
been wrapped. Now the specification of registered view looks like as if no
conversions from TVC to selects were done.
Approved by Oleksandr Byelkin <sanja@mariadb.com>
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f83bf32130e..2c12d1c4c65 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -27992,6 +27992,12 @@ void st_select_lex::print(THD *thd, String *str, enum_query_type query_type) return; } + if (is_tvc_wrapper && (query_type & QT_NO_WRAPPERS_FOR_TVC_IN_VIEW)) + { + first_inner_unit()->first_select()->print(thd, str, query_type); + return; + } + if ((query_type & QT_SHOW_SELECT_NUMBER) && thd->lex->all_selects_list && thd->lex->all_selects_list->link_next && |