Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-13629

slave type conversion failure reports tinyblob independently of actual blob type

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 5.5, 10.0, 10.1, 10.2, 10.3
    • 10.4
    • Replication
    • None

    Description

      Try to replicate blob to any incompatible data type and observe error like this:

      Column 0 of table 'test.t1' cannot be converted from type 'tinyblob' to type 'int(11)'

      The problem is that master stores "packlength" of blob, while slave takes it as a maximum field length.

      Suggested patch:

      diff --git a/sql/field.cc b/sql/field.cc
      index e41516a..3f2dc37 100644
      --- a/sql/field.cc
      +++ b/sql/field.cc
      @@ -10222,20 +10222,6 @@ bool Column_definition::check(THD *thd)
         DBUG_RETURN(FALSE); /* success */
       }
       
      -enum_field_types get_blob_type_from_length(ulong length)
      -{
      -  enum_field_types type;
      -  if (length < 256)
      -    type= MYSQL_TYPE_TINY_BLOB;
      -  else if (length < 65536)
      -    type= MYSQL_TYPE_BLOB;
      -  else if (length < 256L*256L*256L)
      -    type= MYSQL_TYPE_MEDIUM_BLOB;
      -  else
      -    type= MYSQL_TYPE_LONG_BLOB;
      -  return type;
      -}
      -
       
       uint pack_length_to_packflag(uint type)
       {
      diff --git a/sql/field.h b/sql/field.h
      index f3270d2..a96d50e 100644
      --- a/sql/field.h
      +++ b/sql/field.h
      @@ -4426,7 +4426,6 @@ class Copy_field :public Sql_alloc {
       
       
       uint pack_length_to_packflag(uint type);
      -enum_field_types get_blob_type_from_length(ulong length);
       int set_field_to_null(Field *field);
       int set_field_to_null_with_conversions(Field *field, bool no_conversions);
       int convert_null_to_field_value_or_error(Field *field);
      diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc
      index f7e224d..fa5b20b 100644
      --- a/sql/rpl_utility.cc
      +++ b/sql/rpl_utility.cc
      @@ -468,21 +468,21 @@ 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:
      +    case 3:
             str->set_ascii(STRING_WITH_LEN("mediumblob"));
             break;
       
      -    case MYSQL_TYPE_LONG_BLOB:
      +    case 4:
             str->set_ascii(STRING_WITH_LEN("longblob"));
             break;
       
      -    case MYSQL_TYPE_BLOB:
      +    case 2:
             str->set_ascii(STRING_WITH_LEN("blob"));
             break;
      
      

      Many tests have to be updated accordingly.

      Attachments

        Activity

          People

            Elkin Andrei Elkin
            svoj Sergey Vojtovich
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.