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

Cleanup inconsistency in setting HA_(BLOB|VAR_LENGTH|BIT)_PART flags

    XMLWordPrintable

Details

    Description

      There are three similar code pieces setting KEY_PART_INFO::key_part_flag, but there is a difference in every piece.

      We should check all three pieces for bugs and get rid of duplicate code, for example by introducing new virtual methods in Field, with approximately this prototype:

      uint key_part_flags() const;
      uint key_part_store_length(const KEY_PART_INFO &part) const;
      

      sql_select.cc: create_tmp_table()

            key_part_info->store_length= key_part_info->length;
            if ((*reg_field)->type() == MYSQL_TYPE_BLOB ||
                (*reg_field)->real_type() == MYSQL_TYPE_VARCHAR ||
                (*reg_field)->type() == MYSQL_TYPE_GEOMETRY)
            {
              if ((*reg_field)->type() == MYSQL_TYPE_BLOB ||
                  (*reg_field)->type() == MYSQL_TYPE_GEOMETRY)
                key_part_info->key_part_flag|= HA_BLOB_PART;
              else
                key_part_info->key_part_flag|= HA_VAR_LENGTH_PART;
       
              key_part_info->store_length+=HA_KEY_BLOB_LENGTH;
            }
            keyinfo->key_length+= key_part_info->store_length; 
      

      • Does not set HA_BIT_FLAG for the BIT data type
      • Sets HA_BLOB_PART for the GEOMETRY data type

      table.cc: TABLE_SHARE::init_from_binary_frm_image()

              if (field->type() == MYSQL_TYPE_BLOB ||
                  field->real_type() == MYSQL_TYPE_VARCHAR ||
                  field->type() == MYSQL_TYPE_GEOMETRY)
              {
                if (field->type() == MYSQL_TYPE_BLOB ||
                    field->type() == MYSQL_TYPE_GEOMETRY)
                  key_part->key_part_flag|= HA_BLOB_PART;
                else
                  key_part->key_part_flag|= HA_VAR_LENGTH_PART;
                key_part->store_length+=HA_KEY_BLOB_LENGTH;
                keyinfo->key_length+= HA_KEY_BLOB_LENGTH;
              }
              if (field->type() == MYSQL_TYPE_BIT)
                key_part->key_part_flag|= HA_BIT_PART;
      

      • Sets HA_BIT_FLAG for the BIT data type
      • Sets HA_BLOB_PART for the GEOMETRY data type

      table.cc: TABLE::create_key_part_by_field()

        if (field->type() == MYSQL_TYPE_BLOB || 
            field->type() == MYSQL_TYPE_GEOMETRY ||
        {
            field->real_type() == MYSQL_TYPE_VARCHAR)
          key_part_info->store_length+= HA_KEY_BLOB_LENGTH;
          key_part_info->key_part_flag|=
            field->type() == MYSQL_TYPE_BLOB ? HA_BLOB_PART: HA_VAR_LENGTH_PART;
        }
      

      • Does not set HA_BIT_FLAG for the BIT data type
      • Sets HA_VAR_LENGTH_PART for the GEOMETRY data type (the previous two pieces set HA_BLOB_PART for GEOMETRY)

      Attachments

        Issue Links

          Activity

            People

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