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

Generalize can_convert_xxx() hook engine API to cover any arbitrary data type

    XMLWordPrintable

Details

    Description

      The engine API have hooks to let the engine decide if it can perform ALGORITHM=NOCOPY for a minor data type change.
      Originally they were implemented to handle ALTER changing a column character set from CHARACTER SET utf8mb3 to CHARACTER SET utf8mb4 without having to rebuild the table:

      CREATE TABLE t1 (a TEXT CHARACTER SET utf8mb3) ENGINE=InnoDB;
      INSERT INTO t1 VALUES ('test');
      ALTER TABLE t1 MODIFY a TEXT CHARACTER SET utf8mb4;
      

      The above ALTER does not rebuild the table, it only modifies the FRM file.

      The hooks that we have so far can handle only string data types. They are implemented in these "class handler" methods, overridden by ha_innodb:

        virtual bool can_convert_string(const Field_string *field,
                                        const Column_definition &new_type) const
        {
          return false;
        }
        virtual bool can_convert_varstring(const Field_varstring *field,
                                           const Column_definition &new_type) const
        {
          return false;
        }
        virtual bool can_convert_blob(const Field_blob *field,
                                      const Column_definition &new_type) const
        {
          return false;
        }
      

      In order to fix MDEV-29481, we may need a hook for the DOUBLE data type.
      It's not desirable to add a new "can_convert_double()" method.

      Let's remove the above three virtual methods and add one method which can handle any arbitrary data type:

        virtual bool can_convert_nocopy(const Field &,
                                        const Column_definition &) const
        {
          return false;
        }
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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