Bug #29581 documentation of literal charset: _cset '...'
Submitted: 5 Jul 2007 18:45 Modified: 1 Aug 2007 16:34
Reporter: Martin Friebe (Gold Quality Contributor) (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.1.20 5.0.44 OS:Any
Assigned to: Paul DuBois CPU Architecture:Any
Tags: charset, doc

[5 Jul 2007 18:45] Martin Friebe
Description:
From http://dev.mysql.com/doc/refman/5.1/en/charset-literal.html
> The _charset_name  expression is formally called an introducer. It tells the 
.......
> we emphasize that an introducer does not cause any conversion;
> it is strictly a signal that does not change the string's value. 

"does not change the strings value"

This is not true, if the string has a length which can not be matched by the charset.

select hex( _ucs2 "1" );
+------------------+
| hex( _ucs2 "1" ) |
+------------------+
| 0031             |
+------------------+

As you can see the string has been changed. It is now 2 bytes long. same with:
 select hex( _ucs2 0x31 );

But with 2 (or  any even amount of bytes) it is fine
 select hex( _ucs2 "12" );
+-------------------+
| hex( _ucs2 "12" ) |
+-------------------+
| 3132              |
+-------------------+

----
utf8 seems not affected the same way

C2 is not a full utf8 char (it is the first of a 2 byte code)
select hex( _utf8 0xC2);
+------------------+
| hex( _utf8 0xC2) |
+------------------+
| C2               |
+------------------+

yet it is unchanged as documented

How to repeat:

set names latin1;
set character_set_connection = latin1;

select hex( _ucs2 "1" );
select hex( _ucs2 "12" );
select hex( _ucs2 "123" );
select hex( _ucs2 "231" );
select hex( _ucs2 "abc" );
select hex( _ucs2 "1234" );
select hex( _ucs2 "12345" );

Suggested fix:
-
[5 Jul 2007 21:04] MySQL Verification Team
Thank you for the bug report.
[1 Aug 2007 16:34] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

Amended manual to state that the introducer does not change the value, except that padding may occur.