Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -ruN 212/patch_info/wl5151.info 214/patch_info/wl5151.info
- --- 212/patch_info/wl5151.info 2012-02-15 11:40:53.591548115 +0900
- +++ 214/patch_info/wl5151.info 1970-01-01 08:00:00.000000000 +0800
- @@ -1,6 +0,0 @@
- -File=wl5151.patch
- -Name=Backported wl5151 from mysql 5.5 (Row-based replication: attribute promotion and demotion.)
- -Version=1.0
- -Author=Percona <[email protected]>
- -License=GPL
- -Comment=http://dev.mysql.com/doc/refman/5.5/en/replication-features-differing-tables.html#replication-features-attribute-promotion
- diff -ruN 212/sql/field.cc 214/sql/field.cc
- --- 212/sql/field.cc 2012-02-15 11:40:54.604672749 +0900
- +++ 214/sql/field.cc 2012-02-15 11:40:47.775832663 +0900
- @@ -1004,7 +1004,8 @@
- Used below. In an anonymous namespace to not clash with definitions
- in other files.
- */
- -namespace {
- +namespace
- +{
- int compare(unsigned int a, unsigned int b)
- {
- if (a < b)
- @@ -1424,15 +1425,15 @@
- master's field size, @c false otherwise.
- */
- bool Field::compatible_field_size(uint field_metadata,
- - Relay_log_info *rli_arg __attribute__((unused)),
- - uint16 mflags __attribute__((unused)),
- + Relay_log_info *__attribute__((unused)),
- + uint16 __attribute__((unused)),
- int *order_var)
- {
- uint const source_size= pack_length_from_metadata(field_metadata);
- uint const destination_size= row_pack_length();
- DBUG_PRINT("debug", ("real_type: %d, source_size: %u, destination_size: %u",
- real_type(), source_size, destination_size));
- - *order_var = compare(source_size, destination_size);
- + *order_var= compare(source_size, destination_size);
- return true;
- }
- @@ -2962,15 +2963,45 @@
- }
- +/**
- + This method is used in row-based replication to verify that the
- + slave's field size is less than or equal to the master's field
- + size. The encoded field metadata (from the master or source) is
- + decoded and compared to the size of this field (the slave or
- + destination).
- +
- + @note
- +
- + The comparison is made so that if the source data (from the master)
- + is less than the target data (on the slave), -1 is returned in @c
- + <code>*order_var</code>. This implies that a conversion is
- + necessary, but that it is lossy and can result in truncation of the
- + value.
- +
- + If the source data is strictly greater than the target data, 1 is
- + returned in <code>*order_var</code>. This implies that the source
- + type can is contained in the target type and that a conversion is
- + necessary but is non-lossy.
- +
- + If no conversion is required to fit the source type in the target
- + type, 0 is returned in <code>*order_var</code>.
- + @param field_metadata Encoded size in field metadata
- + @param order_var Pointer to variable where the order
- + between the source field and this field
- + will be returned.
- +
- + @return @c true if this field's size is compatible with the
- + master's field size, @c false otherwise.
- +*/
- bool Field_new_decimal::compatible_field_size(uint field_metadata,
- - Relay_log_info * __attribute__((unused)),
- - uint16 mflags __attribute__((unused)),
- + Relay_log_info *__attribute__((unused)),
- + uint16 __attribute__((unused)),
- int *order_var)
- {
- - uint const source_precision= (field_metadata >> 8U) & 0x00ff;
- - uint const source_decimal= field_metadata & 0x00ff;
- - int order= compare(source_precision, precision);
- - *order_var= order != 0 ? order : compare(source_decimal, dec);
- + uint const src_precision= (field_metadata >> 8U) & 0x00ff;
- + uint const src_decimal= field_metadata & 0x00ff;
- + int order= compare(src_precision, precision);
- + *order_var= order != 0 ? order : compare(src_decimal, dec);
- return true;
- }
- @@ -6842,6 +6873,37 @@
- }
- #endif
- +/**
- + This method is used in row-based replication to verify that the
- + slave's field size is less than or equal to the master's field
- + size. The encoded field metadata (from the master or source) is
- + decoded and compared to the size of this field (the slave or
- + destination).
- +
- + @note
- +
- + The comparison is made so that if the source data (from the master)
- + is less than the target data (on the slave), -1 is returned in @c
- + <code>*order_var</code>. This implies that a conversion is
- + necessary, but that it is lossy and can result in truncation of the
- + value.
- +
- + If the source data is strictly greater than the target data, 1 is
- + returned in <code>*order_var</code>. This implies that the source
- + type can is contained in the target type and that a conversion is
- + necessary but is non-lossy.
- +
- + If no conversion is required to fit the source type in the target
- + type, 0 is returned in <code>*order_var</code>.
- + @param field_metadata Encoded size in field metadata
- + @param rli_arg Relay log information
- + @param order_var Pointer to variable where the order
- + between the source field and this field
- + will be returned.
- +
- + @return @c true if this field's size is compatible with the
- + master's field size, @c false otherwise.
- +*/
- bool
- Field_string::compatible_field_size(uint field_metadata,
- Relay_log_info *rli_arg,
- @@ -6852,7 +6914,7 @@
- const Check_field_param check_param = { this };
- if (rpl_master_has_bug(rli_arg, 37426, TRUE,
- check_field_for_37426, &check_param))
- - return FALSE; // Not compatible field sizes
- + return FALSE; // Not compatible field sizes
- #endif
- return Field::compatible_field_size(field_metadata, rli_arg, mflags, order_var);
- }
- @@ -9498,11 +9560,41 @@
- }
- +/**
- + This method is used in row-based replication to verify that the
- + slave's field size is less than or equal to the master's field
- + size. The encoded field metadata (from the master or source) is
- + decoded and compared to the size of this field (the slave or
- + destination).
- +
- + @note
- +
- + The comparison is made so that if the source data (from the master)
- + is less than the target data (on the slave), -1 is returned in @c
- + <code>*order_var</code>. This implies that a conversion is
- + necessary, but that it is lossy and can result in truncation of the
- + value.
- +
- + If the source data is strictly greater than the target data, 1 is
- + returned in <code>*order_var</code>. This implies that the source
- + type can is contained in the target type and that a conversion is
- + necessary but is non-lossy.
- +
- + If no conversion is required to fit the source type in the target
- + type, 0 is returned in <code>*order_var</code>.
- + @param field_metadata Encoded size in field metadata
- + @param mflags Flags from the table map event for the table.
- + @param order_var Pointer to variable where the order
- + between the source field and this field
- + will be returned.
- +
- + @return @c true if this field's size is compatible with the
- + master's field size, @c false otherwise.
- +*/
- bool
- Field_bit::compatible_field_size(uint field_metadata,
- - Relay_log_info * __attribute__((unused)),
- - uint16 mflags,
- - int *order_var)
- + Relay_log_info *__attribute__((unused)),
- + uint16 mflags, int *order_var)
- {
- DBUG_ENTER("Field_bit::compatible_field_size");
- DBUG_ASSERT((field_metadata >> 16) == 0);
- @@ -9518,8 +9610,9 @@
- We do this by computing the number of bytes to store the field
- instead, and then compare the result.
- - */
- - if (!(mflags & Table_map_log_event::TM_BIT_LEN_EXACT_F)) {
- + */
- + if (!(mflags & Table_map_log_event::TM_BIT_LEN_EXACT_F))
- + {
- from_bit_len= (from_bit_len + 7) / 8;
- to_bit_len= (to_bit_len + 7) / 8;
- }
- diff -ruN 212/sql/field.h 214/sql/field.h
- --- 212/sql/field.h 2012-02-15 11:40:53.765569523 +0900
- +++ 214/sql/field.h 2012-02-15 11:40:46.961732510 +0900
- @@ -189,7 +189,7 @@
- virtual uint32 pack_length_in_rec() const { return pack_length(); }
- virtual bool compatible_field_size(uint metadata, Relay_log_info *rli,
- uint16 mflags, int *order);
- - virtual uint pack_length_from_metadata(uint field_metadata)
- + virtual uint pack_length_from_metadata(uint field_metadata)
- {
- DBUG_ENTER("Field::pack_length_from_metadata");
- DBUG_RETURN(field_metadata);
- @@ -673,8 +673,12 @@
- return store_decimal_truncated(value,0);
- }
- int store_decimal_truncated(const my_decimal *,bool *truncated);
- - uint row_pack_length() { return pack_length(); }
- - uint32 pack_length_from_metadata(uint field_metadata) {
- + uint row_pack_length()
- + {
- + return pack_length();
- + }
- + uint32 pack_length_from_metadata(uint field_metadata)
- + {
- uint32 length= pack_length();
- DBUG_PRINT("result", ("pack_length_from_metadata(%d): %u",
- field_metadata, length));
- @@ -1787,7 +1791,10 @@
- }
- bool compatible_field_size(uint field_metadata, Relay_log_info *rli,
- uint16 mflags, int *order_var);
- - uint row_pack_length() { return field_length; }
- + uint row_pack_length()
- + {
- + return field_length;
- + }
- int pack_cmp(const uchar *a,const uchar *b,uint key_length,
- my_bool insert_or_update);
- int pack_cmp(const uchar *b,uint key_length,my_bool insert_or_update);
- @@ -2328,8 +2335,8 @@
- uint pack_length_from_metadata(uint field_metadata);
- uint row_pack_length()
- { return (bytes_in_rec + ((bit_len > 0) ? 1 : 0)); }
- - bool compatible_field_size(uint metadata, Relay_log_info *rli,
- - uint16 mflags, int *order_var);
- + bool compatible_field_size(uint metadata, Relay_log_info *rli, uint16 mflags,
- + int *order_var);
- void sql_type(String &str) const;
- virtual uchar *pack(uchar *to, const uchar *from,
- uint max_length, bool low_byte_first);
- @@ -2440,7 +2447,7 @@
- void init_for_tmp_table(enum_field_types sql_type_arg,
- uint32 max_length, uint32 decimals,
- bool maybe_null, bool is_unsigned,
- - uint pack_length = ~0U);
- + uint pack_length= ~0U);
- bool init(THD *thd, char *field_name, enum_field_types type, char *length,
- char *decimals, uint type_modifier, Item *default_value,
- diff -ruN 212/sql/log_event.cc 214/sql/log_event.cc
- --- 212/sql/log_event.cc 2012-02-15 11:40:54.642677424 +0900
- +++ 214/sql/log_event.cc 2012-02-15 11:40:47.837840290 +0900
- @@ -31,6 +31,7 @@
- #include "rpl_rli.h"
- #include "rpl_mi.h"
- #include "rpl_filter.h"
- +#include "rpl_utility.h"
- #include "rpl_record.h"
- #include <my_dir.h>
- @@ -38,7 +39,6 @@
- #include <base64.h>
- #include <my_bitmap.h>
- -#include "rpl_utility.h"
- #define log_cs &my_charset_latin1
- @@ -1599,7 +1599,7 @@
- type= byte0 | 0x30;
- }
- else
- - length = meta & 0xFF;
- + length= meta & 0xFF;
- }
- else
- length= meta;
- @@ -1749,16 +1749,16 @@
- char *pos= &buf[10];
- /* Copied from field.cc */
- - *pos--=0; // End NULL
- - part=(int) (tmp & 31);
- + *pos--= 0; // End NULL
- + part= (int) (tmp & 31);
- *pos--= (char) ('0'+part%10);
- *pos--= (char) ('0'+part/10);
- *pos--= ':';
- - part=(int) (tmp >> 5 & 15);
- + part= (int) (tmp >> 5 & 15);
- *pos--= (char) ('0'+part%10);
- *pos--= (char) ('0'+part/10);
- *pos--= ':';
- - part=(int) (tmp >> 9);
- + part= (int) (tmp >> 9);
- *pos--= (char) ('0'+part%10); part/=10;
- *pos--= (char) ('0'+part%10); part/=10;
- *pos--= (char) ('0'+part%10); part/=10;
- @@ -1767,7 +1767,7 @@
- my_snprintf(typestr, typestr_length, "DATE");
- return 3;
- }
- -
- +
- case MYSQL_TYPE_DATE:
- {
- uint i32= uint3korr(ptr);
- @@ -1786,7 +1786,8 @@
- }
- case MYSQL_TYPE_ENUM:
- - switch (meta & 0xFF) {
- + switch (meta & 0xFF)
- + {
- case 1:
- my_b_printf(file, "%d", (int) *ptr);
- my_snprintf(typestr, typestr_length, "ENUM(1 byte)");
- @@ -7597,8 +7598,7 @@
- MY_BITMAP *slave_skip_columns;
- if (!ptr->m_tabledef.compatible_with(thd,
- const_cast<Relay_log_info*>(rli),
- - ptr->table,
- - &conv_table,
- + ptr->table, &conv_table,
- &slave_skip_columns))
- {
- @@ -7619,9 +7619,7 @@
- DBUG_PRINT("debug", ("Table: %s.%s is compatible with master"
- " - conv_table: %p, slave_skip_columns: %p",
- ptr->table->s->db.str,
- - ptr->table->s->table_name.str,
- - conv_table,
- - slave_skip_columns));
- + ptr->table->s->table_name.str, conv_table, slave_skip_columns));
- ptr->m_conv_table= conv_table;
- ptr->m_slave_skip_columns= slave_skip_columns;
- }
- diff -ruN 212/sql/log_event_old.cc 214/sql/log_event_old.cc
- --- 212/sql/log_event_old.cc 2012-02-15 11:40:54.650678408 +0900
- +++ 214/sql/log_event_old.cc 2012-02-15 11:40:47.846841397 +0900
- @@ -123,9 +123,9 @@
- {
- TABLE *conv_table;
- MY_BITMAP *slave_skip_columns;
- - if (!ptr->m_tabledef.compatible_with(thd, const_cast<Relay_log_info*>(rli),
- - ptr->table,
- - &conv_table,
- + if (!ptr->m_tabledef.compatible_with(thd,
- + const_cast<Relay_log_info*>(rli),
- + ptr->table, &conv_table,
- &slave_skip_columns))
- {
- DBUG_PRINT("debug", ("Table: %s.%s is not compatible with master",
- @@ -1633,8 +1633,7 @@
- MY_BITMAP *slave_skip_columns;
- if (ptr->m_tabledef.compatible_with(thd,
- const_cast<Relay_log_info*>(rli),
- - ptr->table,
- - &conv_table,
- + ptr->table, &conv_table,
- &slave_skip_columns))
- {
- mysql_unlock_tables(thd, thd->lock);
- diff -ruN 212/sql/rpl_utility.cc 214/sql/rpl_utility.cc
- --- 212/sql/rpl_utility.cc 2012-02-15 11:40:54.662679888 +0900
- +++ 214/sql/rpl_utility.cc 2012-02-15 11:40:47.862843366 +0900
- @@ -39,7 +39,8 @@
- The somewhat contorted expression is to avoid overflow.
- */
- -uint32 uint_max(int bits) {
- +uint32 uint_max(int bits)
- +{
- return (((1UL << (bits - 1)) - 1) << 1) | 1;
- }
- @@ -640,7 +641,7 @@
- {
- if (source_type == MYSQL_TYPE_NEWDECIMAL ||
- source_type == MYSQL_TYPE_DECIMAL)
- - *order_var = 1; // Always require lossy conversions
- + *order_var= 1; // Always require lossy conversions
- else
- *order_var= compare_lengths(field, source_type, metadata);
- DBUG_ASSERT(*order_var != 0);
- @@ -896,15 +897,6 @@
- return true;
- }
- -/**
- - Create a conversion table.
- -
- - If the function is unable to create the conversion table, an error
- - will be printed and NULL will be returned.
- -
- - @return Pointer to conversion table, or NULL if unable to create
- - conversion table.
- - */
- MY_BITMAP* table_def::create_slave_skip_columns(THD *thd,
- Relay_log_info *rli,
- @@ -939,7 +931,17 @@
- return result;
- }
- -TABLE *table_def::create_conversion_table(THD *thd, Relay_log_info *rli, TABLE *target_table) const
- +/**
- + Create a conversion table.
- +
- + If the function is unable to create the conversion table, an error
- + will be printed and NULL will be returned.
- +
- + @return Pointer to conversion table, or NULL if unable to create
- + conversion table.
- +*/
- +TABLE *table_def::create_conversion_table(THD *thd, Relay_log_info *rli,
- + TABLE *target_table) const
- {
- DBUG_ENTER("table_def::create_conversion_table");
- @@ -1090,12 +1092,9 @@
- m_field_metadata(0), m_null_bits(0), m_flags(flags),
- m_memory(NULL), m_columns(size, column_names, column_names_size)
- {
- - m_memory= (uchar *)my_multi_malloc(MYF(MY_WME),
- - &m_type, size,
- - &m_field_metadata,
- - size * sizeof(uint16),
- - &m_null_bits, (size + 7) / 8,
- - NULL);
- + m_memory= (uchar *)my_multi_malloc(MYF(MY_WME), &m_type, size,
- + &m_field_metadata, size * sizeof(uint16),
- + &m_null_bits, (size + 7) / 8, NULL);
- bzero(m_field_metadata, size * sizeof(uint16));
- @@ -1142,8 +1141,8 @@
- }
- case MYSQL_TYPE_BIT:
- {
- - uint16 x= field_metadata[index++];
- - x = x + (field_metadata[index++] << 8U);
- + uint16 x= field_metadata[index++];
- + x= x + (field_metadata[index++] << 8U);
- m_field_metadata[i]= x;
- break;
- }
Advertisement
Add Comment
Please, Sign In to add comment