[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql-internals
Subject:    bk commit into 5.0 tree (ramil:1.1993) BUG#11572
From:       ramil () mysql ! com
Date:       2005-06-30 8:38:36
Message-ID: 200506300838.j5U8cajw099775 () gw ! mysql ! r18 ! ru
[Download RAW message or body]

Below is the list of changes that have just been committed into a local
5.0 repository of ram. When ram 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.1993 05/06/30 13:38:29 ramil@mysql.com +7 -0
  a fix.
  bug #10617: Insert from same table to same table give incorrect result for bit(4) column.
  bug #11091: union involving BIT: assertion failure in Item::tmp_table_field_from_field_type
  bug #11572: MYSQL_TYPE_BIT not taken care of in temp. table creation for VIEWs 

  sql/sql_table.cc
    1.255 05/06/30 13:38:22 ramil@mysql.com +1 -1
    a fix.
    bug #10617: Insert from same table to same table give incorrect result for bit(4) column.
    bug #11091: union involving BIT: assertion failure in Item::tmp_table_field_from_field_type
    bug #11572: MYSQL_TYPE_BIT not taken care of in temp. table creation for VIEWs
    
    - changed the create_tmp_field() call

  sql/sql_select.cc
    1.354 05/06/30 13:38:22 ramil@mysql.com +15 -2
    a fix.
    bug #10617: Insert from same table to same table give incorrect result for bit(4) column.
    bug #11091: union involving BIT: assertion failure in Item::tmp_table_field_from_field_type
    bug #11572: MYSQL_TYPE_BIT not taken care of in temp. table creation for VIEWs
    
    - create_tmp_field() changes to return create_tmp_field_from_item() result 
      (actually, Field_bit_as_char) if table_cant_handle_bit_fields=1 for bit fields.
    - create_tmp_field() calls accordingly changed 
    - call set_bit_ptr() for bit fields after the move_field() call during 
      temporary table creation.

  sql/mysql_priv.h
    1.319 05/06/30 13:38:21 ramil@mysql.com +1 -0
    a fix.
    bug #10617: Insert from same table to same table give incorrect result for bit(4) column.
    bug #11091: union involving BIT: assertion failure in Item::tmp_table_field_from_field_type
    bug #11572: MYSQL_TYPE_BIT not taken care of in temp. table creation for VIEWs 
    
    - table_cant_handle_bit_fields parameter added to the create_tmp_field()

  sql/item.cc
    1.143 05/06/30 13:38:21 ramil@mysql.com +3 -0
    a fix.
    bug #10617: Insert from same table to same table give incorrect result for bit(4) column.
    bug #11091: union involving BIT: assertion failure in Item::tmp_table_field_from_field_type
    bug #11572: MYSQL_TYPE_BIT not taken care of in temp. table creation for VIEWs
    
    - create Field_bit_as_char in case of MYSQL_TYPE_BIT in the Item::tmp_table_field_from_field_type()
      (we cannot create Field_bit here because of lack of information: bit_ptr, bit_ofs)

  sql/field.h
    1.163 05/06/30 13:38:21 ramil@mysql.com +7 -1
    a fix.
    bug #10617: Insert from same table to same table give incorrect result for bit(4) column.
    bug #11091: union involving BIT: assertion failure in Item::tmp_table_field_from_field_type
    bug #11572: MYSQL_TYPE_BIT not taken care of in temp. table creation for VIEWs 
    
    - max_length() returns length in bits.
    - introduced set_bit_ptr() function, which sets bit_ptr and bit_ofs.

  mysql-test/t/type_bit.test
    1.10 05/06/30 13:38:21 ramil@mysql.com +53 -0
    test case.
    bug #10617: Insert from same table to same table give incorrect result for bit(4) column.
    bug #11091: union involving BIT: assertion failure in Item::tmp_table_field_from_field_type
    bug #11572: MYSQL_TYPE_BIT not taken care of in temp. table creation for VIEWs 

  mysql-test/r/type_bit.result
    1.11 05/06/30 13:38:21 ramil@mysql.com +87 -0
    test case.
    bug #10617: Insert from same table to same table give incorrect result for bit(4) column.
    bug #11091: union involving BIT: assertion failure in Item::tmp_table_field_from_field_type
    bug #11572: MYSQL_TYPE_BIT not taken care of in temp. table creation for VIEWs 

# 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:	ramil
# Host:	gw.mysql.r18.ru
# Root:	/usr/home/ram/work/5.0.b11091

--- 1.162/sql/field.h	2005-06-21 01:28:17 +05:00
+++ 1.163/sql/field.h	2005-06-30 13:38:21 +05:00
@@ -1288,7 +1288,7 @@
   enum_field_types type() const { return FIELD_TYPE_BIT; }
   enum ha_base_keytype key_type() const { return HA_KEYTYPE_BIT; }
   uint32 key_length() const { return (uint32) field_length + (bit_len > 0); }
-  uint32 max_length() { return (uint32) field_length + (bit_len > 0); }
+  uint32 max_length() { return (uint32) field_length * 8 + bit_len; }
   uint size_of() const { return sizeof(*this); }
   Item_result result_type () const { return INT_RESULT; }
   void reset(void) { bzero(ptr, field_length); }
@@ -1320,6 +1320,11 @@
   Field *new_key_field(MEM_ROOT *root, struct st_table *new_table,
                        char *new_ptr, uchar *new_null_ptr,
                        uint new_null_bit);
+  void set_bit_ptr(uchar *bit_ptr_arg, uchar bit_ofs_arg)
+  {
+    bit_ptr= bit_ptr_arg;
+    bit_ofs= bit_ofs_arg;
+  }
 };
 
   
@@ -1331,6 +1336,7 @@
                     enum utype unireg_check_arg, const char *field_name_arg,
                     struct st_table *table_arg);
   enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
+  uint32 max_length() { return (uint32) create_length; }
   uint size_of() const { return sizeof(*this); }
   int store(const char *to, uint length, CHARSET_INFO *charset);
   int store(double nr) { return Field_bit::store(nr); }

--- 1.142/sql/item.cc	2005-06-29 12:03:32 +05:00
+++ 1.143/sql/item.cc	2005-06-30 13:38:21 +05:00
@@ -3347,6 +3347,9 @@
   case MYSQL_TYPE_YEAR:
     return new Field_year((char*) 0, max_length, null_ptr, 0, Field::NONE,
 			  name, table);
+  case MYSQL_TYPE_BIT:
+    return new Field_bit_as_char(NULL, max_length, null_ptr, 0, NULL, 0,
+                                 Field::NONE, name, table);
   default:
     /* This case should never be chosen */
     DBUG_ASSERT(0);

--- 1.318/sql/mysql_priv.h	2005-06-21 19:18:22 +05:00
+++ 1.319/sql/mysql_priv.h	2005-06-30 13:38:21 +05:00
@@ -667,6 +667,7 @@
 Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
 			Item ***copy_func, Field **from_field,
 			bool group, bool modify_item,
+			bool table_cant_handle_bit_fields,
                         uint convert_blob_length);
 void sp_prepare_create_field(THD *thd, create_field *sql_field);
 int prepare_create_field(create_field *sql_field, 

--- 1.353/sql/sql_select.cc	2005-06-27 15:10:45 +05:00
+++ 1.354/sql/sql_select.cc	2005-06-30 13:38:22 +05:00
@@ -7957,7 +7957,9 @@
 
 Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
                         Item ***copy_func, Field **from_field,
-                        bool group, bool modify_item, uint convert_blob_length)
+                        bool group, bool modify_item,
+                        bool table_cant_handle_bit_fields,
+                        uint convert_blob_length)
 {
   switch (type) {
   case Item::SUM_FUNC_ITEM:
@@ -7972,6 +7974,9 @@
   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,
@@ -8192,6 +8197,7 @@
 	  Field *new_field=
             create_tmp_field(thd, table, arg, arg->type(), &copy_func,
                              tmp_from_field, group != 0,not_all_columns,
+                             group || distinct,
                              param->convert_blob_length);
 	  if (!new_field)
 	    goto err;					// Should be OOM
@@ -8239,7 +8245,7 @@
         create_tmp_field_for_schema(thd, item, table) :
         create_tmp_field(thd, table, item, type, &copy_func,
                          tmp_from_field, group != 0,
-                         not_all_columns || group !=0,
+                         not_all_columns || group != 0, 0,
                          param->convert_blob_length);
 
       if (!new_field)
@@ -8377,6 +8383,13 @@
     }
     else
       field->move_field((char*) pos,(uchar*) 0,0);
+    if (field->type() == FIELD_TYPE_BIT)
+    {
+      /* We have to reserve place for extra bits among null bits */
+      ((Field_bit*) field)->set_bit_ptr(null_flags + null_count / 8,
+                                        null_count & 7);
+      null_count+= (field->field_length & 7);
+    }
     field->reset();
     if (from_field[i])
     {						/* Not a table Item */

--- 1.254/sql/sql_table.cc	2005-06-22 17:09:59 +05:00
+++ 1.255/sql/sql_table.cc	2005-06-30 13:38:22 +05:00
@@ -1734,7 +1734,7 @@
       field=item->tmp_table_field(&tmp_table);
     else
       field=create_tmp_field(thd, &tmp_table, item, item->type(),
-                             (Item ***) 0, &tmp_field,0,0,0);
+                             (Item ***) 0, &tmp_field, 0, 0, 0, 0);
     if (!field ||
 	!(cr_field=new create_field(field,(item->type() == Item::FIELD_ITEM ?
 					   ((Item_field *)item)->field :

--- 1.10/mysql-test/r/type_bit.result	2005-05-18 17:30:05 +05:00
+++ 1.11/mysql-test/r/type_bit.result	2005-06-30 13:38:21 +05:00
@@ -466,3 +466,90 @@
 a+0
 255
 drop table t1;
+create table t1 (a bit(7));
+insert into t1 values (120), (0), (111);
+select a+0 from t1 union select a+0 from t1;
+a+0
+120
+0
+111
+select a+0 from t1 union select NULL;
+a+0
+120
+0
+111
+NULL
+select NULL union select a+0 from t1;
+NULL
+NULL
+120
+0
+111
+create table t2 select a from t1 union select a from t1;
+select a+0 from t2;
+a+0
+120
+0
+111
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `a` bit(7) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1, t2;
+create table t1 (id1 int(11), b1 bit(1));
+create table t2 (id2 int(11), b2 bit(1));
+insert into t1 values (1, 1), (2, 0), (3, 1);
+insert into t2 values (2, 1), (3, 0), (4, 0);
+create algorithm=undefined view v1 as 
+select b1+0, b2+0 from t1, t2 where id1 = id2 and b1 = 0
+union
+select b1+0, b2+0 from t1, t2 where id1 = id2 and b2 = 1;
+select * from v1;
+b1+0	b2+0
+0	1
+drop table t1, t2;
+drop view v1;
+create table t1(a bit(4));
+insert into t1(a) values (1), (2), (5), (4), (3);
+insert into t1 select * from t1;
+select a+0 from t1;
+a+0
+1
+2
+5
+4
+3
+1
+2
+5
+4
+3
+drop table t1;
+create table t1 (a1 int(11), b1 bit(2));
+create table t2 (a2 int(11), b2 bit(2));
+insert into t1 values (1, 1), (2, 0), (3, 1), (4, 2);
+insert into t2 values (2, 1), (3, 0), (4, 1), (5, 2);
+select a1, a2, b1+0, b2+0 from t1 join t2 on a1 = a2;
+a1	a2	b1+0	b2+0
+2	2	0	1
+3	3	1	0
+4	4	2	1
+select a1, a2, b1+0, b2+0 from t1 join t2 on a1 = a2 order by a1;
+a1	a2	b1+0	b2+0
+2	2	0	1
+3	3	1	0
+4	4	2	1
+select a1, a2, b1+0, b2+0 from t1 join t2 on b1 = b2;
+a1	a2	b1+0	b2+0
+1	2	1	1
+3	2	1	1
+2	3	0	0
+1	4	1	1
+3	4	1	1
+4	5	2	2
+select sum(a1), b1+0, b2+0 from t1 join t2 on b1 = b2 group by b1 order by 1;
+sum(a1)	b1+0	b2+0
+2	0	0
+4	2	2
+8	1	1

--- 1.9/mysql-test/t/type_bit.test	2005-05-18 17:30:05 +05:00
+++ 1.10/mysql-test/t/type_bit.test	2005-06-30 13:38:21 +05:00
@@ -171,3 +171,56 @@
 insert into t1 values ('1111100000');
 select a+0 from t1;
 drop table t1;
+
+#
+# Bug #11091: union
+#
+
+create table t1 (a bit(7));
+insert into t1 values (120), (0), (111);
+select a+0 from t1 union select a+0 from t1;
+select a+0 from t1 union select NULL;
+select NULL union select a+0 from t1;
+create table t2 select a from t1 union select a from t1;
+select a+0 from t2;
+show create table t2;
+drop table t1, t2;
+
+#
+# Bug #11572: view
+#
+
+create table t1 (id1 int(11), b1 bit(1));
+create table t2 (id2 int(11), b2 bit(1));
+insert into t1 values (1, 1), (2, 0), (3, 1);
+insert into t2 values (2, 1), (3, 0), (4, 0);
+create algorithm=undefined view v1 as 
+  select b1+0, b2+0 from t1, t2 where id1 = id2 and b1 = 0
+  union
+  select b1+0, b2+0 from t1, t2 where id1 = id2 and b2 = 1;
+select * from v1;
+drop table t1, t2;
+drop view v1;
+
+#
+# Bug #10617: bulk-insert
+#
+
+create table t1(a bit(4));
+insert into t1(a) values (1), (2), (5), (4), (3);
+insert into t1 select * from t1;
+select a+0 from t1;
+drop table t1;
+
+#
+# join
+#
+
+create table t1 (a1 int(11), b1 bit(2));
+create table t2 (a2 int(11), b2 bit(2));
+insert into t1 values (1, 1), (2, 0), (3, 1), (4, 2);
+insert into t2 values (2, 1), (3, 0), (4, 1), (5, 2);
+select a1, a2, b1+0, b2+0 from t1 join t2 on a1 = a2;
+select a1, a2, b1+0, b2+0 from t1 join t2 on a1 = a2 order by a1;
+select a1, a2, b1+0, b2+0 from t1 join t2 on b1 = b2;
+select sum(a1), b1+0, b2+0 from t1 join t2 on b1 = b2 group by b1 order by 1;

-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/internals?unsub=mysql-internals@progressive-comp.com

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic