MDEV-31466 Add optional correlation column list for derived tables
Extend derived table syntax to support column name assignment. (subquery expression) [as|=] ident [comma separated column name list]. Prior to this patch, the optional comma separated column name list is not supported. Processing within the unit of the subquery expression will use original column names, outside the unit will use the new names. For example, in the query select a1, a2 from (select c1, c2, c3 from t1 where c2 > 0) as dt (a1, a2, a3) where a2 > 10; we see the second column of the derived table dt being used both within, (where c2 > 0), and outside, (where a2 > 10), the specification. Both conditions apply to t1.c2. When multiple unit preparations are required, such as when being used within a prepared statement or procedure, original column names are needed for correct resolution. Original names are reset within mysql_derived_reinit(). Item_holder items, used for result tables in both TVC and union preparations are renamed before use within st_select_lex_unit::prepare(). During wildcard expansion, if column names are present, items names are set directly after creation. Reviewed by Igor Babaev (igor@mariadb.com)
Showing
This diff is collapsed.
This diff is collapsed.
Please register or sign in to comment