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

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

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

            bar Alexander Barkov created issue -
            bar Alexander Barkov made changes -
            Field Original Value New Value
            Rank Ranked higher
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            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 these virtual methods in {{Field}}, with approximately this prototype:

            {code:cpp}
            uint key_part_flags() const;
            uint key_part_store_length(const KEY_PART_INFO *part) const;
            {code}



            h3. sql_select.cc: create_tmp_table()

            {code:cpp}
                  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;
            {code}

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


            h3. table.cc: TABLE_SHARE::init_from_binary_frm_image()

            {code:cpp}
                    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;
            {code}

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


            h3. table.cc: TABLE::create_key_part_by_field()

            {code:cpp}
              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;
              }
            {code}

            - 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)
            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:

            {code:cpp}
            uint key_part_flags() const;
            uint key_part_store_length(const KEY_PART_INFO *part) const;
            {code}



            h3. sql_select.cc: create_tmp_table()

            {code:cpp}
                  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;
            {code}

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


            h3. table.cc: TABLE_SHARE::init_from_binary_frm_image()

            {code:cpp}
                    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;
            {code}

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


            h3. table.cc: TABLE::create_key_part_by_field()

            {code:cpp}
              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;
              }
            {code}

            - 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)
            bar Alexander Barkov made changes -
            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:

            {code:cpp}
            uint key_part_flags() const;
            uint key_part_store_length(const KEY_PART_INFO *part) const;
            {code}



            h3. sql_select.cc: create_tmp_table()

            {code:cpp}
                  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;
            {code}

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


            h3. table.cc: TABLE_SHARE::init_from_binary_frm_image()

            {code:cpp}
                    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;
            {code}

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


            h3. table.cc: TABLE::create_key_part_by_field()

            {code:cpp}
              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;
              }
            {code}

            - 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)
            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:

            {code:cpp}
            uint key_part_flags() const;
            uint key_part_store_length(const KEY_PART_INFO &part) const;
            {code}



            h3. sql_select.cc: create_tmp_table()

            {code:cpp}
                  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;
            {code}

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


            h3. table.cc: TABLE_SHARE::init_from_binary_frm_image()

            {code:cpp}
                    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;
            {code}

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


            h3. table.cc: TABLE::create_key_part_by_field()

            {code:cpp}
              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;
              }
            {code}

            - 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)
            bar Alexander Barkov made changes -
            Assignee Varun Gupta [ varun ] Alexander Barkov [ bar ]
            bar Alexander Barkov made changes -
            issue.field.resolutiondate 2019-06-04 06:57:26.0 2019-06-04 06:57:26.777
            bar Alexander Barkov made changes -
            Fix Version/s 10.5.0 [ 23709 ]
            Fix Version/s 10.4 [ 22408 ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]
            varun Varun Gupta (Inactive) made changes -
            Assignee Alexander Barkov [ bar ] Varun Gupta [ varun ]
            varun Varun Gupta (Inactive) made changes -
            Assignee Varun Gupta [ varun ] Alexander Barkov [ bar ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 96380 ] MariaDB v4 [ 133942 ]

            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.