Bug #20481 I_S.columns shows wrong output for character_maximum_length&character_octet_le
Submitted: 15 Jun 2006 13:31 Modified: 15 Jun 2006 19:36
Reporter: Sarah Sproehnle Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.20 OS:Windows (Windows XP)
Assigned to: CPU Architecture:Any

[15 Jun 2006 13:31] Sarah Sproehnle
Description:
The character_maximum_length and character_octet_length are not accurate for a variable-length character set.

How to repeat:
mysql> use test
Database changed
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.0.20-nt |
+-----------+
1 row in set (0.00 sec)
mysql> CREATE TABLE bug (a char(150) CHARACTER SET utf8);
Query OK, 0 rows affected (0.16 sec)

mysql> SELECT column_name, column_type, character_maximum_length, character_octet_length
    -> FROM information_schema.columns WHERE table_schema='test' AND table_name='bug';
+-------------+-------------+--------------------------+------------------------+
| column_name | column_type | character_maximum_length | character_octet_length |
+-------------+-------------+--------------------------+------------------------+
| a           | char(150)   | 50                       | 150                    |
+-------------+-------------+--------------------------+------------------------+
1 row in set (0.01 sec)
[15 Jun 2006 13:47] Valeriy Kravchuk
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

Please, read the manual (http://dev.mysql.com/doc/refman/5.0/en/columns-table.html):

"CHARACTER_OCTET_LENGTH should be the same as CHARACTER_MAXIMUM_LENGTH, except for multi-byte character sets."

UTF8 is muti-byte character set. Up to 3 bytes per character is used.
[15 Jun 2006 14:34] Sarah Sproehnle
I agree that the character_maximum_length should be less than the character_octet_length.  However, the column is a char(150), so I would expect these values to be 150 and 450 respectively.  Not 50 and 150.
[15 Jun 2006 19:36] Valeriy Kravchuk
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

mysql> create table bug (a char(5) character set utf8);
Query OK, 0 rows affected (0.02 sec)

mysql> show create table bug\G
*************************** 1. row ***************************
       Table: bug
Create Table: CREATE TABLE `bug` (
  `a` char(5) character set utf8 default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

mysql> SELECT column_name, column_type, character_maximum_length,
    -> character_octet_length
    -> FROM information_schema.columns WHERE table_schema='test' AND
    -> table_name='bug';
+-------------+-------------+--------------------------+------------------------+
| column_name | column_type | character_maximum_length | haracter_octet_length
|
+-------------+-------------+--------------------------+------------------------+
| a           | char(5)     |                        5 |                     15 |
+-------------+-------------+--------------------------+------------------------+
1 row in set (0.02 sec)

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.0.23    |
+-----------+
1 row in set (0.00 sec)

So, the bug was in 5.0.20, 5.0.22, but already fixed in 5.0.23.
[15 Jun 2006 19:39] Paul DuBois
This bug is probably a dup of  Bug#19236, which was
fixed in 5.0.23. (The bug report says 5.0.22, but the fix
actually went to 5.0.23.)