Can someone please explain this misbehavior?
Posted by: A B
Date: August 19, 2014 07:53PM

SET `collation_connection` = 'utf8_bin';
SET @wrong = CONVERT(CAST(0xD187D0B5D180D0BDD18BD0B9 AS CHAR) USING 'cp1251') COLLATE 'cp1251_general_ci';
SET @right = CONVERT(CAST(0xD187D191D180D0BDD18BD0B9 AS CHAR) USING 'cp1251') COLLATE 'cp1251_general_ci';
SELECT @wrong AS `wrong`, @right AS `right`,
IF(@wrong = @right, 'Bogus comparison', 'Right is right') AS `equality`;


versus

SET `collation_connection` = 'utf8_bin';
SET @wrong = CONVERT(CAST(0xD187D0B5D180D0BDD18BD0B9 AS CHAR) USING 'utf8') COLLATE 'utf8_general_ci';
SET @right = CONVERT(CAST(0xD187D191D180D0BDD18BD0B9 AS CHAR) USING 'utf8') COLLATE 'utf8_general_ci';
SELECT @wrong AS `wrong`, @right AS `right`,
IF(@wrong = @right, 'Bogus comparison', 'Right is right') AS `equality`,
@@collation_connection AS `collation`;

SET `collation_connection` = 'utf8_bin';
SET @wrong = CONVERT(CAST(0xD187D0B5D180D0BDD18BD0B9 AS CHAR) USING 'utf8') COLLATE 'utf8_unicode_ci';
SET @right = CONVERT(CAST(0xD187D191D180D0BDD18BD0B9 AS CHAR) USING 'utf8') COLLATE 'utf8_unicode_ci';
SELECT @wrong AS `wrong`, @right AS `right`,
IF(@wrong = @right, 'Bogus comparison', 'Right is right') AS `equality`,
@@collation_connection AS `collation`;

Options: ReplyQuote


Subject
Views
Written By
Posted
Can someone please explain this misbehavior?
3015
A B
August 19, 2014 07:53PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.