From: Date: June 11 2007 9:22pm Subject: bk commit into 5.1 tree (cbell:1.2550) List-Archive: http://lists.mysql.com/commits/28519 Message-Id: <200706111922.l5BJMrKT005688@mail.mysql.com> 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-11 15:22:36-04:00, cbell@mysql_cab_desk. +1 -0 Merge mysql_cab_desk.:C:/source/c++/mysql-5.1-new-rpl into mysql_cab_desk.:C:/source/c++/mysql-5.1_BUG_22086 MERGE: 1.2500.37.3 sql/log_event.cc@stripped, 2007-06-11 15:22:31-04:00, cbell@mysql_cab_desk. +0 -0 Auto merged MERGE: 1.281.1.1 # 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: mysql_cab_desk. # Root: C:/source/c++/mysql-5.1_BUG_22086/RESYNC --- 1.282/sql/log_event.cc 2007-06-11 15:22:47 -04:00 +++ 1.283/sql/log_event.cc 2007-06-11 15:22:47 -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,30 @@ 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= ((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 +6438,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 +6502,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 +6512,39 @@ strncpy(const_cast(m_dbnam), (const char*)ptr_dblen + 1, m_dblen + 1); strncpy(const_cast(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 +6683,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 +6761,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