MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:cbell Date:June 12 2007 7:13pm
Subject:bk commit into 5.1 tree (cbell:1.2547) BUG#22086
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of cbell. When cbell 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, 2007-06-12 15:12:45-04:00, cbell@stripped +8 -0
  BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash
    
  The solution implements a portion of WL#3228. The Table_map_log_event 
  was extended to write two arrays containing the width of each column 
  and the number of bytes used for the length for each column. 
    
  These arrays are written to the body of the data body portion of the 
  event that follows the headers. These arrays are used in the table_def 
  compatible_with() method to add checks for compatible field widths.
    
  Compatible field widths are cases where the master's columns are shorter
  than the slave. Another check was added to check the number of bytes 
  used in the fields. If the master has fields that are not using the same 
  number of bytes for the length, the code in unpack() can fail. This 
  check ensures the server (slave) stops gracefully if the length_bytes
  differ.
    
  A check is made to ensure the arrays are read only if the length of the 
  data body contains enough data to populate the arrays. If not, the 
  arrays are emptied so that the error handlers in compatible_with() are 
  ignored.
    
  The solution allows replication in mixed version topologies. Older 
  versions of 5.1 masters can replicate with 5.1 slaves that contain the 
  solution. similarly, 5.1 masters that contain the solution can replicate
  with older version of 5.1 slaves.

  mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test@stripped, 2007-06-12 15:12:39-04:00, cbell@stripped +109 -33
    BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash
        
    This patch contains enhancements to the rpl_extraSlave_Col test to test
    conditions where the slave has a different column size than the master.

  mysql-test/r/rpl_extraCol_innodb.result@stripped, 2007-06-12 15:12:39-04:00, cbell@stripped +140 -0
    BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash
        
    This patch contains updated results for the enhancements to the 
    rpl_extraSlave_Col test to test conditions where the slave has a 
    different column size than the master.
    

  mysql-test/r/rpl_extraCol_myisam.result@stripped, 2007-06-12 15:12:39-04:00, cbell@stripped +140 -0
    BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash
        
    This patch contains updated results for the enhancements to the 
    rpl_extraSlave_Col test to test conditions where the slave has a 
    different column size than the master.

  mysql-test/r/rpl_ndb_extraCol.result@stripped, 2007-06-12 15:12:39-04:00, cbell@stripped +140 -0
    BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash
        
    This patch contains updated results for the enhancements to the 
    rpl_ndb_extraCol test to test conditions where the slave has a 
    different column size than the master.

  sql/log_event.cc@stripped, 2007-06-12 15:12:39-04:00, cbell@stripped +72 -3
    BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash
        
    This patch contains enhancements to the Table_map_log_event that adds
    two arrays to the body of the event following the header. The arrays
    contain the column widths and column length bytes from the master. These
    arrays are stored in the Table_def class to allow the slave to check
    compatibility with the master on column type, width, and length bytes.

  sql/log_event.h@stripped, 2007-06-12 15:12:40-04:00, cbell@stripped +3 -1
    BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash
        
    This patch contains enhancements to the Table_map_log_event that adds
    two arrays to the body of the event following the header. The arrays
    contain the column widths and column length bytes from the master. 

  sql/rpl_utility.cc@stripped, 2007-06-12 15:12:40-04:00, cbell@stripped +38 -0
    BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash
        
    This patch contains enhancements to the Table_def class to allow the 
    slave to check compatibility with the master on column type, width, 
    and length bytes.

  sql/rpl_utility.h@stripped, 2007-06-12 15:12:40-04:00, cbell@stripped +50 -2
    BUG#22086 : Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash
        
    This patch contains enhancements to the Table_def class to allow the 
    slave to check compatibility with the master on column type, width, 
    and length bytes.

# 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:	cbell
# Host:	suse.vabb.com
# Root:	/home/Chuck/source/mysql-5.1_BUG_22086

--- 1.282/sql/log_event.cc	2007-06-11 03:45:33 -04:00
+++ 1.283/sql/log_event.cc	2007-06-12 15:12:39 -04:00
@@ -6369,7 +6369,9 @@
     m_tbllen(tbl->s->table_name.length),
     m_colcnt(tbl->s->fields), m_coltype(0),
     m_table_id(tid),
-    m_flags(flags)
+    m_flags(flags),
+    m_colwidth(0),
+    m_colwidthbytes(0)
 {
   DBUG_ASSERT(m_table_id != ~0UL);
   /*
@@ -6388,6 +6390,8 @@
   m_data_size+= m_dblen + 2;	// Include length and terminating \0
   m_data_size+= m_tbllen + 2;	// Include length and terminating \0
   m_data_size+= 1 + m_colcnt;	// COLCNT and column types
+  m_data_size+= sizeof(int) * m_colcnt;	// column widths
+  m_data_size+= sizeof(int) * m_colcnt;	// column width bytes
 
   /* If malloc fails, catched in is_valid() */
   if ((m_memory= (uchar*) my_malloc(m_colcnt, MYF(MY_WME))))
@@ -6396,9 +6400,32 @@
     for (unsigned int i= 0 ; i < m_table->s->fields ; ++i)
       m_coltype[i]= m_table->field[i]->type();
   }
+
+  /* Store the width for all fields */
+
+  /* If malloc fails, catched in is_valid() */
+  if ((m_colwidth= (int *) my_malloc(m_colcnt * sizeof(int), MYF(MY_WME))))
+    for (unsigned int i= 0 ; i < m_table->s->fields ; i++)
+      int2store(&m_colwidth[i], m_table->field[i]->field_length);
+
+  /* Store the length bytes for all fields */
+
+  /* If malloc fails, catched in is_valid() */
+  if ((m_colwidthbytes= (int *) my_malloc(m_colcnt * sizeof(int), MYF(MY_WME))))
+    for (unsigned int i= 0 ; i < m_table->s->fields ; i++)
+    {
+      int len_bytes= 0;
+      if (m_table->field[i]->type() == MYSQL_TYPE_VARCHAR)
+        len_bytes= ((Field_varstring *)m_table->field[i])->length_bytes;
+      if (len_bytes)
+        int2store(&m_colwidthbytes[i], len_bytes);
+      else
+        int2store(&m_colwidthbytes[i], 1);
+    }
 }
 #endif /* !defined(MYSQL_CLIENT) */
 
+
 /*
   Constructor used by slave to read the event from the binary log.
  */
@@ -6413,6 +6440,8 @@
 #endif
   m_memory(NULL)
 {
+  unsigned int bytes_read= 0;
+
   DBUG_ENTER("Table_map_log_event::Table_map_log_event(const char*,uint,...)");
 
   uint8 common_header_len= description_event->common_header_len;
@@ -6475,6 +6504,8 @@
                                      &m_dbnam, (uint) m_dblen + 1,
                                      &m_tblnam, (uint) m_tbllen + 1,
                                      &m_coltype, (uint) m_colcnt,
+                                     &m_colwidth, (uint) m_colcnt * sizeof(int),
+                                     &m_colwidthbytes, (uint) m_colcnt * sizeof(int),
                                      NullS);
 
   if (m_memory)
@@ -6483,6 +6514,39 @@
     strncpy(const_cast<char*>(m_dbnam), (const char*)ptr_dblen  + 1, m_dblen + 1);
     strncpy(const_cast<char*>(m_tblnam), (const char*)ptr_tbllen + 1, m_tbllen + 1);
     memcpy(m_coltype, ptr_after_colcnt, m_colcnt);
+    /*
+      Check to see if there is enough data to read the column width
+      and column width bytes arrays. If not, then the event is coming
+      from an older master.
+    */
+    DBUG_PRINT("info", ("The event data size is: %d!\n", event_len));
+    ptr_after_colcnt= ptr_after_colcnt + m_colcnt;
+    bytes_read= ptr_after_colcnt - (uchar *)buf;
+    DBUG_PRINT("info", ("Bytes read: %d.\n", bytes_read));
+    if (bytes_read < event_len)
+    {
+      for (int i= 0; i < (int) m_colcnt; i++)
+        m_colwidth[i] = uint2korr(ptr_after_colcnt + (i * sizeof(int)));
+      ptr_after_colcnt= ptr_after_colcnt + (m_colcnt * sizeof(int));
+      bytes_read= ptr_after_colcnt - (uchar *)buf;
+      DBUG_PRINT("info", ("Reading extended data body for event.\n"));
+      DBUG_PRINT("info", ("Bytes read: %d.\n", bytes_read));
+      for (int i= 0; i < (int) m_colcnt; i++)
+        m_colwidthbytes[i] = uint2korr(ptr_after_colcnt + (i * sizeof(int)));
+      ptr_after_colcnt= ptr_after_colcnt + (m_colcnt * sizeof(int));
+      bytes_read= ptr_after_colcnt - (uchar *)buf;
+      DBUG_PRINT("info", ("Bytes read: %d.\n", bytes_read));
+    }
+    /*
+      Connected to lower version master. Disregard column width check
+      and zero the arrays for the error handler. 
+    */
+    else
+      for(unsigned int i= 0; i < m_colcnt; i++)
+      {
+        m_colwidth[i]= 0;
+        m_colwidthbytes[i]= 0;
+      }
   }
 
   DBUG_VOID_RETURN;
@@ -6621,7 +6685,8 @@
       inside st_relay_log_info::clear_tables_to_lock() by calling the
       table_def destructor explicitly.
     */
-    new (&table_list->m_tabledef) table_def(m_coltype, m_colcnt);
+    new (&table_list->m_tabledef) table_def(m_coltype, m_colcnt, 
+      m_colwidth, m_colwidthbytes);
     table_list->m_tabledef_valid= TRUE;
 
     /*
@@ -6698,7 +6763,11 @@
           my_b_safe_write(file, tbuf,      sizeof(tbuf)) ||
           my_b_safe_write(file, (const uchar*)m_tblnam,  m_tbllen+1) ||
           my_b_safe_write(file, cbuf, (size_t) (cbuf_end - cbuf)) ||
-          my_b_safe_write(file, m_coltype, m_colcnt));
+          my_b_safe_write(file, m_coltype, m_colcnt) ||
+          my_b_safe_write(file, (const uchar *)m_colwidth, 
+            m_colcnt * sizeof(int)) ||
+          my_b_safe_write(file, (const uchar *)m_colwidthbytes, 
+            m_colcnt * sizeof(int)));
  }
 #endif
 

--- 1.152/sql/log_event.h	2007-06-04 19:15:00 -04:00
+++ 1.153/sql/log_event.h	2007-06-12 15:12:40 -04:00
@@ -196,7 +196,7 @@
 #define DELETE_FILE_HEADER_LEN 4
 #define FORMAT_DESCRIPTION_HEADER_LEN (START_V3_HEADER_LEN+1+LOG_EVENT_TYPES)
 #define ROWS_HEADER_LEN        8
-#define TABLE_MAP_HEADER_LEN   8
+#define TABLE_MAP_HEADER_LEN   8 
 #define EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN (4 + 4 + 4 + 1)
 #define EXECUTE_LOAD_QUERY_HEADER_LEN  (QUERY_HEADER_LEN + EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN)
 #define INCIDENT_HEADER_LEN    2
@@ -2079,6 +2079,8 @@
   size_t         m_tbllen;
   ulong          m_colcnt;
   uchar         *m_coltype;
+  int           *m_colwidth;
+  int           *m_colwidthbytes;
 
   uchar         *m_memory;
   ulong          m_table_id;

--- 1.2/mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test	2007-04-25 15:33:15 -04:00
+++ 1.3/mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test	2007-06-12 15:12:39 -04:00
@@ -70,39 +70,115 @@
 ### Should Stop Slave or truncate value  ###
 ############################################
 
-## BUG22086
-#--echo *** Create t2 on slave  ***
-#STOP SLAVE;
-#RESET SLAVE;
-#eval CREATE TABLE t2 (a INT, b INT PRIMARY KEY, c CHAR(5),
-#                      d FLOAT DEFAULT '2.00',
-#                      e CHAR(5) DEFAULT 'TEST2')
-#                      ENGINE=$engine_type;
-#
-#--echo *** Create t2 on Master ***
-#connection master;
-#eval CREATE TABLE t2 (a INT PRIMARY KEY, b INT, c CHAR(10)
-#                       ) ENGINE=$engine_type;
-#RESET MASTER;
-#
-#--echo *** Start Slave ***
-#connection slave;
-#START SLAVE;
-#
-#--echo *** Master Data Insert ***
-#connection master;
-#
-#INSERT INTO t2 () VALUES(1,2,'Kyle, TEX'),(2,1,'JOE AUSTIN'),(3,4,'QA TESTING');
-#SELECT * FROM t2 ORDER BY a;
-
-#--echo *** Select from slave ***
-#sync_slave_with_master;
-#SELECT * FROM t2 ORDER BY a;
-
-#--echo *** Drop t2  ***
-#connection master;
-#DROP TABLE t2;
-#sync_slave_with_master;
+# BUG22086 - Extra Slave Col: Char(5) on slave and Char(10) on master cause mysqld crash
+ 
+--echo *** Create t2 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+
+# first test tests the size of the fields
+eval CREATE TABLE t2 (a INT, b INT PRIMARY KEY, c CHAR(5))
+                      ENGINE=$engine_type;
+ 
+--echo *** Create t2 on Master ***
+connection master;
+eval CREATE TABLE t2 (a INT PRIMARY KEY, b INT, c CHAR(10))
+                      ENGINE=$engine_type; 
+RESET MASTER;
+
+--echo *** Start Slave ***
+connection slave;
+START SLAVE;
+
+--echo *** Master Data Insert ***
+connection master;
+
+INSERT INTO t2 VALUES
+ (1,2,'Sam'),
+ (2,1,'Kyle, TEX'),
+ (3,5,'JOE AUSTIN'),
+ (4,4,'QA TESTING');
+
+SELECT * FROM t2 ORDER BY a;
+
+--echo ********************************************
+--echo *** Expect slave to fail with Error 1523 *** 
+--echo ********************************************
+
+connection slave;
+wait_for_slave_to_stop;
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 #
+--query_vertical SHOW SLAVE STATUS
+STOP SLAVE;
+
+--echo ********************************************
+--echo *** Repair column and restart slave.     ***
+--echo ********************************************
+--echo *** Select from slave ***
+SELECT * FROM t2 ORDER BY a;
+ALTER TABLE t2 CHANGE c c CHAR(10);
+START SLAVE;
+
+connection master;
+sync_slave_with_master;
+
+--echo *** Select from slave ***
+SELECT * FROM t2 ORDER BY a;
+
+--echo *** Drop t2  ***
+connection master;
+DROP TABLE t2;
+sync_slave_with_master;
+
+#second test tests length bytes mismatch
+--echo *** Create t2 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+
+# first test tests the size of the fields
+eval CREATE TABLE t2 (a INT, b INT PRIMARY KEY, c varchar(400))
+                      ENGINE=$engine_type;
+ 
+--echo *** Create t2 on Master ***
+connection master;
+eval CREATE TABLE t2 (a INT PRIMARY KEY, b INT, c varchar(250))
+                      ENGINE=$engine_type; 
+RESET MASTER;
+
+--echo *** Start Slave ***
+connection slave;
+START SLAVE;
+
+--echo *** Master Data Insert ***
+connection master;
+
+INSERT INTO t2 VALUES (1,2,'Samuel Text Writer');
+SELECT * FROM t2 ORDER BY a;
+
+--echo ********************************************
+--echo *** Expect slave to fail with Error 1523 *** 
+--echo ********************************************
+
+connection slave;
+wait_for_slave_to_stop;
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 #
+--query_vertical SHOW SLAVE STATUS
+STOP SLAVE;
+RESET SLAVE;
+
+connection master;
+RESET MASTER;
+
+--echo *** Start Slave ***
+connection slave;
+START SLAVE;
+
+--echo *** Drop t2  ***
+connection master;
+DROP TABLE t2;
+sync_slave_with_master;
 
 ####################################
 ### Try to replicate BLOB to INT ###

--- 1.3/mysql-test/r/rpl_extraCol_innodb.result	2007-03-29 15:59:03 -04:00
+++ 1.4/mysql-test/r/rpl_extraCol_innodb.result	2007-06-12 15:12:39 -04:00
@@ -33,6 +33,146 @@
 3	4	QA	2	TEST
 *** Drop t1  ***
 DROP TABLE t1;
+*** Create t2 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t2 (a INT, b INT PRIMARY KEY, c CHAR(5))
+ENGINE='InnoDB';
+*** Create t2 on Master ***
+CREATE TABLE t2 (a INT PRIMARY KEY, b INT, c CHAR(10))
+ENGINE='InnoDB';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+INSERT INTO t2 VALUES
+(1,2,'Sam'),
+(2,1,'Kyle, TEX'),
+(3,5,'JOE AUSTIN'),
+(4,4,'QA TESTING');
+SELECT * FROM t2 ORDER BY a;
+a	b	c
+1	2	Sam
+2	1	Kyle, TEX
+3	5	JOE AUSTIN
+4	4	QA TESTING
+********************************************
+*** Expect slave to fail with Error 1523 *** 
+********************************************
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	MASTER_PORT
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1523
+Last_Error	Column 2 width mismatch - received width 10, test.t2 has width 5
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+STOP SLAVE;
+********************************************
+*** Repair column and restart slave.     ***
+********************************************
+*** Select from slave ***
+SELECT * FROM t2 ORDER BY a;
+a	b	c
+ALTER TABLE t2 CHANGE c c CHAR(10);
+START SLAVE;
+*** Select from slave ***
+SELECT * FROM t2 ORDER BY a;
+a	b	c
+1	2	Sam
+2	1	Kyle, TEX
+3	5	JOE AUSTIN
+4	4	QA TESTING
+*** Drop t2  ***
+DROP TABLE t2;
+*** Create t2 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t2 (a INT, b INT PRIMARY KEY, c varchar(400))
+ENGINE='InnoDB';
+*** Create t2 on Master ***
+CREATE TABLE t2 (a INT PRIMARY KEY, b INT, c varchar(250))
+ENGINE='InnoDB';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+INSERT INTO t2 VALUES (1,2,'Samuel Text Writer');
+SELECT * FROM t2 ORDER BY a;
+a	b	c
+1	2	Samuel Text Writer
+********************************************
+*** Expect slave to fail with Error 1523 *** 
+********************************************
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	MASTER_PORT
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1523
+Last_Error	Column 2 length_bytes mismatch - received length_bytes 1, test.t2 has length_bytes 2
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+STOP SLAVE;
+RESET SLAVE;
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Drop t2  ***
+DROP TABLE t2;
 *** Create t3 on slave  ***
 STOP SLAVE;
 RESET SLAVE;

--- 1.3/mysql-test/r/rpl_extraCol_myisam.result	2007-03-29 15:59:03 -04:00
+++ 1.4/mysql-test/r/rpl_extraCol_myisam.result	2007-06-12 15:12:39 -04:00
@@ -33,6 +33,146 @@
 3	4	QA	2	TEST
 *** Drop t1  ***
 DROP TABLE t1;
+*** Create t2 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t2 (a INT, b INT PRIMARY KEY, c CHAR(5))
+ENGINE='MyISAM';
+*** Create t2 on Master ***
+CREATE TABLE t2 (a INT PRIMARY KEY, b INT, c CHAR(10))
+ENGINE='MyISAM';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+INSERT INTO t2 VALUES
+(1,2,'Sam'),
+(2,1,'Kyle, TEX'),
+(3,5,'JOE AUSTIN'),
+(4,4,'QA TESTING');
+SELECT * FROM t2 ORDER BY a;
+a	b	c
+1	2	Sam
+2	1	Kyle, TEX
+3	5	JOE AUSTIN
+4	4	QA TESTING
+********************************************
+*** Expect slave to fail with Error 1523 *** 
+********************************************
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	MASTER_PORT
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1523
+Last_Error	Column 2 width mismatch - received width 10, test.t2 has width 5
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+STOP SLAVE;
+********************************************
+*** Repair column and restart slave.     ***
+********************************************
+*** Select from slave ***
+SELECT * FROM t2 ORDER BY a;
+a	b	c
+ALTER TABLE t2 CHANGE c c CHAR(10);
+START SLAVE;
+*** Select from slave ***
+SELECT * FROM t2 ORDER BY a;
+a	b	c
+1	2	Sam
+2	1	Kyle, TEX
+3	5	JOE AUSTIN
+4	4	QA TESTING
+*** Drop t2  ***
+DROP TABLE t2;
+*** Create t2 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t2 (a INT, b INT PRIMARY KEY, c varchar(400))
+ENGINE='MyISAM';
+*** Create t2 on Master ***
+CREATE TABLE t2 (a INT PRIMARY KEY, b INT, c varchar(250))
+ENGINE='MyISAM';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+INSERT INTO t2 VALUES (1,2,'Samuel Text Writer');
+SELECT * FROM t2 ORDER BY a;
+a	b	c
+1	2	Samuel Text Writer
+********************************************
+*** Expect slave to fail with Error 1523 *** 
+********************************************
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	MASTER_PORT
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1523
+Last_Error	Column 2 length_bytes mismatch - received length_bytes 1, test.t2 has length_bytes 2
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+STOP SLAVE;
+RESET SLAVE;
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Drop t2  ***
+DROP TABLE t2;
 *** Create t3 on slave  ***
 STOP SLAVE;
 RESET SLAVE;

--- 1.4/mysql-test/r/rpl_ndb_extraCol.result	2007-04-02 04:54:26 -04:00
+++ 1.5/mysql-test/r/rpl_ndb_extraCol.result	2007-06-12 15:12:39 -04:00
@@ -33,6 +33,146 @@
 3	4	QA	NULL	NULL
 *** Drop t1  ***
 DROP TABLE t1;
+*** Create t2 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t2 (a INT, b INT PRIMARY KEY, c CHAR(5))
+ENGINE='NDB';
+*** Create t2 on Master ***
+CREATE TABLE t2 (a INT PRIMARY KEY, b INT, c CHAR(10))
+ENGINE='NDB';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+INSERT INTO t2 VALUES
+(1,2,'Sam'),
+(2,1,'Kyle, TEX'),
+(3,5,'JOE AUSTIN'),
+(4,4,'QA TESTING');
+SELECT * FROM t2 ORDER BY a;
+a	b	c
+1	2	Sam
+2	1	Kyle, TEX
+3	5	JOE AUSTIN
+4	4	QA TESTING
+********************************************
+*** Expect slave to fail with Error 1523 *** 
+********************************************
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	MASTER_PORT
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1523
+Last_Error	Column 2 width mismatch - received width 10, test.t2 has width 5
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+STOP SLAVE;
+********************************************
+*** Repair column and restart slave.     ***
+********************************************
+*** Select from slave ***
+SELECT * FROM t2 ORDER BY a;
+a	b	c
+ALTER TABLE t2 CHANGE c c CHAR(10);
+START SLAVE;
+*** Select from slave ***
+SELECT * FROM t2 ORDER BY a;
+a	b	c
+1	2	Sam
+2	1	Kyle, TEX
+3	5	JOE AUSTIN
+4	4	QA TESTING
+*** Drop t2  ***
+DROP TABLE t2;
+*** Create t2 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t2 (a INT, b INT PRIMARY KEY, c varchar(400))
+ENGINE='NDB';
+*** Create t2 on Master ***
+CREATE TABLE t2 (a INT PRIMARY KEY, b INT, c varchar(250))
+ENGINE='NDB';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+INSERT INTO t2 VALUES (1,2,'Samuel Text Writer');
+SELECT * FROM t2 ORDER BY a;
+a	b	c
+1	2	Samuel Text Writer
+********************************************
+*** Expect slave to fail with Error 1523 *** 
+********************************************
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	MASTER_PORT
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1523
+Last_Error	Column 2 length_bytes mismatch - received length_bytes 1, test.t2 has length_bytes 2
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+STOP SLAVE;
+RESET SLAVE;
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Drop t2  ***
+DROP TABLE t2;
 *** Create t3 on slave  ***
 STOP SLAVE;
 RESET SLAVE;

--- 1.6/sql/rpl_utility.cc	2007-05-10 05:59:28 -04:00
+++ 1.7/sql/rpl_utility.cc	2007-06-12 15:12:40 -04:00
@@ -111,6 +111,8 @@
 table_def::compatible_with(RELAY_LOG_INFO const *rli_arg, TABLE *table)
   const
 {
+  int len_bytes= 0;
+
   /*
     We only check the initial columns for the tables.
   */
@@ -137,6 +139,9 @@
 
   for (uint col= 0 ; col < cols_to_check ; ++col)
   {
+    /*
+       Check column types for compatibility.
+    */
     if (table->field[col]->type() != type(col))
     {
       DBUG_ASSERT(col < size() && col < tsh->fields);
@@ -147,6 +152,39 @@
                       "received type %d, %s.%s has type %d",
                       col, type(col), tsh->db.str, tsh->table_name.str,
                       table->field[col]->type());
+    }
+    /*
+       Check column widths for compatibility.
+    */
+    if (!error && (table->field[col]->field_length < (uint)width(col)))
+    {
+      DBUG_ASSERT(col < size() && col < tsh->fields);
+      DBUG_ASSERT(tsh->db.str && tsh->table_name.str);
+      error= 1;
+      slave_print_msg(ERROR_LEVEL, rli, ER_BINLOG_ROW_WRONG_TABLE_DEF,
+                      "Column %d width mismatch - "
+                      "received width %d, %s.%s has width %d",
+                      col, width(col), tsh->db.str, tsh->table_name.str,
+                      table->field[col]->field_length);
+    }
+    /*
+       Check column field length bytes for compatibility.
+    */
+   
+    if (table->field[col]->type() == MYSQL_TYPE_VARCHAR)
+      len_bytes= ((Field_varstring *)table->field[col])->length_bytes;
+    else
+      len_bytes= 0;
+    if (!error && len_bytes && (len_bytes != width_bytes(col)))
+    {
+      DBUG_ASSERT(col < size() && col < tsh->fields);
+      DBUG_ASSERT(tsh->db.str && tsh->table_name.str);
+      error= 1;
+      slave_print_msg(ERROR_LEVEL, rli, ER_BINLOG_ROW_WRONG_TABLE_DEF,
+                      "Column %d length_bytes mismatch - "
+                      "received length_bytes %d, %s.%s has length_bytes %d",
+                      col, width_bytes(col), tsh->db.str, tsh->table_name.str,
+                      len_bytes);
     }
   }
 

--- 1.6/sql/rpl_utility.h	2007-05-23 18:39:21 -04:00
+++ 1.7/sql/rpl_utility.h	2007-06-12 15:12:40 -04:00
@@ -57,19 +57,33 @@
 
     @param types Array of types
     @param size  Number of elements in array 'types'
+    @param widths Array of widths
    */
-  table_def(field_type *types, ulong size)
-    : m_size(size), m_type(new unsigned char [size])
+  table_def(field_type *types, ulong size, int *widths, int *len_bytes)
+    : m_size(size), m_type(new unsigned char [size]), 
+      m_widths(new int[size]), m_width_bytes(new int[size])
   {
     if (m_type)
       memcpy(m_type, types, size);
     else
       m_size= 0;
+    if (m_widths)
+      memcpy(m_widths, widths, size * sizeof(int));
+    else
+      m_widths= 0;
+    if (m_width_bytes)
+      memcpy(m_width_bytes, len_bytes, size * sizeof(int));
+    else
+      m_width_bytes= 0;
   }
 
   ~table_def() {
     if (m_type)
       delete [] m_type;
+    if (m_widths)
+      delete [] m_widths;
+    if (m_width_bytes)
+      delete [] m_width_bytes;
 #ifndef DBUG_OFF
     m_type= 0;
     m_size= 0;
@@ -99,6 +113,38 @@
     return m_type[index];
   }
 
+  /*
+    Return the length for the specified field.
+
+    @param index Field index to return data for
+
+    @return Will return width for field <code>index</code>. 
+   */
+  int width(ulong index) const
+  {
+    DBUG_ASSERT(index < m_size);
+    if (m_widths)
+      return m_widths[index];
+    else
+      return 0;
+  }
+
+  /*
+    Return the length_bytes for the specified field.
+
+    @param index Field index to return data for
+
+    @return Will return length_bytes for field <code>index</code>. 
+   */
+  int width_bytes(ulong index) const
+  {
+    DBUG_ASSERT(index < m_size);
+    if (m_width_bytes)
+      return m_width_bytes[index];
+    else
+      return 0;
+  }
+
   /**
     Decide if the table definition is compatible with a table.
 
@@ -121,6 +167,8 @@
 private:
   ulong m_size;           // Number of elements in the types array
   field_type *m_type;                     // Array of type descriptors
+  int *m_widths;          // Array of widths
+  int *m_width_bytes;     // Array of field length_bytes
 };
 
 /**
Thread
bk commit into 5.1 tree (cbell:1.2547) BUG#22086cbell12 Jun