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

Add Type_handler::KEY_pack_flags()

    XMLWordPrintable

Details

    Description

      This code in mysql_prepare_create_table() is not friendly to data type plugins:

             /* Use packed keys for long strings on the first column */
             if (!((*db_options) & HA_OPTION_NO_PACK_KEYS) &&
                 !((create_info->table_options & HA_OPTION_NO_PACK_KEYS)) &&
                 (key_part_length >= KEY_DEFAULT_PACK_LENGTH &&
                  (sql_field->real_field_type() == MYSQL_TYPE_STRING ||
                   sql_field->real_field_type() == MYSQL_TYPE_VARCHAR ||
                   f_is_blob(sql_field->pack_flag))) && !is_hash_field_needed)
             {
               if ((column_nr == 0 && f_is_blob(sql_field->pack_flag)) ||
                   sql_field->real_field_type() == MYSQL_TYPE_VARCHAR)
                 key_info->flags|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY;
               else
                 key_info->flags|= HA_PACK_KEY;
             }
      

      Let's add a new method in Type_handler:

      virtual ulong KEY_pack_flags(uint column_nr) const { return 0; }
      

      So the above code will change to:

             /* Use packed keys for long strings on the first column */
             if (!((*db_options) & HA_OPTION_NO_PACK_KEYS) &&
                 !((create_info->table_options & HA_OPTION_NO_PACK_KEYS)) &&
                 (key_part_length >= KEY_DEFAULT_PACK_LENGTH) &&
                 !is_hash_field_needed)
             {
               key_info->flags|= sql_field->type_handler()->KEY_pack_flags(column_nr);
             }
      

      Data type plugins will be able to override this method.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.