summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorunknown <timour@mysql.com>2005-10-01 09:35:30 +0300
committerunknown <timour@mysql.com>2005-10-01 09:35:30 +0300
commit20c77c32e3389b748483b295871ae88190c733f6 (patch)
treef5ee23694bda45817fb2d312a039f559d122820f /sql/item.cc
parent8f72171a46b3c841c45ef0fafbd6d59e259fef13 (diff)
downloadmariadb-git-20c77c32e3389b748483b295871ae88190c733f6.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/item.cc')
-rw-r--r--sql/item.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/sql/item.cc b/sql/item.cc
index f826fc1d874..966dbbaec53 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -2973,7 +2973,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
const char *field_name;
ORDER *found_group= NULL;
int found_match_degree= 0;
- Item_field *cur_field;
+ Item_ident *cur_field;
int cur_match_degree= 0;
if (find_item->type() == Item::FIELD_ITEM ||
@@ -2992,7 +2992,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
{
if ((*(cur_group->item))->real_item()->type() == Item::FIELD_ITEM)
{
- cur_field= (Item_field*) *cur_group->item;
+ cur_field= (Item_ident*) *cur_group->item;
cur_match_degree= 0;
DBUG_ASSERT(cur_field->field_name != 0);