List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:March 12 2010 7:52am
Subject:bzr push into mysql-pe branch (Sergey.Glukhov:3966 to 3967)
View as plain text  
 3967 Sergey Glukhov	2010-03-12 [merge]
      5.1-bugteam->mysql-pe merge
     @ mysql-test/r/metadata.result
        5.1-bugteam->mysql-pe merge
     @ mysql-test/t/metadata.test
        5.1-bugteam->mysql-pe merge
     @ sql/item.cc
        5.1-bugteam->mysql-pe merge
     @ sql/item.h
        5.1-bugteam->mysql-pe merge
     @ sql/table.cc
        5.1-bugteam->mysql-pe merge

    modified:
      mysql-test/r/metadata.result
      mysql-test/t/metadata.test
      sql/item.cc
      sql/item.h
      sql/table.cc
 3966 Sergey Vojtovich	2010-03-11 [merge]
      Merge fix for BUG44178 to mysql-pe.

    modified:
      client/mysql.cc
=== modified file 'mysql-test/r/metadata.result'
--- a/mysql-test/r/metadata.result	2010-02-11 04:17:25 +0000
+++ b/mysql-test/r/metadata.result	2010-03-12 06:49:07 +0000
@@ -198,6 +198,17 @@ def				IF(i, d, d)	IF(i, d, d)	10	10	10	
 def				IFNULL(d, d)	IFNULL(d, d)	10	10	10	Y	128	0	63
 def				LEAST(d, d)	LEAST(d, d)	10	10	10	Y	128	0	63
 DROP TABLE t1;
+#
+# Bug#41788 mysql_fetch_field returns org_table == table by a view
+#
+CREATE TABLE t1 (f1 INT);
+CREATE VIEW v1 AS SELECT f1 FROM t1;
+SELECT f1 FROM v1 va;
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def	test	v1	va	f1	f1	3	11	0	Y	32768	0	63
+f1
+DROP VIEW v1;
+DROP TABLE t1;
 End of 5.0 tests
 create table t1(
 # numeric types

=== modified file 'mysql-test/t/metadata.test'
--- a/mysql-test/t/metadata.test	2009-09-30 10:25:50 +0000
+++ b/mysql-test/t/metadata.test	2010-03-12 06:49:07 +0000
@@ -129,6 +129,19 @@ SELECT COALESCE(d, d), IFNULL(d, d), IF(
 
 DROP TABLE t1;
 
+--echo #
+--echo # Bug#41788 mysql_fetch_field returns org_table == table by a view
+--echo #
+
+CREATE TABLE t1 (f1 INT);
+CREATE VIEW v1 AS SELECT f1 FROM t1;
+--enable_metadata
+SELECT f1 FROM v1 va;
+--disable_metadata
+
+DROP VIEW v1;
+DROP TABLE t1;
+
 --echo End of 5.0 tests
 
 # Verify that column metadata is correct for all possible data types.

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2010-03-11 11:13:13 +0000
+++ b/sql/item.cc	2010-03-12 06:49:07 +0000
@@ -588,6 +588,18 @@ Item_ident::Item_ident(Name_resolution_c
 }
 
 
+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)
 */
@@ -6054,6 +6066,20 @@ Item_ref::Item_ref(Name_resolution_conte
 }
 
 
+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.
 

=== modified file 'sql/item.h'
--- a/sql/item.h	2010-03-09 15:48:05 +0000
+++ b/sql/item.h	2010-03-12 06:49:07 +0000
@@ -1580,6 +1580,7 @@ public:
              const char *db_name_arg, const char *table_name_arg,
              const char *field_name_arg);
   Item_ident(THD *thd, Item_ident *item);
+  Item_ident(TABLE_LIST *view_arg, const char *field_name_arg);
   const char *full_name() const;
   void cleanup();
   bool remove_dependence_processor(uchar * arg);
@@ -2451,6 +2452,8 @@ public:
   Item_ref(Name_resolution_context *context_arg, Item **item,
            const char *table_name_arg, const char *field_name_arg,
            bool alias_name_used_arg= FALSE);
+  Item_ref(TABLE_LIST *view_arg, Item **item,
+           const char *field_name_arg, bool alias_name_used_arg= FALSE);
 
   /* Constructor need to process subselect with temporary tables (see Item) */
   Item_ref(THD *thd, Item_ref *item)
@@ -2568,6 +2571,12 @@ public:
   {}
   /* Constructor need to process subselect with temporary tables (see Item) */
   Item_direct_ref(THD *thd, Item_direct_ref *item) : Item_ref(thd, item) {}
+  Item_direct_ref(TABLE_LIST *view_arg, Item **item,
+                  const char *field_name_arg,
+                  bool alias_name_used_arg= FALSE)
+    :Item_ref(view_arg, item, field_name_arg,
+              alias_name_used_arg)
+  {}
 
   double val_real();
   longlong val_int();
@@ -2593,6 +2602,10 @@ public:
   /* Constructor need to process subselect with temporary tables (see Item) */
   Item_direct_view_ref(THD *thd, Item_direct_ref *item)
     :Item_direct_ref(thd, item) {}
+  Item_direct_view_ref(TABLE_LIST *view_arg, Item **item,
+                       const char *field_name_arg)
+    :Item_direct_ref(view_arg, item, field_name_arg)
+  {}
 
   bool fix_fields(THD *, Item **);
   void fix_after_pullout(st_select_lex *new_parent, Item **ref);

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2010-02-25 13:55:28 +0000
+++ b/sql/table.cc	2010-03-12 06:49:07 +0000
@@ -4145,9 +4145,7 @@ Item *create_view_field(THD *thd, TABLE_
   {
     DBUG_RETURN(field);
   }
-  Item *item= new Item_direct_view_ref(&view->view->select_lex.context,
-                                       field_ref, view->alias,
-                                       name);
+  Item *item= new Item_direct_view_ref(view, field_ref, name);
   DBUG_RETURN(item);
 }
 


Attachment: [text/bzr-bundle] bzr/sergey.glukhov@sun.com-20100312064907-3ifr3q3vud44evj9.bundle
Thread
bzr push into mysql-pe branch (Sergey.Glukhov:3966 to 3967)Sergey Glukhov12 Mar 2010