Bug #31073 UPPER() does not work on MD5() function when Inserting
Submitted: 18 Sep 2007 2:56 Modified: 18 Sep 2007 4:32
Reporter: Matt Wegrzyn Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.0.45-community-nt OS:Windows (Windows XP)
Assigned to: CPU Architecture:Any

[18 Sep 2007 2:56] Matt Wegrzyn
Description:
When using the UPPER() function on the MD5() function when inserting data, the data will still be inserted as lowercase.

Although, it will uppercase the data when doing an update after an insert.

How to repeat:
CREATE table md5test
(
password char(32) not null default ''
) engine=myisam;

INSERT INTO md5test
VALUES (UPPER(MD5('test'));

The inserted hash is still lowercase after executing this query. Running an UPDATE with UPPER works, but not when doing the above insert.
[18 Sep 2007 4:32] Valeriy Kravchuk
Thank you for a problem report. I was ableto repeat the behaviour described, but it is not a bug, it seems. Please, read the manual, http://dev.mysql.com/doc/refman/5.0/en/encryption-functions.html#function_md5:

"- MD5(str)

Calculates an MD5 128-bit checksum for the string. The value is returned as a binary string of 32 hex digits, or NULL if the argument was NULL. The return value can, for example, be used as a hash key.

...

If you want to convert the value to uppercase, see the description of binary string conversion given in the entry for the BINARY operator in Section 11.9, “Cast Functions and Operators”."