summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@macbook.gmz>2006-11-09 16:55:42 +0200
committerunknown <gkodinov/kgeorge@macbook.gmz>2006-11-09 16:55:42 +0200
commitaa4beb220e7063eb82ca192e9585d6891231b501 (patch)
tree5dedc2a9ee9c23a4508bde184e3af51a70b25f7b /sql/item.cc
parent82bbba165bf3d3ed4760f703a2e2f3d6772554c1 (diff)
downloadmariadb-git-aa4beb220e7063eb82ca192e9585d6891231b501.tar.gz
Bug #20191: getTableName gives wrong or inconsistent result when using VIEWs
When compiling GROUP BY Item_ref instances are dereferenced in setup_copy_fields(), i.e. replaced with the corresponding Item_field (if they point to one) or Item_copy_string for the other cases. Since the Item_ref (in the Item_field case) is no longer used the information about the aliases stored in it is lost. Fixed by preserving the column, table and DB alias on dereferencing Item_ref mysql-test/r/metadata.result: Bug #20191: getTableName gives wrong or inconsistent result when using VIEWs - test case mysql-test/t/metadata.test: Bug #20191: getTableName gives wrong or inconsistent result when using VIEWs - test case sql/item.cc: Bug #20191: getTableName gives wrong or inconsistent result when using VIEWs - use the table and db name to fill up the metadata for columns sql/sql_select.cc: Bug #20191: getTableName gives wrong or inconsistent result when using VIEWs - preserve the field, table and DB name on dereferencing an Item_ref
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/sql/item.cc b/sql/item.cc
index dc92edd651d..76f0332b4ab 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -4202,6 +4202,10 @@ void Item_field::make_field(Send_field *tmp_field)
DBUG_ASSERT(tmp_field->table_name != 0);
if (name)
tmp_field->col_name=name; // Use user supplied name
+ if (table_name)
+ tmp_field->table_name= table_name;
+ if (db_name)
+ tmp_field->db_name= db_name;
}