diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-08-28 10:18:41 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-08-28 10:18:41 +0300 |
commit | e41eb044f19e3ee9b881344565924dd6b9d20e1a (patch) | |
tree | 72db01fe401eca2e794b9f02edec0200e78416b6 /sql | |
parent | 947b0b5722117350c83656ee0b23502be59b7d2b (diff) | |
parent | 7aac83580a5c5a6042b5d03d1031750cb0d5d6ea (diff) | |
download | mariadb-git-e41eb044f19e3ee9b881344565924dd6b9d20e1a.tar.gz |
Merge 10.2 into 10.3
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 45 | ||||
-rw-r--r-- | sql/field.h | 3 | ||||
-rw-r--r-- | sql/rpl_utility.cc | 49 | ||||
-rw-r--r-- | sql/share/errmsg-utf8.txt | 2 |
4 files changed, 79 insertions, 20 deletions
diff --git a/sql/field.cc b/sql/field.cc index fc5ca7675ac..29446b9378b 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -7310,6 +7310,28 @@ void Field_string::sql_type(String &res) const res.append(STRING_WITH_LEN(" binary")); } +/** + For fields which are associated with character sets their length is provided + in octets and their character set information is also provided as part of + type information. + + @param res String which contains filed type and length. +*/ +void Field_string::sql_rpl_type(String *res) const +{ + CHARSET_INFO *cs=charset(); + if (Field_string::has_charset()) + { + size_t length= cs->cset->snprintf(cs, (char*) res->ptr(), + res->alloced_length(), + "char(%u octets) character set %s", + field_length, + charset()->csname); + res->length(length); + } + else + Field_string::sql_type(*res); + } uchar *Field_string::pack(uchar *to, const uchar *from, uint max_length) { @@ -7730,6 +7752,29 @@ void Field_varstring::sql_type(String &res) const res.append(STRING_WITH_LEN(" binary")); } +/** + For fields which are associated with character sets their length is provided + in octets and their character set information is also provided as part of + type information. + + @param res String which contains filed type and length. +*/ +void Field_varstring::sql_rpl_type(String *res) const +{ + CHARSET_INFO *cs=charset(); + if (Field_varstring::has_charset()) + { + size_t length= cs->cset->snprintf(cs, (char*) res->ptr(), + res->alloced_length(), + "varchar(%u octets) character set %s", + field_length, + charset()->csname); + res->length(length); + } + else + Field_varstring::sql_type(*res); +} + uint32 Field_varstring::data_length() { diff --git a/sql/field.h b/sql/field.h index 330523f5864..39bd10af525 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1140,6 +1140,7 @@ public: in str and restore it with set() if needed */ virtual void sql_type(String &str) const =0; + virtual void sql_rpl_type(String *str) const { sql_type(*str); } virtual uint size_of() const =0; // For new field inline bool is_null(my_ptrdiff_t row_offset= 0) const { @@ -3362,6 +3363,7 @@ public: int cmp(const uchar *,const uchar *); void sort_string(uchar *buff,uint length); void sql_type(String &str) const; + void sql_rpl_type(String*) const; virtual uchar *pack(uchar *to, const uchar *from, uint max_length); virtual const uchar *unpack(uchar* to, const uchar *from, @@ -3472,6 +3474,7 @@ public: uint get_key_image(uchar *buff,uint length, imagetype type); void set_key_image(const uchar *buff,uint length); void sql_type(String &str) const; + void sql_rpl_type(String*) const; virtual uchar *pack(uchar *to, const uchar *from, uint max_length); virtual const uchar *unpack(uchar* to, const uchar *from, const uchar *from_end, uint param_data); diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index b36838b9b22..437d58d772f 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -352,7 +352,8 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) /** */ -void show_sql_type(enum_field_types type, uint16 metadata, String *str, CHARSET_INFO *field_cs) +void show_sql_type(enum_field_types type, uint16 metadata, String *str, + bool char_with_octets) { DBUG_ENTER("show_sql_type"); DBUG_PRINT("enter", ("type: %d, metadata: 0x%x", type, metadata)); @@ -420,11 +421,13 @@ void show_sql_type(enum_field_types type, uint16 metadata, String *str, CHARSET_ case MYSQL_TYPE_VARCHAR_COMPRESSED: { CHARSET_INFO *cs= str->charset(); - size_t length= - cs->cset->snprintf(cs, (char*) str->ptr(), str->alloced_length(), - "varchar(%u)%s", metadata, - type == MYSQL_TYPE_VARCHAR_COMPRESSED ? " compressed" - : ""); + size_t length=0; + if (char_with_octets) + length= cs->cset->snprintf(cs, (char*) str->ptr(), str->alloced_length(), + "varchar(%u octets)", metadata); + else + length= cs->cset->snprintf(cs, (char*) str->ptr(), str->alloced_length(), + "varbinary(%u)", metadata); str->length(length); } break; @@ -475,22 +478,22 @@ void show_sql_type(enum_field_types type, uint16 metadata, String *str, CHARSET_ it is necessary to check the pack length to figure out what kind of blob it really is. */ - switch (get_blob_type_from_length(metadata)) + switch (metadata) { - case MYSQL_TYPE_TINY_BLOB: + case 1: str->set_ascii(STRING_WITH_LEN("tinyblob")); break; - case MYSQL_TYPE_MEDIUM_BLOB: - str->set_ascii(STRING_WITH_LEN("mediumblob")); + case 2: + str->set_ascii(STRING_WITH_LEN("blob")); break; - case MYSQL_TYPE_LONG_BLOB: - str->set_ascii(STRING_WITH_LEN("longblob")); + case 3: + str->set_ascii(STRING_WITH_LEN("mediumblob")); break; - case MYSQL_TYPE_BLOB: - str->set_ascii(STRING_WITH_LEN("blob")); + case 4: + str->set_ascii(STRING_WITH_LEN("longblob")); break; default: @@ -509,9 +512,13 @@ void show_sql_type(enum_field_types type, uint16 metadata, String *str, CHARSET_ */ CHARSET_INFO *cs= str->charset(); uint bytes= (((metadata >> 4) & 0x300) ^ 0x300) + (metadata & 0x00ff); - size_t length= - cs->cset->snprintf(cs, (char*) str->ptr(), str->alloced_length(), - "char(%d)", bytes / field_cs->mbmaxlen); + size_t length=0; + if (char_with_octets) + length= cs->cset->snprintf(cs, (char*) str->ptr(), str->alloced_length(), + "char(%u octets)", bytes); + else + length= cs->cset->snprintf(cs, (char*) str->ptr(), str->alloced_length(), + "binary(%u)", bytes); str->length(length); } break; @@ -948,9 +955,13 @@ table_def::compatible_with(THD *thd, rpl_group_info *rgi, String source_type(source_buf, sizeof(source_buf), &my_charset_latin1); String target_type(target_buf, sizeof(target_buf), &my_charset_latin1); THD *thd= table->in_use; + bool char_with_octets= field->cmp_type() == STRING_RESULT ? + field->has_charset() : true; + + show_sql_type(type(col), field_metadata(col), &source_type, + char_with_octets); + field->sql_rpl_type(&target_type); - show_sql_type(type(col), field_metadata(col), &source_type, field->charset()); - field->sql_type(target_type); rli->report(ERROR_LEVEL, ER_SLAVE_CONVERSION_FAILED, rgi->gtid_info(), ER_THD(thd, ER_SLAVE_CONVERSION_FAILED), col, db_name, tbl_name, diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 99af1c60287..b6cd8e6487d 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -6461,7 +6461,7 @@ ER_MESSAGE_AND_STATEMENT eng "%s Statement: %s" ER_SLAVE_CONVERSION_FAILED - eng "Column %d of table '%-.192s.%-.192s' cannot be converted from type '%-.32s' to type '%-.32s'" + eng "Column %d of table '%-.192s.%-.192s' cannot be converted from type '%-.50s' to type '%-.50s'" ER_SLAVE_CANT_CREATE_CONVERSION eng "Can't create conversion table for table '%-.192s.%-.192s'" ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT |