[MDEV-13629] slave type conversion failure reports tinyblob independently of actual blob type Created: 2017-08-23  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Replication
Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Sergey Vojtovich Assignee: Andrei Elkin
Resolution: Unresolved Votes: 0
Labels: 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.



 Comments   
Comment by Sergey Vojtovich [ 2017-08-23 ]

It affects all MariaDB versions, please adjust FixVersion as you see fit.

Generated at Thu Feb 08 08:07:05 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.