MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:Sergey Petrunia Date:September 7 2005 7:50am
Subject:bk commit into 5.0 tree (sergefp:1.1959) BUG#12941
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of psergey. When psergey 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.1959 05/09/07 11:50:41 sergefp@stripped +3 -0
  Fix for BUG#12941: in create_tmp_field(), if the passed item is an Item_ref, put newly
  created item into item->result_field, not *(item->ref)->result_field.

  sql/sql_select.cc
    1.366 05/09/07 11:50:36 sergefp@stripped +20 -10
    Fix for BUG#12941: in create_tmp_field(), if the passed item is an Item_ref, put newly
    created item into item->result_field, not *(item->ref)->result_field.

  mysql-test/t/view.test
    1.103 05/09/07 11:50:36 sergefp@stripped +33 -0
    Tescase for BUG#12941

  mysql-test/r/view.result
    1.108 05/09/07 11:50:36 sergefp@stripped +26 -0
    Tescase for BUG#12941

# 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:	sergefp
# Host:	newbox.mylan
# Root:	/home/psergey/mysql-5.0-bug12941

--- 1.365/sql/sql_select.cc	2005-09-02 17:21:08 +04:00
+++ 1.366/sql/sql_select.cc	2005-09-07 11:50:36 +04:00
@@ -8054,12 +8054,17 @@
                         bool table_cant_handle_bit_fields,
                         uint convert_blob_length)
 {
+  Item::Type orig_type;
+  Item *orig_item;
+
   if (type != Item::FIELD_ITEM &&
       item->real_item()->type() == Item::FIELD_ITEM &&
       (item->type() != Item::REF_ITEM ||
        !((Item_ref *) item)->depended_from))
   {
+    orig_item= item;
     item= item->real_item();
+    orig_type= type;
     type= Item::FIELD_ITEM;
   }
   switch (type) {
@@ -8075,29 +8080,34 @@
   case Item::DEFAULT_VALUE_ITEM:
   {
     Item_field *field= (Item_field*) item;
+    bool orig_modify= modify_item;
+    Field *result;
+    if (orig_type == Item::REF_ITEM)
+      modify_item= 0;
     /*
       If item have to be able to store NULLs but underlaid field can't do it,
       create_tmp_field_from_field() can't be used for tmp field creation.
     */
     if (field->maybe_null && !field->field->maybe_null())
     {
-      Field *res= create_tmp_field_from_item(thd, item, table, NULL,
+      result= create_tmp_field_from_item(thd, item, table, NULL,
                                        modify_item, convert_blob_length);
       *from_field= field->field;
-      if (res && modify_item)
-        ((Item_field*)item)->result_field= res;
-      return res;
-    }
-
-    if (table_cant_handle_bit_fields && 
-        field->field->type() == FIELD_TYPE_BIT)
-      return create_tmp_field_from_item(thd, item, table, copy_func,
+      if (result && modify_item)
+        ((Item_field*)item)->result_field= result;
+    } 
+    else if (table_cant_handle_bit_fields && field->field->type() == FIELD_TYPE_BIT)
+      result= 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),
+    else
+      result= create_tmp_field_from_field(thd, (*from_field= field->field),
                                        item->name, table,
                                        modify_item ? (Item_field*) item :
                                        NULL,
                                        convert_blob_length);
+    if (orig_type == Item::REF_ITEM && orig_modify)
+      ((Item_ref*)orig_item)->set_result_field(result);
+    return result;
   }
   /* Fall through */
   case Item::FUNC_ITEM:

--- 1.107/mysql-test/r/view.result	2005-09-01 23:42:19 +04:00
+++ 1.108/mysql-test/r/view.result	2005-09-07 11:50:36 +04:00
@@ -2151,3 +2151,29 @@
 strcmp(f1,'a')
 drop view v1;
 drop table t1;
+create table t1 (
+r_object_id char(16) NOT NULL,
+group_name varchar(32) NOT NULL
+) engine = InnoDB;
+create table t2 (
+r_object_id char(16) NOT NULL,
+i_position int(11) NOT NULL, 
+users_names varchar(32) default NULL
+) Engine = InnoDB;
+create view v1 as select r_object_id, group_name from t1;
+create view v2 as select r_object_id, i_position, users_names from t2;
+create unique index r_object_id on t1(r_object_id);
+create index group_name on t1(group_name);
+create unique index r_object_id_i_position on t2(r_object_id,i_position);
+create index users_names on t2(users_names);
+insert into t1 values('120001a080000542','tstgroup1');
+insert into t2 values('120001a080000542',-1, 'guser01');
+insert into t2 values('120001a080000542',-2, 'guser02');
+select v1.r_object_id, v2.users_names from v1, v2
+where (v1.group_name='tstgroup1') and v2.r_object_id=v1.r_object_id 
+order by users_names;
+r_object_id	users_names
+120001a080000542	guser01
+120001a080000542	guser02
+drop view v1, v2;
+drop table t1, t2;

--- 1.102/mysql-test/t/view.test	2005-09-02 10:50:09 +04:00
+++ 1.103/mysql-test/t/view.test	2005-09-07 11:50:36 +04:00
@@ -2018,3 +2018,36 @@
 select * from v1;
 drop view v1;
 drop table t1;
+
+#
+# BUG#12941
+#
+create table t1 (
+  r_object_id char(16) NOT NULL,
+  group_name varchar(32) NOT NULL
+) engine = InnoDB;
+
+create table t2 (
+  r_object_id char(16) NOT NULL,
+  i_position int(11) NOT NULL, 
+  users_names varchar(32) default NULL
+) Engine = InnoDB;
+
+create view v1 as select r_object_id, group_name from t1;
+create view v2 as select r_object_id, i_position, users_names from t2;
+
+create unique index r_object_id on t1(r_object_id);
+create index group_name on t1(group_name);
+create unique index r_object_id_i_position on t2(r_object_id,i_position);
+create index users_names on t2(users_names);
+
+insert into t1 values('120001a080000542','tstgroup1');
+insert into t2 values('120001a080000542',-1, 'guser01');
+insert into t2 values('120001a080000542',-2, 'guser02');
+
+select v1.r_object_id, v2.users_names from v1, v2
+where (v1.group_name='tstgroup1') and v2.r_object_id=v1.r_object_id 
+order by users_names;
+
+drop view v1, v2;
+drop table t1, t2;
Thread
bk commit into 5.0 tree (sergefp:1.1959) BUG#12941Sergey Petrunia7 Sep