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

Duplicate key value is silently truncated to 64 characters in print_keydup_error

Details

    Description

      When a duplicate key is encountered, the error message is constructed in print_keydup_error:

      https://github.com/MariaDB/server/blob/mariadb-10.2.27/sql/handler.cc#L3450

      The duplicate value is silently truncated to 64 characters. This is because the format string for the error message sets the field width to 64:

      https://github.com/MariaDB/server/blob/mariadb-10.2.27/sql/share/errmsg-utf8.txt#L6166

      Truncation is probably fine, but since this specific error involves a "duplicate key", it can be a bit confusing if the user searches the table for that string, and then doesn't find another row with that specific value.

      If we can't print the whole value, then the error message may want to mention that the string may be truncated to 64 characters.

      Attachments

        Issue Links

          Activity

            GeoffMontee Geoff Montee (Inactive) created issue -
            GeoffMontee Geoff Montee (Inactive) made changes -
            Field Original Value New Value
            serg Sergei Golubchik made changes -
            Priority Major [ 3 ] Minor [ 4 ]

            We can fix my_vsprintf to print (optionally) some truncation hint, like "..." if the value was truncated. E.g. "%-.64...s" meaning it'll print "..."

            Or we can rephrase the error message to be something like "Duplicate value for the key %$2-.128s: '%$1s'" — this way it'll allow few hundreds bytes for the key value, up to the max error message length of (iirc) 512. But might have compatibility implications if some tool looks for the exact error message text (that no sane tool should do).

            serg Sergei Golubchik added a comment - We can fix my_vsprintf to print (optionally) some truncation hint, like "..." if the value was truncated. E.g. "%-.64...s" meaning it'll print "..." Or we can rephrase the error message to be something like "Duplicate value for the key %$2-.128s: '%$1s'" — this way it'll allow few hundreds bytes for the key value, up to the max error message length of (iirc) 512. But might have compatibility implications if some tool looks for the exact error message text (that no sane tool should do).
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ]
            serg Sergei Golubchik made changes -
            Labels beginner-friendly
            GeoffMontee Geoff Montee (Inactive) made changes -
            julien.fritsch Julien Fritsch made changes -
            Priority Minor [ 4 ] Major [ 3 ]
            serg Sergei Golubchik made changes -
            Assignee Oleksandr Byelkin [ sanja ]
            julien.fritsch Julien Fritsch made changes -
            Priority Major [ 3 ] Critical [ 2 ]
            sanja Oleksandr Byelkin made changes -
            Status Open [ 1 ] In Progress [ 3 ]

            I found that we have plugin for my_snprintf, so theoretically it can be done with a plugin

            sanja Oleksandr Byelkin added a comment - I found that we have plugin for my_snprintf, so theoretically it can be done with a plugin
            sanja Oleksandr Byelkin made changes -
            Status In Progress [ 3 ] Stalled [ 10000 ]
            sanja Oleksandr Byelkin made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]

            ho big description and no so small test suite:

            create table t1 (a varchar(100), UNIQUE KEY akey (a));
             
            insert into t1 values ("1234567890123456789012345678901234567890123456789012345678901234567890_end");
            --error ER_DUP_ENTRY
            insert into t1 values ("1234567890123456789012345678901234567890123456789012345678901234567890_end");
             
            drop table t1;
            

            sanja Oleksandr Byelkin added a comment - ho big description and no so small test suite: create table t1 (a varchar(100), UNIQUE KEY akey (a));   insert into t1 values ("1234567890123456789012345678901234567890123456789012345678901234567890_end"); --error ER_DUP_ENTRY insert into t1 values ("1234567890123456789012345678901234567890123456789012345678901234567890_end");   drop table t1;

            IMHO we need something shorter than "..." (triple dot), I propose ":".

            sanja Oleksandr Byelkin added a comment - IMHO we need something shorter than "..." (triple dot), I propose ":".

            commit 42b77dd0549c8883a497e2385bf6c992222ecb02 (HEAD > bb-10.2MDEV-20604, origin/bb-10.2-MDEV-20604)
            Author: Oleksandr Byelkin <sanja@mariadb.com>
            Date: Mon Mar 16 16:53:10 2020 +0100

            MDEV-20604: Duplicate key value is silently truncated to 64 characters in print_keydup_error

            Added indication of truncated string with special width/precission suffix ':'.

            sanja Oleksandr Byelkin added a comment - commit 42b77dd0549c8883a497e2385bf6c992222ecb02 (HEAD > bb-10.2 MDEV-20604 , origin/bb-10.2- MDEV-20604 ) Author: Oleksandr Byelkin <sanja@mariadb.com> Date: Mon Mar 16 16:53:10 2020 +0100 MDEV-20604 : Duplicate key value is silently truncated to 64 characters in print_keydup_error Added indication of truncated string with special width/precission suffix ':'.
            sanja Oleksandr Byelkin made changes -
            Comment [ commit 11363b44d58ababaef89524d3caca368d04e589a (HEAD -> bb-10.2-release, origin/bb-10.2-release)
            Author: Oleksandr Byelkin <sanja@mariadb.com>
            Date: Mon Mar 16 16:53:10 2020 +0100

                MDEV-20604: Duplicate key value is silently truncated to 64 characters in print_keydup_error
                
                Added indication of truncated string with special width/precission suffix ':'.

            ]

            commit 17449c44a5443934909ff38c547e5e6db06b9660 (HEAD -> bb-10.2-release)
            Author: Oleksandr Byelkin <sanja@mariadb.com>
            Date: Mon Mar 16 16:53:10 2020 +0100

            MDEV-20604: Duplicate key value is silently truncated to 64 characters in print_keydup_error

            Added indication of truncated string for "s" format

            sanja Oleksandr Byelkin added a comment - commit 17449c44a5443934909ff38c547e5e6db06b9660 (HEAD -> bb-10.2-release) Author: Oleksandr Byelkin <sanja@mariadb.com> Date: Mon Mar 16 16:53:10 2020 +0100 MDEV-20604 : Duplicate key value is silently truncated to 64 characters in print_keydup_error Added indication of truncated string for "s" format
            sanja Oleksandr Byelkin made changes -
            Assignee Oleksandr Byelkin [ sanja ] Sergei Golubchik [ serg ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            sanja Oleksandr Byelkin made changes -
            Assignee Sergei Golubchik [ serg ] Oleksandr Byelkin [ sanja ]
            sanja Oleksandr Byelkin made changes -
            Status In Review [ 10002 ] Stalled [ 10000 ]
            sanja Oleksandr Byelkin made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]
            sanja Oleksandr Byelkin made changes -
            Assignee Oleksandr Byelkin [ sanja ] Sergei Golubchik [ serg ]
            Status In Progress [ 3 ] In Review [ 10002 ]

            commit fc90a39426c1756c204b5b3ff2f580a2f4224571 (HEAD > bb-10.2MDEV-20604, origin/bb-10.2-release, origin/bb-10.2-MDEV-20604, bb-10.2-release)
            Author: Oleksandr Byelkin <sanja@mariadb.com>
            Date: Mon Mar 16 16:53:10 2020 +0100

            MDEV-20604: Duplicate key value is silently truncated to 64 characters in print_keydup_error

            Added indication of truncated string for "s" and "M" formats

            sanja Oleksandr Byelkin added a comment - commit fc90a39426c1756c204b5b3ff2f580a2f4224571 (HEAD > bb-10.2 MDEV-20604 , origin/bb-10.2-release, origin/bb-10.2- MDEV-20604 , bb-10.2-release) Author: Oleksandr Byelkin <sanja@mariadb.com> Date: Mon Mar 16 16:53:10 2020 +0100 MDEV-20604 : Duplicate key value is silently truncated to 64 characters in print_keydup_error Added indication of truncated string for "s" and "M" formats
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Oleksandr Byelkin [ sanja ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            sanja Oleksandr Byelkin made changes -
            Component/s OTHER [ 10125 ]
            Fix Version/s 10.2.32 [ 24221 ]
            Fix Version/s 10.3.23 [ 24222 ]
            Fix Version/s 10.4.13 [ 24223 ]
            Fix Version/s 10.2 [ 14601 ]
            Fix Version/s 10.3 [ 22126 ]
            Fix Version/s 10.4 [ 22408 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            rob.schwyzer@mariadb.com Rob Schwyzer (Inactive) made changes -
            Labels beginner-friendly ServiceNow beginner-friendly
            rob.schwyzer@mariadb.com Rob Schwyzer (Inactive) made changes -
            Labels ServiceNow beginner-friendly 76qDvLB8Gju6Hs7nk3VY3EX42G795W5z beginner-friendly
            serg Sergei Golubchik made changes -
            Labels 76qDvLB8Gju6Hs7nk3VY3EX42G795W5z beginner-friendly beginner-friendly
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 99692 ] MariaDB v4 [ 156753 ]
            mariadb-jira-automation Jira Automation (IT) made changes -
            Zendesk Related Tickets 201658 136328
            Zendesk active tickets 201658

            People

              sanja Oleksandr Byelkin
              GeoffMontee Geoff Montee (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              6 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.