DECODE works not properly on 9.4.0.5145

[expired user #10466]'s profile image [expired user #10466] posted 7 years ago in Running SQL scripts Permalink

Short test:

SET @TEST = ENCODE('test', 'mykey$'); SELECT @TEST; SELECT DECODE(@TEST, 'mykey$');

Outputs: 0xA0227630 0x74657374

So, second one must be actually a 'test' string again, but its returns 0x74657374 (?)

The same code on MySQL server works properly.

Is a bug or i doing something wrong?

kalvaro's profile image kalvaro posted 7 years ago Permalink

HeidiSQL is a MySQL client, it doesn't run SQL functions by itself, it only displays what the server sends back.

Stuff that starts with 0x is an hexadecimal number. In this case, if you look carefully, you'll realise it's the UTF-8 encoding of the text "test". To see binary output as text you can click on the "View binary data as text (instead of HEX)" toolbar button.

[expired user #10466]'s profile image [expired user #10466] posted 7 years ago Permalink

Hello kalvaro, thanks a lot for explanation! :)

Stuff that starts with 0x is an hexadecimal number. In this case, if you look carefully, you'll realise it's the UTF-8 encoding of the text "test". To see binary output as text you can click on the "View binary data as text (instead of HEX)" toolbar button.

Please login to leave a reply, or register at first.