List:Commits« Previous MessageNext Message »
From:Mats Kindahl Date:December 1 2006 5:32am
Subject:bk commit into 5.1 tree (mats:1.2374) BUG#24490
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of mats. When mats 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@stripped, 2006-12-01 06:32:42+01:00, mats@stripped +5 -0
  BUG#24490 (segfault inside unpack_row at Field_bit_as_char::set_default()):
  Field_bit_as_char::set_default() was not defined, so Field_bit::set_default()
  was used instead, causing a crash.

  mysql-test/extra/rpl_tests/rpl_row_tabledefs.test@stripped, 2006-12-01 06:32:37+01:00, mats@stripped +20 -20
    Doing select using ORDER BY to prevent table-internal order from
    affecting the result.

  mysql-test/r/rpl_row_tabledefs_2myisam.result@stripped, 2006-12-01 06:32:37+01:00, mats@stripped +26 -26
    Result change

  mysql-test/r/rpl_row_tabledefs_3innodb.result@stripped, 2006-12-01 06:32:37+01:00, mats@stripped +26 -26
    Result change

  sql/field.h@stripped, 2006-12-01 06:32:37+01:00, mats@stripped +8 -0
    Adding Field_bit_as_char::set_default() since it is not possible
    to use Field_bit::set_default() as a replacement for that.
    Field_bit::set_default() uses the bit_ptr, but it is undefined,
    hence causing a crash.  In reality, the hierarchy order is not correct
    so added a TODO comment about refactoring.

  sql/log_event.cc@stripped, 2006-12-01 06:32:38+01:00, mats@stripped +8 -5
    Code was manipulating bits for a FIELD_TYPE_BIT field without checking
    if the bit_len was > 0, hence using an undefined bit_ptr when the
    class was actually a Field_bit_as_char.

# 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:	mats
# Host:	kindahl-laptop.dnsalias.net
# Root:	/home/bk/b24490-mysql-5.1-new-rpl

--- 1.191/sql/field.h	2006-12-01 06:32:51 +01:00
+++ 1.192/sql/field.h	2006-12-01 06:32:51 +01:00
@@ -1488,6 +1488,13 @@
 };
 
 
+/**
+  BIT field represented as chars for non-MyISAM tables.
+
+  @todo The inheritance relationship is backwards since Field_bit is
+  an extended version of Field_bit_as_char and not the other way
+  around. Hence, we should refactor it to fix the hierarchy order.
+ */
 class Field_bit_as_char: public Field_bit {
 public:
   Field_bit_as_char(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
@@ -1499,6 +1506,7 @@
   int store(double nr) { return Field_bit::store(nr); }
   int store(longlong nr, bool unsigned_val)
   { return Field_bit::store(nr, unsigned_val); }
+  virtual void set_default() { Field::set_default(); }
   void sql_type(String &str) const;
 };
 

--- 1.254/sql/log_event.cc	2006-12-01 06:32:51 +01:00
+++ 1.255/sql/log_event.cc	2006-12-01 06:32:51 +01:00
@@ -6578,10 +6578,13 @@
 
       case FIELD_TYPE_BIT:
         Field_bit *f= static_cast<Field_bit*>(*field_ptr);
-        my_ptrdiff_t const offset= table->record[1] - table->record[0];
-        uchar const bits=
-          get_rec_bits(f->bit_ptr + offset, f->bit_ofs, f->bit_len);
-        set_rec_bits(bits, f->bit_ptr, f->bit_ofs, f->bit_len);
+        if (f->bit_len > 0)
+        {
+          my_ptrdiff_t const offset= table->record[1] - table->record[0];
+          uchar const bits=
+            get_rec_bits(f->bit_ptr + offset, f->bit_ofs, f->bit_len);
+          set_rec_bits(bits, f->bit_ptr, f->bit_ofs, f->bit_len);
+        }
         break;
       }
     }
@@ -6682,7 +6685,7 @@
        present on the master from table->record[1], if there are any.
     */
     copy_extra_record_fields(table, master_reclength, master_fields);
-    
+
     /*
        REPLACE is defined as either INSERT or DELETE + INSERT.  If
        possible, we can replace it with an UPDATE, but that will not

--- 1.5/mysql-test/extra/rpl_tests/rpl_row_tabledefs.test	2006-12-01 06:32:51 +01:00
+++ 1.6/mysql-test/extra/rpl_tests/rpl_row_tabledefs.test	2006-12-01 06:32:51 +01:00
@@ -80,28 +80,28 @@
 INSERT INTO t1_bit VALUES (2,5);
 INSERT INTO t1_char VALUES (1,2);
 INSERT INTO t1_char VALUES (2,5);
-SELECT * FROM t1_int;
-SELECT * FROM t1_bit;
-SELECT * FROM t1_char;
+SELECT * FROM t1_int ORDER BY a;
+SELECT * FROM t1_bit ORDER BY a;
+SELECT * FROM t1_char ORDER BY a;
 --echo **** On Slave ****
 sync_slave_with_master;
-SELECT a,b,x FROM t1_int;
-SELECT a,b,HEX(x),HEX(y),HEX(z) FROM t1_bit;
-SELECT a,b,x FROM t1_char;
+SELECT a,b,x FROM t1_int ORDER BY a;
+SELECT a,b,HEX(x),HEX(y),HEX(z) FROM t1_bit ORDER BY a;
+SELECT a,b,x FROM t1_char ORDER BY a;
 
 --echo **** On Master ****
 connection master;
 UPDATE t1_int  SET b=2*b WHERE a=2;
 UPDATE t1_char SET b=2*b WHERE a=2;
 UPDATE t1_bit  SET b=2*b WHERE a=2;
-SELECT * FROM t1_int;
-SELECT * FROM t1_bit;
-SELECT * FROM t1_char;
+SELECT * FROM t1_int ORDER BY a;
+SELECT * FROM t1_bit ORDER BY a;
+SELECT * FROM t1_char ORDER BY a;
 --echo **** On Slave ****
 sync_slave_with_master;
-SELECT a,b,x FROM t1_int;
-SELECT a,b,HEX(x),HEX(y),HEX(z) FROM t1_bit;
-SELECT a,b,x FROM t1_char;
+SELECT a,b,x FROM t1_int ORDER BY a;
+SELECT a,b,HEX(x),HEX(y),HEX(z) FROM t1_bit ORDER BY a;
+SELECT a,b,x FROM t1_char ORDER BY a;
 
 # Each of these inserts should generate an error and stop the slave
 
@@ -188,11 +188,11 @@
 connection master;
 INSERT INTO t7 VALUES (1),(2),(3);
 INSERT INTO t8 VALUES (1),(2),(3);
-SELECT * FROM t7;
-SELECT * FROM t8;
+SELECT * FROM t7 ORDER BY a;
+SELECT * FROM t8 ORDER BY a;
 sync_slave_with_master;
-SELECT * FROM t7;
-SELECT * FROM t8;
+SELECT * FROM t7 ORDER BY a;
+SELECT * FROM t8 ORDER BY a;
 
 # We will now try to update and then delete a row on the master where
 # the extra field on the slave does not have a default value. This
@@ -216,20 +216,20 @@
 --echo **** On Master ****
 connection master;
 UPDATE t1_nodef SET b=2*b WHERE a=1;
-SELECT * FROM t1_nodef;
+SELECT * FROM t1_nodef ORDER BY a;
 
 --echo **** On Slave ****
 sync_slave_with_master;
-SELECT * FROM t1_nodef;
+SELECT * FROM t1_nodef ORDER BY a;
 
 --echo **** On Master ****
 connection master;
 DELETE FROM t1_nodef WHERE a=2;
-SELECT * FROM t1_nodef;
+SELECT * FROM t1_nodef ORDER BY a;
 
 --echo **** On Slave ****
 sync_slave_with_master;
-SELECT * FROM t1_nodef;
+SELECT * FROM t1_nodef ORDER BY a;
 
 --echo **** Cleanup ****
 connection master;

--- 1.6/mysql-test/r/rpl_row_tabledefs_2myisam.result	2006-12-01 06:32:51 +01:00
+++ 1.7/mysql-test/r/rpl_row_tabledefs_2myisam.result	2006-12-01 06:32:51 +01:00
@@ -46,60 +46,60 @@
 INSERT INTO t1_bit VALUES (2,5);
 INSERT INTO t1_char VALUES (1,2);
 INSERT INTO t1_char VALUES (2,5);
-SELECT * FROM t1_int;
+SELECT * FROM t1_int ORDER BY a;
 a	b
 1	2
 2	5
-SELECT * FROM t1_bit;
+SELECT * FROM t1_bit ORDER BY a;
 a	b
 1	2
 2	5
-SELECT * FROM t1_char;
+SELECT * FROM t1_char ORDER BY a;
 a	b
 1	2
 2	5
 **** On Slave ****
-SELECT a,b,x FROM t1_int;
+SELECT a,b,x FROM t1_int ORDER BY a;
 a	b	x
-2	5	4711
 1	2	42
-SELECT a,b,HEX(x),HEX(y),HEX(z) FROM t1_bit;
+2	5	4711
+SELECT a,b,HEX(x),HEX(y),HEX(z) FROM t1_bit ORDER BY a;
 a	b	HEX(x)	HEX(y)	HEX(z)
-2	5	5	1C	1
 1	2	3	15	2
-SELECT a,b,x FROM t1_char;
+2	5	5	1C	1
+SELECT a,b,x FROM t1_char ORDER BY a;
 a	b	x
-2	5	Foo is a bar
 1	2	Just a test
+2	5	Foo is a bar
 **** On Master ****
 UPDATE t1_int  SET b=2*b WHERE a=2;
 UPDATE t1_char SET b=2*b WHERE a=2;
 UPDATE t1_bit  SET b=2*b WHERE a=2;
-SELECT * FROM t1_int;
+SELECT * FROM t1_int ORDER BY a;
 a	b
 1	2
 2	10
-SELECT * FROM t1_bit;
+SELECT * FROM t1_bit ORDER BY a;
 a	b
 1	2
 2	10
-SELECT * FROM t1_char;
+SELECT * FROM t1_char ORDER BY a;
 a	b
 1	2
 2	10
 **** On Slave ****
-SELECT a,b,x FROM t1_int;
+SELECT a,b,x FROM t1_int ORDER BY a;
 a	b	x
-2	10	4711
 1	2	42
-SELECT a,b,HEX(x),HEX(y),HEX(z) FROM t1_bit;
+2	10	4711
+SELECT a,b,HEX(x),HEX(y),HEX(z) FROM t1_bit ORDER BY a;
 a	b	HEX(x)	HEX(y)	HEX(z)
-2	10	5	1C	1
 1	2	3	15	2
-SELECT a,b,x FROM t1_char;
+2	10	5	1C	1
+SELECT a,b,x FROM t1_char ORDER BY a;
 a	b	x
-2	10	Foo is a bar
 1	2	Just a test
+2	10	Foo is a bar
 INSERT INTO t9 VALUES (2);
 INSERT INTO t1_nodef VALUES (1,2);
 SHOW SLAVE STATUS;
@@ -327,22 +327,22 @@
 Seconds_Behind_Master	#
 INSERT INTO t7 VALUES (1),(2),(3);
 INSERT INTO t8 VALUES (1),(2),(3);
-SELECT * FROM t7;
+SELECT * FROM t7 ORDER BY a;
 a
 1
 2
 3
-SELECT * FROM t8;
+SELECT * FROM t8 ORDER BY a;
 a
 1
 2
 3
-SELECT * FROM t7;
+SELECT * FROM t7 ORDER BY a;
 a	e1	e2	e3	e4	e5	e6	e7	e8
 1	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 2	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 3	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
-SELECT * FROM t8;
+SELECT * FROM t8 ORDER BY a;
 a	e1	e2	e3	e4	e5	e6	e7	e8
 1	0	0	0	0	0	0	0	0
 2	0	0	0	0	0	0	0	0
@@ -358,22 +358,22 @@
 INSERT INTO t1_nodef VALUES (2,4,6);
 **** On Master ****
 UPDATE t1_nodef SET b=2*b WHERE a=1;
-SELECT * FROM t1_nodef;
+SELECT * FROM t1_nodef ORDER BY a;
 a	b
 1	4
 2	4
 **** On Slave ****
-SELECT * FROM t1_nodef;
+SELECT * FROM t1_nodef ORDER BY a;
 a	b	x
 1	4	3
 2	4	6
 **** On Master ****
 DELETE FROM t1_nodef WHERE a=2;
-SELECT * FROM t1_nodef;
+SELECT * FROM t1_nodef ORDER BY a;
 a	b
 1	4
 **** On Slave ****
-SELECT * FROM t1_nodef;
+SELECT * FROM t1_nodef ORDER BY a;
 a	b	x
 1	4	3
 **** Cleanup ****

--- 1.3/mysql-test/r/rpl_row_tabledefs_3innodb.result	2006-12-01 06:32:51 +01:00
+++ 1.4/mysql-test/r/rpl_row_tabledefs_3innodb.result	2006-12-01 06:32:51 +01:00
@@ -46,60 +46,60 @@
 INSERT INTO t1_bit VALUES (2,5);
 INSERT INTO t1_char VALUES (1,2);
 INSERT INTO t1_char VALUES (2,5);
-SELECT * FROM t1_int;
+SELECT * FROM t1_int ORDER BY a;
 a	b
 1	2
 2	5
-SELECT * FROM t1_bit;
+SELECT * FROM t1_bit ORDER BY a;
 a	b
 1	2
 2	5
-SELECT * FROM t1_char;
+SELECT * FROM t1_char ORDER BY a;
 a	b
 1	2
 2	5
 **** On Slave ****
-SELECT a,b,x FROM t1_int;
+SELECT a,b,x FROM t1_int ORDER BY a;
 a	b	x
-2	5	4711
 1	2	42
-SELECT a,b,HEX(x),HEX(y),HEX(z) FROM t1_bit;
+2	5	4711
+SELECT a,b,HEX(x),HEX(y),HEX(z) FROM t1_bit ORDER BY a;
 a	b	HEX(x)	HEX(y)	HEX(z)
-2	5	5	1C	1
 1	2	3	15	2
-SELECT a,b,x FROM t1_char;
+2	5	5	1C	1
+SELECT a,b,x FROM t1_char ORDER BY a;
 a	b	x
-2	5	Foo is a bar
 1	2	Just a test
+2	5	Foo is a bar
 **** On Master ****
 UPDATE t1_int  SET b=2*b WHERE a=2;
 UPDATE t1_char SET b=2*b WHERE a=2;
 UPDATE t1_bit  SET b=2*b WHERE a=2;
-SELECT * FROM t1_int;
+SELECT * FROM t1_int ORDER BY a;
 a	b
 1	2
 2	10
-SELECT * FROM t1_bit;
+SELECT * FROM t1_bit ORDER BY a;
 a	b
 1	2
 2	10
-SELECT * FROM t1_char;
+SELECT * FROM t1_char ORDER BY a;
 a	b
 1	2
 2	10
 **** On Slave ****
-SELECT a,b,x FROM t1_int;
+SELECT a,b,x FROM t1_int ORDER BY a;
 a	b	x
-2	10	4711
 1	2	42
-SELECT a,b,HEX(x),HEX(y),HEX(z) FROM t1_bit;
+2	10	4711
+SELECT a,b,HEX(x),HEX(y),HEX(z) FROM t1_bit ORDER BY a;
 a	b	HEX(x)	HEX(y)	HEX(z)
-2	10	5	1C	1
 1	2	3	15	2
-SELECT a,b,x FROM t1_char;
+2	10	5	1C	1
+SELECT a,b,x FROM t1_char ORDER BY a;
 a	b	x
-2	10	Foo is a bar
 1	2	Just a test
+2	10	Foo is a bar
 INSERT INTO t9 VALUES (2);
 INSERT INTO t1_nodef VALUES (1,2);
 SHOW SLAVE STATUS;
@@ -327,22 +327,22 @@
 Seconds_Behind_Master	#
 INSERT INTO t7 VALUES (1),(2),(3);
 INSERT INTO t8 VALUES (1),(2),(3);
-SELECT * FROM t7;
+SELECT * FROM t7 ORDER BY a;
 a
 1
 2
 3
-SELECT * FROM t8;
+SELECT * FROM t8 ORDER BY a;
 a
 1
 2
 3
-SELECT * FROM t7;
+SELECT * FROM t7 ORDER BY a;
 a	e1	e2	e3	e4	e5	e6	e7	e8
 1	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 2	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 3	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
-SELECT * FROM t8;
+SELECT * FROM t8 ORDER BY a;
 a	e1	e2	e3	e4	e5	e6	e7	e8
 1	0	0	0	0	0	0	0	0
 2	0	0	0	0	0	0	0	0
@@ -358,22 +358,22 @@
 INSERT INTO t1_nodef VALUES (2,4,6);
 **** On Master ****
 UPDATE t1_nodef SET b=2*b WHERE a=1;
-SELECT * FROM t1_nodef;
+SELECT * FROM t1_nodef ORDER BY a;
 a	b
 1	4
 2	4
 **** On Slave ****
-SELECT * FROM t1_nodef;
+SELECT * FROM t1_nodef ORDER BY a;
 a	b	x
 1	4	3
 2	4	6
 **** On Master ****
 DELETE FROM t1_nodef WHERE a=2;
-SELECT * FROM t1_nodef;
+SELECT * FROM t1_nodef ORDER BY a;
 a	b
 1	4
 **** On Slave ****
-SELECT * FROM t1_nodef;
+SELECT * FROM t1_nodef ORDER BY a;
 a	b	x
 1	4	3
 **** Cleanup ****
Thread
bk commit into 5.1 tree (mats:1.2374) BUG#24490Mats Kindahl1 Dec