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

            danblack Daniel Black created issue -
            danblack Daniel Black made changes -
            Field Original Value New Value
            Summary update case insensitive unique key with insensitive change of value - duplicate key update case insensitive (large) unique key with insensitive change of value - duplicate key

            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.
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            Component/s Server [ 13907 ]
            Component/s Storage Engine - InnoDB [ 10129 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.7 [ 24805 ]
            Fix Version/s 10.8 [ 26121 ]
            Fix Version/s 10.9 [ 26905 ]
            Fix Version/s 10.10 [ 27530 ]
            Assignee Marko Mäkelä [ marko ] Oleksandr Byelkin [ sanja ]
            Labels not-10.3 not-10.3 regression-10.4
            Priority Major [ 3 ] Critical [ 2 ]
            marko Marko Mäkelä made changes -
            Status Open [ 1 ] Confirmed [ 10101 ]
            danblack Daniel Black made changes -
            serg Sergei Golubchik made changes -
            Labels not-10.3 regression-10.4 not-10.3
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s 10.7 [ 24805 ]
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s 10.8 [ 26121 ]
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s 10.9 [ 26905 ]
            Fix Version/s 10.10 [ 27530 ]
            danblack Daniel Black made changes -
            serg Sergei Golubchik made changes -
            Assignee Oleksandr Byelkin [ sanja ] Sergei Golubchik [ serg ]
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            Status Confirmed [ 10101 ] In Progress [ 3 ]
            serg Sergei Golubchik made changes -
            Status In Progress [ 3 ] In Testing [ 10301 ]
            serg Sergei Golubchik made changes -
            issue.field.resolutiondate 2024-05-05 20:36:09.0 2024-05-05 20:36:08.942
            serg Sergei Golubchik made changes -
            Fix Version/s 10.5.25 [ 29626 ]
            Fix Version/s 10.6.18 [ 29627 ]
            Fix Version/s 10.11.8 [ 29630 ]
            Fix Version/s 11.0.6 [ 29628 ]
            Fix Version/s 11.1.5 [ 29629 ]
            Fix Version/s 11.2.4 [ 29631 ]
            Fix Version/s 11.4.2 [ 29633 ]
            Fix Version/s 10.4 [ 22408 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Resolution Fixed [ 1 ]
            Status In Testing [ 10301 ] Closed [ 6 ]

            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.