Bug #36593 Missing charsetnr documentation
Submitted: 8 May 2008 12:44 Modified: 9 May 2008 19:04
Reporter: Carsten Pedersen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: Paul DuBois CPU Architecture:Any

[8 May 2008 12:44] Carsten Pedersen
Description:
http://bugs.mysql.com/bug.php?id=19814 requested that documentation on charsetnr values be documented somewhere. Apparently it was at the time, but the information seems to have gone missing again.

How to repeat:
Google "mysql" and "charsetnr" ;-)

Suggested fix:
Reinstate the documentation that was supposedly available.
[8 May 2008 14:48] Valeriy Kravchuk
Looks like the information you need is presented at http://forge.mysql.com/wiki/MySQL_Internals_Algorithms#Character.2FCollation_Sets now. 

I do not see this URL at the frist page of Google search results for mysql and charsetnr, but I am not sure if this can be considered a bug in MySQL documentation...
[8 May 2008 19:04] Carsten Pedersen
Thanks for the pointer.

It's a "bug" in that the information is impossible to find. charsetnr is present in the API documentation, but without some way of attaching meaning to the returned value, that information is less than useful. And in our case we did need that information.

Thanks again for the updated link.
[9 May 2008 19:04] 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.

Updated http://dev.mysql.com/doc/refman/5.0/en/c-api-datatypes.html to say:

An ID number that indicates the character set/collation pair for the
field.    

To distinguish between binary and non-binary data for string data
types, check whether the charsetnr value is 63. If so, the character
set is binary, which indicates binary rather than non-binary data.
This enables you to distinguish BINARY from CHAR, VARBINARY from
VARCHAR, and the BLOB types from the TEXT types.

charsetnr values are the same as those displayed in the Id column of
the SHOW COLLATION statement or the ID column of the
INFORMATION_SCHEMA COLLATIONS table. You can use those information
sources to see which character set and collation specific charsetnr
values indicate: 

mysql> SHOW COLLATION WHERE Id = 63; 
+-----------+---------+----+---------+----------+---------+
| Collation | Charset | Id | Default | Compiled | Sortlen |
+-----------+---------+----+---------+----------+---------+
| binary    | binary  | 63 | Yes     | Yes      |       1 |
+-----------+---------+----+---------+----------+---------+

mysql> SELECT COLLATION_NAME, CHARACTER_SET_NAME 
    -> FROM INFORMATION_SCHEMA.COLLATIONS WHERE ID = 33;
+-----------------+--------------------+
| COLLATION_NAME  | CHARACTER_SET_NAME |
+-----------------+--------------------+
| utf8_general_ci | utf8               |
+-----------------+--------------------+