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

update case insensitive (large) unique key with insensitive change of value - duplicate key

Details

    Description

      create table x (id int auto_increment primary key, name varchar(2048) collate utf8_general_ci, unique key u(name));
      insert into x values (1,'test');
      update x set name = "Test" where id=1
       
      Duplicate entry 'Test' for key 'u
      

      A smaller varchar length ~200 will not generate an error.

      Suspected MDEV-371 regression.

      source: https://www.reddit.com/r/mariadb/comments/wu83pe/change_case_with_unique_constraint/

      Attachments

        Issue Links

          Activity

            Here is a little simpler test case, not involving InnoDB at all:

            create table t1 (name varchar(2048) collate utf8_general_ci, unique key u(name));
            insert t1 set name='test';
            update t1 set name='Test';
            drop table t1;
            

            I disabled MDEV-371 with the following:

            diff --git a/sql/sql_table.cc b/sql/sql_table.cc
            index 6e8a4795f21..f8f3eefc114 100644
            --- a/sql/sql_table.cc
            +++ b/sql/sql_table.cc
            @@ -2441,6 +2441,8 @@ static inline void make_long_hash_field_name(LEX_CSTRING *buf, uint num)
             static Create_field * add_hash_field(THD * thd, List<Create_field> *create_list,
                                                   KEY *key_info)
             {
            +  my_error(ER_TOO_LONG_KEY, MYF(0), 1000);
            +  return nullptr;
               List_iterator<Create_field> it(*create_list);
               Create_field *dup_field, *cf= new (thd->mem_root) Create_field();
               cf->flags|= UNSIGNED_FLAG | LONG_UNIQUE_HASH_FIELD;
            

            With MDEV-371 disabled, the error ER_TOO_LONG_KEY would be output for anything longer than varchar(333). For shorter values, no duplicate key error will be flagged.

            marko Marko Mäkelä added a comment - Here is a little simpler test case, not involving InnoDB at all: create table t1 ( name varchar (2048) collate utf8_general_ci, unique key u( name )); insert t1 set name = 'test' ; update t1 set name = 'Test' ; drop table t1; I disabled MDEV-371 with the following: diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 6e8a4795f21..f8f3eefc114 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2441,6 +2441,8 @@ static inline void make_long_hash_field_name(LEX_CSTRING *buf, uint num) static Create_field * add_hash_field(THD * thd, List<Create_field> *create_list, KEY *key_info) { + my_error(ER_TOO_LONG_KEY, MYF(0), 1000); + return nullptr; List_iterator<Create_field> it(*create_list); Create_field *dup_field, *cf= new (thd->mem_root) Create_field(); cf->flags|= UNSIGNED_FLAG | LONG_UNIQUE_HASH_FIELD; With MDEV-371 disabled, the error ER_TOO_LONG_KEY would be output for anything longer than varchar(333) . For shorter values, no duplicate key error will be flagged.

            People

              serg Sergei Golubchik
              danblack Daniel Black
              Votes:
              2 Vote for this issue
              Watchers:
              7 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.