MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:gluh Date:June 26 2006 2:56pm
Subject:bk commit into 5.0 tree (gluh:1.2193) BUG#19671
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of gluh. When gluh 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
  1.2193 06/06/26 19:56:14 gluh@stripped +4 -0
  Bug#19671 mysql_list_fields returns incorrect table name for VIEWs
  After view onening real view db name and table name are placed
  into table_list->view_db & table_list->view_name.
  Item_field class does not handle these names properly during 
  intialization of Send_field.
  The fix is to use new class 'Item_ident_for_show' 
  which sets correct view db name and table name for Send_field.

  tests/mysql_client_test.c
    1.188 06/06/26 19:54:38 gluh@stripped +34 -0
    Bug#19671 mysql_list_fields returns incorrect table name for VIEWs
    test case

  sql/sql_show.cc
    1.320 06/06/26 19:54:38 gluh@stripped +8 -1
    Bug#19671 mysql_list_fields returns incorrect table name for VIEWs
     new Item_ident_for_show is used for views

  sql/item.h
    1.201 06/06/26 19:54:38 gluh@stripped +22 -0
    Bug#19671 mysql_list_fields returns incorrect table name for VIEWs
     new Item_ident_for_show class which correctly sets view db and table names
     for Send_field.

  sql/item.cc
    1.225 06/06/26 19:54:38 gluh@stripped +12 -1
    Bug#19671 mysql_list_fields returns incorrect table name for VIEWs
     new Item_ident_for_show class which correctly sets view db and table names
     for Send_field.

# 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:	gluh
# Host:	eagle.intranet.mysql.r18.ru
# Root:	/home/gluh/MySQL/Test/5.0

--- 1.224/sql/item.cc	Thu May 18 23:25:38 2006
+++ 1.225/sql/item.cc	Mon Jun 26 19:54:38 2006
@@ -1457,7 +1457,18 @@ bool agg_item_charsets(DTCollation &coll
 }
 
 
-
+void Item_ident_for_show::make_field(Send_field *tmp_field)
+{
+  tmp_field->table_name= tmp_field->org_table_name= table_name;
+  tmp_field->db_name= db_name;
+  tmp_field->col_name= tmp_field->org_col_name= field->field_name;
+  tmp_field->charsetnr= field->charset()->number;
+  tmp_field->length=field->field_length;
+  tmp_field->type=field->type();
+  tmp_field->flags= field->table->maybe_null ? 
+    (field->flags & ~NOT_NULL_FLAG) : field->flags;
+  tmp_field->decimals= 0;
+}
 
 /**********************************************/
 

--- 1.200/sql/item.h	Thu Jun 15 00:54:05 2006
+++ 1.201/sql/item.h	Mon Jun 26 19:54:38 2006
@@ -1142,6 +1142,28 @@ public:
                             bool any_privileges);
 };
 
+
+class Item_ident_for_show :public Item
+{
+public:
+  Field *field;
+  const char *db_name;
+  const char *table_name;
+
+  Item_ident_for_show(Field *par_field, const char *db_arg,
+                      const char *table_name_arg)
+    :field(par_field), db_name(db_arg), table_name(table_name_arg)
+  {}
+
+  enum Type type() const { return FIELD_ITEM; }
+  double val_real() { return field->val_real(); }
+  longlong val_int() { return field->val_int(); }
+  String *val_str(String *str) { return field->val_str(str); }
+  my_decimal *val_decimal(my_decimal *dec) { return field->val_decimal(dec); }
+  void make_field(Send_field *tmp_field);
+};
+
+
 class Item_equal;
 class COND_EQUAL;
 

--- 1.319/sql/sql_show.cc	Tue Jun  6 11:25:25 2006
+++ 1.320/sql/sql_show.cc	Mon Jun 26 19:54:38 2006
@@ -580,7 +580,14 @@ mysqld_list_fields(THD *thd, TABLE_LIST 
   {
     if (!wild || !wild[0] || 
         !wild_case_compare(system_charset_info, field->field_name,wild))
-      field_list.push_back(new Item_field(field));
+    {
+      if (table_list->view)
+        field_list.push_back(new Item_ident_for_show(field,
+                                                     table_list->view_db.str,
+                                                     table_list->view_name.str));
+      else
+        field_list.push_back(new Item_field(field));
+    }
   }
   restore_record(table, s->default_values);              // Get empty record
   if (thd->protocol->send_fields(&field_list, Protocol::SEND_DEFAULTS |

--- 1.187/tests/mysql_client_test.c	Mon Jun 19 02:16:16 2006
+++ 1.188/tests/mysql_client_test.c	Mon Jun 26 19:54:38 2006
@@ -8311,6 +8311,39 @@ static void test_list_fields()
 }
 
 
+static void test_bug19671()
+{
+  MYSQL_RES *result;
+  int rc;
+  myheader("test_bug19671");
+
+  rc= mysql_query(mysql, "drop table if exists t1");
+  myquery(rc);
+
+  rc= mysql_query(mysql, "drop view if exists v1");
+  myquery(rc);
+
+  rc= mysql_query(mysql, "create table t1(f1 int)");
+  myquery(rc);
+
+  rc= mysql_query(mysql, "create view v1 as select va.* from t1 va");
+  myquery(rc);
+
+  result= mysql_list_fields(mysql, "v1", NULL);
+  mytest(result);
+
+  rc= my_process_result_set(result);
+  DIE_UNLESS(rc == 0);
+
+  verify_prepare_field(result, 0, "f1", "f1", MYSQL_TYPE_LONG,
+                       "v1", "v1", current_db, 11, "0");
+
+  mysql_free_result(result);
+  myquery(mysql_query(mysql, "drop view v1"));
+  myquery(mysql_query(mysql, "drop table t1"));
+}
+
+
 /* Test a memory ovverun bug */
 
 static void test_mem_overun()
@@ -15195,6 +15228,7 @@ static struct my_tests_st my_tests[]= {
   { "test_bug15613", test_bug15613 },
   { "test_bug14169", test_bug14169 },
   { "test_bug17667", test_bug17667 },
+  { "test_bug19671", test_bug19671},
   { 0, 0 }
 };
 
Thread
bk commit into 5.0 tree (gluh:1.2193) BUG#19671gluh26 Jun