List:Internals« Previous MessageNext Message »
From:igor Date:July 25 2005 9:57pm
Subject:bk commit into 5.0 tree (igor:1.1895) BUG#11412
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor 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.1895 05/07/25 12:57:23 igor@stripped +5 -0
  sql_select.cc:
    Fixed bug #11412.
    Reversed the patch of cs 1.1934 for the function 
    create_tmp_table. Modified the function to support
    tem_ref objects created for view fields.
  item_buff.cc:
    Fixed bug #11412.
    Modified implementation of new_Cached_item to support
    cacheing of view fields.
  item.h:
    Fixed bug #11412.
    Changed implementation of Item_ref::get_tmp_table_field and
    added Item_ref::get_tmp_table_item to support Item_ref objects
    created for view fields.
  view.test, view.result:
    Added a test case for bug #11412.

  sql/sql_select.cc
    1.344 05/07/25 12:51:44 igor@stripped +23 -24
    Fixed bug #11412.
    Reversed the patch of cs 1.1934 for the function 
    create_tmp_table. Modified the function to support
    tem_ref objects created for view fields.

  sql/item_buff.cc
    1.18 05/07/25 12:46:12 igor@stripped +3 -3
    Fixed bug #11412.
    Modified implementation of new_Cached_item to support
    cacheing of view fields.

  sql/item.h
    1.156 05/07/25 12:41:50 igor@stripped +5 -2
    Fixed bug #11412.
    Changed implementation of Item_ref::get_tmp_table_field and
    added Item_ref::get_tmp_table_item to support Item_ref objects
    created for view fields.

  mysql-test/t/view.test
    1.90 05/07/25 09:07:39 igor@stripped +25 -1
    Added a test case for bug #11412.

  mysql-test/r/view.result
    1.96 05/07/25 09:06:53 igor@stripped +23 -0
    Added a test case for bug #11412.

# 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:	igor
# Host:	rurik.mysql.com
# Root:	/home/igor/dev/mysql-5.0-0

--- 1.155/sql/item.h	Tue Jul 19 09:06:42 2005
+++ 1.156/sql/item.h	Mon Jul 25 12:41:50 2005
@@ -1464,7 +1464,10 @@
   void save_org_in_field(Field *field)	{ (*ref)->save_org_in_field(field); }
   enum Item_result result_type () const { return (*ref)->result_type(); }
   enum_field_types field_type() const   { return (*ref)->field_type(); }
-  Field *get_tmp_table_field() { return result_field; }
+  Field *get_tmp_table_field()
+  { return result_field ? result_field : (*ref)->get_tmp_table_field(); }
+  Item *get_tmp_table_item(THD *thd)
+  { return (*ref)->get_tmp_table_item(thd); }
   table_map used_tables() const		
   { 
     return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables(); 
@@ -1702,7 +1705,7 @@
 public:
   Cached_item_field(Item_field *item)
   {
-    field=item->field;
+    field= item->field;
     buff= (char*) sql_calloc(length=field->pack_length());
   }
   bool cmp(void);

--- 1.17/sql/item_buff.cc	Wed Jun 22 02:11:18 2005
+++ 1.18/sql/item_buff.cc	Mon Jul 25 12:46:12 2005
@@ -25,9 +25,9 @@
 
 Cached_item *new_Cached_item(THD *thd, Item *item)
 {
-  if (item->type() == Item::FIELD_ITEM &&
-      !(((Item_field *) item)->field->flags & BLOB_FLAG))
-    return new Cached_item_field((Item_field *) item);
+  if (item->real_item()->type() == Item::FIELD_ITEM &&
+      !(((Item_field *) (item->real_item()))->field->flags & BLOB_FLAG))
+    return new Cached_item_field((Item_field *) (item->real_item()));
   switch (item->result_type()) {
   case STRING_RESULT:
     return new Cached_item_str(thd, (Item_field *) item);

--- 1.343/sql/sql_select.cc	Wed Jul 20 09:02:26 2005
+++ 1.344/sql/sql_select.cc	Mon Jul 25 12:51:44 2005
@@ -8026,6 +8026,12 @@
                         bool table_cant_handle_bit_fields,
                         uint convert_blob_length)
 {
+  Item *org_item= item;
+  if (item->real_item()->type() == Item::FIELD_ITEM)
+  {
+    item= item->real_item();
+    type= item->type();
+  }
   switch (type) {
   case Item::SUM_FUNC_ITEM:
   {
@@ -8038,30 +8044,22 @@
   case Item::FIELD_ITEM:
   case Item::DEFAULT_VALUE_ITEM:
   {
-    Item_field *field= (Item_field*) item;
-    if (table_cant_handle_bit_fields && field->field->type() ==
FIELD_TYPE_BIT)
-      return create_tmp_field_from_item(thd, item, table, copy_func,
-                                        modify_item, convert_blob_length);
-    return create_tmp_field_from_field(thd, (*from_field= field->field),
-                                       item->name, table,
-                                       modify_item ? (Item_field*) item : NULL,
-                                       convert_blob_length);
-  }
-  case Item::REF_ITEM:
-  {
-    Item *tmp_item;
-    if ((tmp_item= item->real_item())->type() == Item::FIELD_ITEM)
+    if (org_item->type() != Item::REF_ITEM ||
+        !((Item_ref *)org_item)->depended_from)
     {
-      Item_field *field= (Item_field*) tmp_item;
-      Field *new_field= create_tmp_field_from_field(thd, 
-                               (*from_field= field->field),
-                               item->name, table,
-                               NULL,
-                               convert_blob_length);
-      if (modify_item)
-        item->set_result_field(new_field);
-      return new_field;
+      Item_field *field= (Item_field*) item;
+      if (table_cant_handle_bit_fields && 
+          field->field->type() == FIELD_TYPE_BIT)
+        return create_tmp_field_from_item(thd, item, table, copy_func,
+                                          modify_item, convert_blob_length);
+      return create_tmp_field_from_field(thd, (*from_field= field->field),
+                                         item->name, table,
+                                         modify_item ? (Item_field*) item :
+                                                       NULL,
+                                         convert_blob_length);
     }
+    else
+      item= org_item;
   }
   case Item::FUNC_ITEM:
   case Item::COND_ITEM:
@@ -8074,6 +8072,7 @@
   case Item::REAL_ITEM:
   case Item::DECIMAL_ITEM:
   case Item::STRING_ITEM:
+  case Item::REF_ITEM:
   case Item::NULL_ITEM:
   case Item::VARBIN_ITEM:
     return create_tmp_field_from_item(thd, item, table, copy_func, modify_item,
@@ -10904,12 +10903,12 @@
   usable_keys.set_all();
   for (ORDER *tmp_order=order; tmp_order ; tmp_order=tmp_order->next)
   {
-    if ((*tmp_order->item)->type() != Item::FIELD_ITEM)
+    if ((*tmp_order->item)->real_item()->type() != Item::FIELD_ITEM)
     {
       usable_keys.clear_all();
       DBUG_RETURN(0);
     }
-    usable_keys.intersect(((Item_field*) (*tmp_order->item))->
+    usable_keys.intersect(((Item_field*) (*tmp_order->item)->real_item())->
 			  field->part_of_sortkey);
     if (usable_keys.is_clear_all())
       DBUG_RETURN(0);					// No usable keys

--- 1.95/mysql-test/r/view.result	Tue Jul 19 19:59:29 2005
+++ 1.96/mysql-test/r/view.result	Mon Jul 25 09:06:53 2005
@@ -2024,3 +2024,26 @@
 2005-01-01 12:00:00	2005-01-01 10:58:59
 drop view v1;
 drop table t1;
+CREATE TABLE t1 (
+aid int PRIMARY KEY,
+fn varchar(20) NOT NULL,
+ln varchar(20) NOT NULL
+);
+CREATE TABLE t2 (
+aid int NOT NULL,
+pid int NOT NULL
+);
+INSERT INTO t1 VALUES(1,'a','b'), (2,'c','d');
+INSERT INTO t2 values (1,1), (2,1), (2,2);
+CREATE VIEW v1 AS SELECT t1.*,t2.pid FROM t1,t2 WHERE t1.aid = t2.aid;
+SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM t1,t2 
+WHERE t1.aid = t2.aid GROUP BY pid;
+pid	GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1)
+1	a b,c d
+2	c d
+SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM v1 GROUP BY pid;
+pid	GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1)
+1	a b,c d
+2	c d
+DROP VIEW v1;
+DROP TABLE t1,t2;

--- 1.89/mysql-test/t/view.test	Tue Jul 19 19:59:29 2005
+++ 1.90/mysql-test/t/view.test	Mon Jul 25 09:07:39 2005
@@ -1862,4 +1862,28 @@
 create view v1 as select f1, subtime(f1, '1:1:1') as sb from t1;
 select * from v1;
 drop view v1;
-drop table t1; 
+drop table t1;
+
+#
+# Test for bug #11412: query over a multitable view with GROUP_CONCAT
+#
+CREATE TABLE t1 (
+  aid int PRIMARY KEY,
+  fn varchar(20) NOT NULL,
+  ln varchar(20) NOT NULL
+);
+CREATE TABLE t2 (
+  aid int NOT NULL,
+  pid int NOT NULL
+);
+INSERT INTO t1 VALUES(1,'a','b'), (2,'c','d');
+INSERT INTO t2 values (1,1), (2,1), (2,2);
+
+CREATE VIEW v1 AS SELECT t1.*,t2.pid FROM t1,t2 WHERE t1.aid = t2.aid;
+
+SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM t1,t2 
+  WHERE t1.aid = t2.aid GROUP BY pid;
+SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM v1 GROUP BY pid;
+
+DROP VIEW v1;
+DROP TABLE t1,t2;
Thread
bk commit into 5.0 tree (igor:1.1895) BUG#11412igor25 Jul