diff options
author | unknown <timour@mysql.com> | 2005-10-01 09:35:30 +0300 |
---|---|---|
committer | unknown <timour@mysql.com> | 2005-10-01 09:35:30 +0300 |
commit | 58263844c7e916d271dc1e14661ea1b6e66d5e04 (patch) | |
tree | f5ee23694bda45817fb2d312a039f559d122820f /sql/table.cc | |
parent | 3a806cd674deca9288f7555c03172afa4ada01ac (diff) | |
download | mariadb-git-58263844c7e916d271dc1e14661ea1b6e66d5e04.tar.gz |
Fix for BUG#13410 - qualified reference to a view column in the HAVING clause cannot be resolved.
The problem was then when a column reference was resolved to a view column, the new Item
created for this column contained the name of the view, and not the view alias.
mysql-test/r/view.result:
Additional test for BUG#13410.
mysql-test/t/view.test:
Additional test for BUG#13410.
sql/item.cc:
Correctly cast 'cur_field' to Item_ident because if the original item is
an Item_field, the cur_field is either an Item_field or an Item_ref.
Thus we have to cast cur_field to a common super-class of both.
sql/item.h:
- real_item() may be called before Item_ref::ref is set
(i.e. the Item_ref object was resolved).
- To avoid a crash and to return some meaningful value
in such cases we return 'this'.
sql/sql_base.cc:
- 'item' may be an Item_ref, so we test for the type of the actual
referenced item.
- Correctly cast 'cur_field' to Item_ident because if the original
item is an Item_field, the cur_field is either an Item_field or an
Item_ref. Thus we have to cast cur_field to a common super-class
of both.
sql/table.cc:
- When creating a new Item for a reference to a view column, use the view alias,
and not the real view name.
- Removed old code
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/sql/table.cc b/sql/table.cc index 982d5e7ddc9..4be48bafae4 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2424,22 +2424,6 @@ Field *Natural_join_column::field() const char *Natural_join_column::table_name() { return table_ref->alias; - /* - TODO: - I think that it is sufficient to return just - table->alias, which is correctly set to either - the view name, the table name, or the alias to - the table reference (view or stored table). - */ -#ifdef NOT_YET - if (view_field) - return table_ref->view_name.str; - - DBUG_ASSERT(!strcmp(table_ref->table_name, - table_ref->table->s->table_name)); - return table_ref->table_name; -} -#endif } @@ -2575,7 +2559,7 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref, DBUG_RETURN(field); } Item *item= new Item_direct_view_ref(&view->view->select_lex.context, - field_ref, view->view_name.str, + field_ref, view->alias, name); DBUG_RETURN(item); } |