summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorSergey Glukhov <Sergey.Glukhov@sun.com>2010-03-12 10:33:16 +0400
committerSergey Glukhov <Sergey.Glukhov@sun.com>2010-03-12 10:33:16 +0400
commitb8132a8d946bde553834c37785bbe53008f1e925 (patch)
tree8c5e7ceda5785c052e709a71c6a64f50b2e93eae /sql/item.cc
parentb182c9bd2030c3b3c548157d1bc4c01c306b2c5c (diff)
downloadmariadb-git-b8132a8d946bde553834c37785bbe53008f1e925.tar.gz
Bug#41788 mysql_fetch_field returns org_table == table by a view
The problem is that Item_direct_view_ref which is inherited from Item_ident updates orig_table_name and table_name with the same values. The fix is introduction of new constructor into Item_ident and up which updates orig_table_name and table_name separately. mysql-test/r/metadata.result: test case mysql-test/t/metadata.test: test case sql/item.cc: new constructor which updates orig_table_name and table_name separately. sql/item.h: new constructor which updates orig_table_name and table_name separately. sql/table.cc: used new constructor
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/sql/item.cc b/sql/item.cc
index ec4c2e6e662..e34905a2e7f 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -556,6 +556,18 @@ Item_ident::Item_ident(Name_resolution_context *context_arg,
}
+Item_ident::Item_ident(TABLE_LIST *view_arg, const char *field_name_arg)
+ :orig_db_name(NullS), orig_table_name(view_arg->table_name),
+ orig_field_name(field_name_arg), context(&view_arg->view->select_lex.context),
+ db_name(NullS), table_name(view_arg->alias),
+ field_name(field_name_arg),
+ alias_name_used(FALSE), cached_field_index(NO_CACHED_FIELD_INDEX),
+ cached_table(NULL), depended_from(NULL)
+{
+ name = (char*) field_name_arg;
+}
+
+
/**
Constructor used by Item_field & Item_*_ref (see Item comment)
*/
@@ -5721,6 +5733,20 @@ Item_ref::Item_ref(Name_resolution_context *context_arg,
}
+Item_ref::Item_ref(TABLE_LIST *view_arg, Item **item,
+ const char *field_name_arg, bool alias_name_used_arg)
+ :Item_ident(view_arg, field_name_arg),
+ result_field(NULL), ref(item)
+{
+ alias_name_used= alias_name_used_arg;
+ /*
+ This constructor is used to create some internal references over fixed items
+ */
+ if (ref && *ref && (*ref)->fixed)
+ set_properties();
+}
+
+
/**
Resolve the name of a reference to a column reference.