[MDEV-19710] Split the server side code in rpl_utility.cc into virtual methods in Type_handler Created: 2019-06-07  Updated: 2020-05-11  Resolved: 2019-06-07

Status: Closed
Project: MariaDB Server
Component/s: Replication
Fix Version/s: 10.5.0

Type: Task Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed
PartOf
includes MDEV-9219 Split rpl_utility.cc:can_convert_fiel... Open

 Description   

The server side code in rpl_utility.cc is not friendly to pluggable data types, which will want to have their own rules on data type conversion during replication.

The client side code used by mysqlbinlog is out of scope of this task.

The affected functions:

  • max_display_length_for_field()
  • show_sql_type()
  • can_convert_field_to()

Instead of testing for field->real_type() inside these functions, we'll introduce the following new code:

  • New data types:

    enum enum_conv_type
    {
      CONV_TYPE_PRECISE,
      CONV_TYPE_VARIANT,
      CONV_TYPE_SUBSET_TO_SUPERSET,
      CONV_TYPE_SUPERSET_TO_SUBSET,
      CONV_TYPE_IMPOSSIBLE
    };
     
     
    class Conv_param
    {
      uint16 m_table_def_flags;
    public:
      Conv_param(uint16 table_def_flags)
       :m_table_def_flags(table_def_flags)
      { }
      uint16 table_def_flags() const { return m_table_def_flags; }
    };
     
     
    class Conv_source: public Type_handler_hybrid_field_type
    {
      enum_field_types m_type;
      uint16 m_metadata;
      CHARSET_INFO *m_cs;
    public:
      Conv_source(const Type_handler *h, uint16 metadata, CHARSET_INFO *cs)
       :Type_handler_hybrid_field_type(h),
        m_metadata(metadata),
        m_cs(cs)
      {
        DBUG_ASSERT(cs);
      }
      uint16 metadata() const { return m_metadata; }
      uint mbmaxlen() const { return m_cs->mbmaxlen; }
    };
    

  • A new virtual method in Field

    virtual enum_conv_type rpl_conv_type_from(const Conv_source &source,
                                              const Relay_log_info *rli,
                                              const Conv_param &param)
                                              const;
    

  • A new virtual method in Field

    enum_conv_type rpl_conv_type_from_same_data_type(uint16 metadata,
                                                     const Relay_log_info *rli,
                                                     const Conv_param &param)
                                                     const;
    

  • A new method in Type_handler

    virtual void show_binlog_type(const Conv_source &src, String *str) const;
    

  • A new virtual method in Type_handler

    virtual uint32 max_display_length_for_field(const Conv_source &src) const;
    

Let's also put the new code into a new file rpl_utility_server.cc, to split the server side code and the client side code.


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