[MDEV-20604] Duplicate key value is silently truncated to 64 characters in print_keydup_error Created: 2019-09-16 Updated: 2022-03-22 Resolved: 2020-04-01 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | OTHER |
| Affects Version/s: | 10.2.27, 10.3.18, 10.4.8 |
| Fix Version/s: | 10.2.32, 10.3.23, 10.4.13 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Geoff Montee (Inactive) | Assignee: | Oleksandr Byelkin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | beginner-friendly | ||
| Issue Links: |
|
||||||||||||||||||||||||
| 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. |
| Comments |
| Comment by Sergei Golubchik [ 2019-09-17 ] | |||||||
|
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). | |||||||
| Comment by Oleksandr Byelkin [ 2020-02-25 ] | |||||||
|
I found that we have plugin for my_snprintf, so theoretically it can be done with a plugin | |||||||
| Comment by Oleksandr Byelkin [ 2020-03-16 ] | |||||||
|
ho big description and no so small test suite:
| |||||||
| Comment by Oleksandr Byelkin [ 2020-03-16 ] | |||||||
|
IMHO we need something shorter than "..." (triple dot), I propose ":". | |||||||
| Comment by Oleksandr Byelkin [ 2020-03-16 ] | |||||||
|
commit 42b77dd0549c8883a497e2385bf6c992222ecb02 (HEAD Added indication of truncated string with special width/precission suffix ':'. | |||||||
| Comment by Oleksandr Byelkin [ 2020-03-20 ] | |||||||
|
commit 17449c44a5443934909ff38c547e5e6db06b9660 (HEAD -> bb-10.2-release) Added indication of truncated string for "s" format | |||||||
| Comment by Oleksandr Byelkin [ 2020-03-24 ] | |||||||
|
commit fc90a39426c1756c204b5b3ff2f580a2f4224571 (HEAD Added indication of truncated string for "s" and "M" formats |