Bug #6815 SHOW CREATE TABLE hangs after upgrading to 4.1
Submitted: 24 Nov 2004 22:58 Modified: 2 Dec 2004 7:43
Reporter: Hartmut Holzgraefe Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.x OS:Linux (linux)
Assigned to: Alexander Barkov CPU Architecture:Any

[24 Nov 2004 22:58] Hartmut Holzgraefe
Description:
Tables created in 4.0 or older versions that have non-ASCII characters
in column names cause the server to run into an endless loop on
SHOW CREATE TABLE

While the documentation clearly says that tables with non-ASCII characters in table or column names are not supposed to be portable between versions 
< 4.1 and >= 4.1 i still consider it a bug if a table from an older version
leads to a connection thread being trapped in an endless loop consuming
all available CPU cycles 

How to repeat:
on 4.0.x do a 

  CREATE test (fübar int);

upgrade to 4.1.x or move the fübar.* files 
over to an existing 4.1.x installation and try

  SHOW CREATE TABLE test;

Suggested fix:
The actual problem is located in sql/sql_show.cc, function append_identifier() and string/ctype-utf8.c, function my_mbcharlen_utf8()

append_identifier() loops over a column name using my_mbcharlen_utf8()
through the macro my_mbcharlen() to step over the name character by character.

my_mbcharlen_utf8() returns 0 on unknown characters or sequences,
this leads to the length variable never being changed and the same 
character tested over and over again on non-UTF8 characters like a
Latin-1 'ü'

maybe 

  if (!length) length = 1;

should be added in append_identifier() right after the call to
my_mbcharlen()?
[27 Nov 2004 17:52] Hartmut Holzgraefe
Having some kind of test script that checks an existing 4.0 setup 
for possible non-portable names before upgrading for 4.1 might
be nice, too
[2 Dec 2004 7:43] Alexander Barkov
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:

fixed in 4.1.8