MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:timour Date:October 1 2005 6:35am
Subject:bk commit into 5.0 tree (timour:1.2029) BUG#13410
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of timka. When timka 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.2029 05/10/01 09:35:30 timour@stripped +6 -0
  Fix for BUG#13410 - qualified reference to a view column in the HAVING clause cannot be resolved.
  
  The problem was then when a column reference was resolved to a view column, the new Item
  created for this column contained the name of the view, and not the view alias.

  sql/table.cc
    1.193 05/10/01 09:35:10 timour@stripped +1 -17
    - When creating a new Item for a reference to a view column, use the view alias,
      and not the real view name.
    - Removed old code

  sql/sql_base.cc
    1.307 05/10/01 09:35:10 timour@stripped +2 -2
    - 'item' may be an Item_ref, so we test for the type of the actual
      referenced item.
    - Correctly cast 'cur_field' to Item_ident because if the original
      item is an Item_field, the cur_field is either an Item_field or an
      Item_ref. Thus we have to cast cur_field to a common super-class
      of both.

  sql/item.h
    1.170 05/10/01 09:35:10 timour@stripped +1 -1
    - real_item() may be called before Item_ref::ref is set
      (i.e. the Item_ref object was resolved).
    - To avoid a crash and to return some meaningful value
      in such cases we return 'this'.

  sql/item.cc
    1.185 05/10/01 09:35:10 timour@stripped +2 -2
    Correctly cast 'cur_field' to Item_ident because if the original item is
    an Item_field, the cur_field is either an Item_field or an Item_ref.
    Thus we have to cast cur_field to a common super-class of both.

  mysql-test/t/view.test
    1.114 05/10/01 09:35:10 timour@stripped +2 -0
    Additional test for BUG#13410.

  mysql-test/r/view.result
    1.122 05/10/01 09:35:10 timour@stripped +10 -0
    Additional test for BUG#13410.

# 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:	timour
# Host:	lamia.home
# Root:	/home/timka/mysql/src/5.0-bug-13410

--- 1.184/sql/item.cc	2005-09-29 12:23:44 +03:00
+++ 1.185/sql/item.cc	2005-10-01 09:35:10 +03:00
@@ -2973,7 +2973,7 @@
   const char *field_name;
   ORDER      *found_group= NULL;
   int         found_match_degree= 0;
-  Item_field *cur_field;
+  Item_ident *cur_field;
   int         cur_match_degree= 0;
 
   if (find_item->type() == Item::FIELD_ITEM ||
@@ -2992,7 +2992,7 @@
   {
     if ((*(cur_group->item))->real_item()->type() == Item::FIELD_ITEM)
     {
-      cur_field= (Item_field*) *cur_group->item;
+      cur_field= (Item_ident*) *cur_group->item;
       cur_match_degree= 0;
       
       DBUG_ASSERT(cur_field->field_name != 0);

--- 1.169/sql/item.h	2005-09-28 12:34:49 +03:00
+++ 1.170/sql/item.h	2005-10-01 09:35:10 +03:00
@@ -1619,7 +1619,7 @@
   }
   Item *real_item()
   {
-    return (*ref)->real_item();
+    return (ref && *ref) ? (*ref)->real_item() : this;
   }
   bool walk(Item_processor processor, byte *arg)
   { return (*ref)->walk(processor, arg); }

--- 1.306/sql/sql_base.cc	2005-09-27 06:15:46 +03:00
+++ 1.307/sql/sql_base.cc	2005-10-01 09:35:10 +03:00
@@ -3357,9 +3357,9 @@
 
   for (uint i= 0; (item=li++); i++)
   {
-    if (field_name && item->type() == Item::FIELD_ITEM)
+    if (field_name && item->real_item()->type() == Item::FIELD_ITEM)
     {
-      Item_field *item_field= (Item_field*) item;
+      Item_ident *item_field= (Item_ident*) item;
 
       /*
 	In case of group_concat() with ORDER BY condition in the QUERY

--- 1.192/sql/table.cc	2005-09-22 23:46:51 +03:00
+++ 1.193/sql/table.cc	2005-10-01 09:35:10 +03:00
@@ -2424,22 +2424,6 @@
 const char *Natural_join_column::table_name()
 {
   return table_ref->alias;
-  /*
-    TODO:
-    I think that it is sufficient to return just
-    table->alias, which is correctly set to either
-    the view name, the table name, or the alias to
-    the table reference (view or stored table).
-  */
-#ifdef NOT_YET
-  if (view_field)
-    return table_ref->view_name.str;
-
-  DBUG_ASSERT(!strcmp(table_ref->table_name,
-                      table_ref->table->s->table_name));
-  return table_ref->table_name;
-}
-#endif
 }
 
 
@@ -2575,7 +2559,7 @@
     DBUG_RETURN(field);
   }
   Item *item= new Item_direct_view_ref(&view->view->select_lex.context,
-                                       field_ref, view->view_name.str,
+                                       field_ref, view->alias,
                                        name);
   DBUG_RETURN(item);
 }

--- 1.121/mysql-test/r/view.result	2005-09-27 09:26:57 +03:00
+++ 1.122/mysql-test/r/view.result	2005-10-01 09:35:10 +03:00
@@ -2286,5 +2286,15 @@
 a
 2
 3
+SELECT t_1.a FROM t1 AS t_1 GROUP BY t_1.a HAVING t_1.a IN (1,2,3);
+a
+1
+2
+3
+SELECT v_1.a FROM v1 AS v_1 GROUP BY v_1.a HAVING v_1.a IN (1,2,3);
+a
+1
+2
+3
 DROP VIEW v1;
 DROP TABLE t1;

--- 1.113/mysql-test/t/view.test	2005-09-27 09:26:29 +03:00
+++ 1.114/mysql-test/t/view.test	2005-10-01 09:35:10 +03:00
@@ -2162,6 +2162,8 @@
 CREATE VIEW v1 AS SELECT a,b FROM t1;
 SELECT t1.a FROM t1 GROUP BY t1.a HAVING t1.a > 1;
 SELECT v1.a FROM v1 GROUP BY v1.a HAVING v1.a > 1;
+SELECT t_1.a FROM t1 AS t_1 GROUP BY t_1.a HAVING t_1.a IN (1,2,3);
+SELECT v_1.a FROM v1 AS v_1 GROUP BY v_1.a HAVING v_1.a IN (1,2,3);
 
 DROP VIEW v1;
 DROP TABLE t1;
Thread
bk commit into 5.0 tree (timour:1.2029) BUG#13410timour1 Oct