[MDEV-19345] Cleanup inconsistency in setting HA_(BLOB|VAR_LENGTH|BIT)_PART flags Created: 2019-04-26  Updated: 2019-09-23  Resolved: 2019-06-04

Status: Closed
Project: MariaDB Server
Component/s: Data types, Optimizer
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

 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)

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