List:Commits« Previous MessageNext Message »
From:<gshchepa Date:June 20 2007 7:25am
Subject:bk commit into 5.0 tree (gshchepa:1.2522) BUG#28898
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of uchum. When uchum does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-06-20 12:25:07+05:00, gshchepa@stripped +5 -0
  Fixed bug #28898.
  For a join query with GROUP BY and/or ORDER BY and a view reference
  in the FROM list the metadata erroneously showed empty table aliases
  and database names for the view columns.
  

  mysql-test/r/metadata.result@stripped, 2007-06-20 12:18:53+05:00, gshchepa@stripped +41 -0
    Updated test case for bug #28898.

  mysql-test/t/metadata.test@stripped, 2007-06-20 12:18:52+05:00, gshchepa@stripped +21 -0
    Updated test case for bug #28898.

  sql/item.cc@stripped, 2007-06-20 12:18:52+05:00, gshchepa@stripped +15 -0
    Fixed bug #28898.
    The Item_ref::get_tmp_table_item method has been modified
    to copy pointers to the table alias and database name to the new
    Item_field object created for a field stored in the temporary
    table.

  sql/item.h@stripped, 2007-06-20 12:18:42+05:00, gshchepa@stripped +1 -5
    Fixed bug #28898.
    Body of Item_ref::get_tmp_table_item method has been moved
    to item.cc file.

  sql/sql_select.cc@stripped, 2007-06-20 12:18:54+05:00, gshchepa@stripped +7 -0
    Fixed bug #28898.
    The change_to_use_tmp_fields function has been modified to
    to copy pointers to the table alias and database name from
    the Item_ref objects to the new Item_field objects created
    for fields stored in the temporary table.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	gshchepa
# Host:	gleb.loc
# Root:	/home/uchum/work/bk/5.0-opt-28898

--- 1.272/sql/item.cc	2007-06-14 16:37:34 +05:00
+++ 1.273/sql/item.cc	2007-06-20 12:18:52 +05:00
@@ -5501,6 +5501,21 @@ void Item_ref::make_field(Send_field *fi
 }
 
 
+Item *Item_ref::get_tmp_table_item(THD *thd)
+{
+  if (!result_field)
+    return (*ref)->get_tmp_table_item(thd);
+
+  Item_field *item= new Item_field(result_field);
+  if (item)
+  {
+    item->table_name= table_name;
+    item->db_name= db_name;
+  }
+  return item;
+}
+
+
 void Item_ref_null_helper::print(String *str)
 {
   str->append(STRING_WITH_LEN("<ref_null_helper>("));

--- 1.232/sql/item.h	2007-06-14 16:37:34 +05:00
+++ 1.233/sql/item.h	2007-06-20 12:18:42 +05:00
@@ -1904,11 +1904,7 @@ public:
   enum_field_types field_type() const   { return (*ref)->field_type(); }
   Field *get_tmp_table_field()
   { return result_field ? result_field : (*ref)->get_tmp_table_field(); }
-  Item *get_tmp_table_item(THD *thd)
-  { 
-    return (result_field ? new Item_field(result_field) :
-                          (*ref)->get_tmp_table_item(thd));
-  }
+  Item *get_tmp_table_item(THD *thd);
   table_map used_tables() const		
   {
     return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables(); 

--- 1.531/sql/sql_select.cc	2007-06-14 16:41:04 +05:00
+++ 1.532/sql/sql_select.cc	2007-06-20 12:18:54 +05:00
@@ -14241,6 +14241,13 @@ change_to_use_tmp_fields(THD *thd, Item 
 	if (!item_field)
 	  DBUG_RETURN(TRUE);                    // Fatal error
 	item_field->name= item->name;
+        if (item->type() == Item::REF_ITEM)
+        {
+          Item_field *ifield= (Item_field *) item_field;
+          Item_ref *iref= (Item_ref *) item;
+          ifield->table_name= iref->table_name;
+          ifield->db_name= iref->db_name;
+        }
 #ifndef DBUG_OFF
 	if (_db_on_ && !item_field->name)
 	{

--- 1.16/mysql-test/r/metadata.result	2007-05-30 11:55:36 +05:00
+++ 1.17/mysql-test/r/metadata.result	2007-06-20 12:18:53 +05:00
@@ -140,4 +140,45 @@ Catalog	Database	Table	Table_alias	Colum
 def			a	v_small	v_small	3	9	9	N	32769	0	63
 v_small
 214748364
+CREATE TABLE t1 (c1 CHAR(1));
+CREATE TABLE t2 (c2 CHAR(1));
+CREATE VIEW v1 AS SELECT t1.c1 FROM t1;
+CREATE VIEW v2 AS SELECT t2.c2 FROM t2;
+INSERT INTO t1 VALUES ('1'), ('2'), ('3');
+INSERT INTO t2 VALUES ('1'), ('2'), ('3'), ('2');
+SELECT v1.c1 FROM v1 JOIN t2 ON c1=c2 ORDER BY 1;
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def	test	t1	v1	c1	c1	254	1	1	Y	0	0	8
+c1
+1
+2
+2
+3
+SELECT v1.c1, v2.c2 FROM v1 JOIN v2 ON c1=c2;
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def	test	t1	v1	c1	c1	254	1	1	Y	0	0	8
+def	test	t2	v2	c2	c2	254	1	1	Y	0	0	8
+c1	c2
+1	1
+2	2
+3	3
+2	2
+SELECT v1.c1, v2.c2 FROM v1 JOIN v2 ON c1=c2 GROUP BY v1.c1;
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def	test	t1	v1	c1	c1	254	1	1	Y	32768	0	8
+def	test	t2	v2	c2	c2	254	1	1	Y	0	0	8
+c1	c2
+1	1
+2	2
+3	3
+SELECT v1.c1, v2.c2 FROM v1 JOIN v2 ON c1=c2 GROUP BY v1.c1 ORDER BY v2.c2;
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def	test	t1	v1	c1	c1	254	1	1	Y	32768	0	8
+def	test	t2	v2	c2	c2	254	1	1	Y	0	0	8
+c1	c2
+1	1
+2	2
+3	3
+DROP VIEW v1;
+DROP TABLE t1,t2;
 End of 5.0 tests

--- 1.7/mysql-test/t/metadata.test	2007-05-30 11:55:36 +05:00
+++ 1.8/mysql-test/t/metadata.test	2007-06-20 12:18:52 +05:00
@@ -90,5 +90,26 @@ select a.* from (select 2147483648 as v_
 select a.* from (select 214748364 as v_small) a;
 --disable_metadata
 
+#
+# Bug #28898: table alias and database name of VIEW columns is empty in the
+# metadata of # SELECT statement where join is executed via temporary table.
+#
+
+CREATE TABLE t1 (c1 CHAR(1));
+CREATE TABLE t2 (c2 CHAR(1));
+CREATE VIEW v1 AS SELECT t1.c1 FROM t1;
+CREATE VIEW v2 AS SELECT t2.c2 FROM t2;
+INSERT INTO t1 VALUES ('1'), ('2'), ('3');
+INSERT INTO t2 VALUES ('1'), ('2'), ('3'), ('2');
+
+--enable_metadata
+SELECT v1.c1 FROM v1 JOIN t2 ON c1=c2 ORDER BY 1;
+SELECT v1.c1, v2.c2 FROM v1 JOIN v2 ON c1=c2;
+SELECT v1.c1, v2.c2 FROM v1 JOIN v2 ON c1=c2 GROUP BY v1.c1;
+SELECT v1.c1, v2.c2 FROM v1 JOIN v2 ON c1=c2 GROUP BY v1.c1 ORDER BY v2.c2;
+--disable_metadata
+
+DROP VIEW v1;
+DROP TABLE t1,t2;
 
 --echo End of 5.0 tests
Thread
bk commit into 5.0 tree (gshchepa:1.2522) BUG#28898gshchepa20 Jun