0

I'm trying to investigate an issue with a query I'm currently debugging.

The error I get from my client code is the following:

Duplicate entry '\x9F\x98\x9Ern\x06\x8BN\x97\x8D\xB5A\xB5e\x12\xC9-\x9C\xE1\x1Ai\' for key 'PRIMARY'.

How do I convert this binary string value to its original value so I can find out which part of my SQL query it belongs to? My goal would be to take this string and be able to convert it back to its binary(16) equivalent.

I found this MySQL documentation that explains briefly how the conversion works, but I'm not sure how to proceed in SQL.

  • I see no likely CHARACTER SET encoding that makes sense. I see no file magic starting with 9F98. Hence it should not be any 'compression'. Give us some more clues. – Rick James Feb 9 at 3:47
1

That error indicates that you are inserting a value in a column that is expected to be unique. The error translates any values in the range 0x20 to 0x7E into their easier-to-read form, and uses an \x prefix for others. So the value you are inserting probably looks like this:

0x9F989E726E068B4E978DB541B56512C92D9CE11A695C

(I got that by keeping any pair of values appearing immediately after an \x, and converting any other values (r, n, N, A, e, -, i, and \) to their ASCII hex values. I assume the \ is a literal, but I would have expected it to be escaped.)

  • Thanks to your explanation! I managed to get a bit further. What I discovered is there is two keys in that error log. The two are splitted by the '-' char. In my case, the primary key is a composite key. The first key is "\x9F\x98\x9Ern\x06\x8BN\x97\x8D\xB5A\xB5e\x12\xC9" and the other one is "\x9C\xE1\x1Ai\". However, in my schema, there is nothing that relates to the 2nd one. I suspect it got truncated before going to my application logs. – Pascal Paradis Feb 11 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.