Bug #59243 Character set 'latin1' is not a compiled character set and is not specified
Submitted: 31 Dec 2010 14:43 Modified: 9 Jan 2011 13:04
Reporter: Richard Secor Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:Ver 14.14 Distrib 5.5.8 OS:FreeBSD (8.1-RELEASE)
Assigned to: CPU Architecture:Any
Tags: character set, dbd, dbi, hangs, Latin1, perl, php

[31 Dec 2010 14:43] Richard Secor
Description:
Under perl:
Failure on connection and exits script.

Under php:
Failure on connection and script just hangs.

This issue seems to be the same as those having problems with ODBC connectors, etc that I've seen in other bugs. However, they do not go on to specifically find the issue and ultimately correct it.

It also appears that this bug has found it's way into the code on and off for years. It must be something simple somewhere that anyone coding anything in MySQL must be made aware of, once found, so that it does not show up again, after it's fixed, in the future.

How to repeat:
On FreeBSD 8.1-RELEASE install the following ports:

For Perl:
lang/perl5.12
databases/mysql55-client
databases/mysql55-server
www/apache22
databases/p5-DBI
databases/p5-DBD-mysql55

For php:
lang/perl5.12
databases/mysql55-client
databases/mysql55-server
lang/php5
databases/php5-mysql
 WITH_MYSQLND=false
databases/php5-mysqli
 WITH_MYSQLND=false

Suggested fix:
Perl uses the libraries for the currently installed copy of MySQL.
PHP uses the libraries for the currently installed copy of MySQL where WITH_MYSQLDN=false.

This leads me to believe it is something in MySQL itself.

Temporary fix for PHP is to compile the PHP library with WITH_MYSQLDN=true so that it uses the PHP embedded libraries for talking with MySQL. While this is not desired it does work.
[31 Dec 2010 18:14] Sveta Smirnova
Thank you for the report.

Looks like your application can not locate character-sets-dir. Please send us full error message you got.
[31 Dec 2010 18:32] Richard Secor
As per request here is the full output from...

perl: (exits to command-line after messages)
# ./test-mysql-lib.pl 
Character set 'latin1' is not a compiled character set and is not specified in the '/usr/local/share/mysql/charsets/Index.xml' file
DBI connect('database=mysql;host=localhost','root',...) failed: Can't initialize character set latin1 (path: /usr/local/share/mysql/charsets/) at ./test-mysql-lib.pl line 7
#

php: (does not exit to command=line after messages, just hangs)
# ./test-mysql-lib.php 
Character set 'latin1' is not a compiled character set and is not specified in the '/usr/local/share/mysql/charsets/Index.xml' file

In fact even just doing the following will cause it not to exist and just hang...
# php -v
PHP 5.3.4 with Suhosin-Patch (cli) (built: Dec 30 2010 09:12:14) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

==========================================
Additionally:

# ls -la /usr/local/share/mysql/charsets/         
total 396
drwxr-xr-x   2 root  wheel   1024 Dec 28 09:30 .
drwxr-xr-x  26 root  wheel   1024 Dec 28 09:30 ..
-rw-r--r--   1 root  wheel  18261 Dec  3 12:58 Index.xml
-rw-r--r--   1 root  wheel   1749 Dec  3 12:58 README
-rw-r--r--   1 root  wheel   5480 Dec  3 12:58 armscii8.xml
-rw-r--r--   1 root  wheel   5466 Dec  3 12:58 ascii.xml
-rw-r--r--   1 root  wheel   8195 Dec  3 12:58 cp1250.xml
-rw-r--r--   1 root  wheel   8316 Dec  3 12:58 cp1251.xml
-rw-r--r--   1 root  wheel   5529 Dec  3 12:58 cp1256.xml
-rw-r--r--   1 root  wheel   8862 Dec  3 12:58 cp1257.xml
-rw-r--r--   1 root  wheel   5466 Dec  3 12:58 cp850.xml
-rw-r--r--   1 root  wheel   5482 Dec  3 12:58 cp852.xml
-rw-r--r--   1 root  wheel   5573 Dec  3 12:58 cp866.xml
-rw-r--r--   1 root  wheel   6489 Dec  3 12:58 dec8.xml
-rw-r--r--   1 root  wheel   5476 Dec  3 12:58 geostd8.xml
-rw-r--r--   1 root  wheel   5688 Dec  3 12:58 greek.xml
-rw-r--r--   1 root  wheel   5471 Dec  3 12:58 hebrew.xml
-rw-r--r--   1 root  wheel   5462 Dec  3 12:58 hp8.xml
-rw-r--r--   1 root  wheel   5489 Dec  3 12:58 keybcs2.xml
-rw-r--r--   1 root  wheel   5470 Dec  3 12:58 koi8r.xml
-rw-r--r--   1 root  wheel   6492 Dec  3 12:58 koi8u.xml
-rw-r--r--   1 root  wheel   9770 Dec  3 12:58 latin1.xml
-rw-r--r--   1 root  wheel   7192 Dec  3 12:58 latin2.xml
-rw-r--r--   1 root  wheel   5469 Dec  3 12:58 latin5.xml
-rw-r--r--   1 root  wheel   7398 Dec  3 12:58 latin7.xml
-rw-r--r--   1 root  wheel   8007 Dec  3 12:58 macce.xml
-rw-r--r--   1 root  wheel   8018 Dec  3 12:58 macroman.xml
-rw-r--r--   1 root  wheel   6490 Dec  3 12:58 swe7.xml
[31 Dec 2010 18:35] Sveta Smirnova
Thank you for the feedback.

Please also specify exact name of MySQL package you use: file name you downloaded.
[31 Dec 2010 18:41] Richard Secor
These are the ports from FreeBSD 8.1-RELEASE
databases/mysql55-client
databases/mysql55-server

They both are currently using:
mysql-5.5.8.tar.gz
[31 Dec 2010 18:49] Sveta Smirnova
Thank you for the feedback.

Please try with our binaries available at http://dev.mysql.com/downloads: we test with Perl and PHP every release and have not seen such behavior. This easily could be port problem.
[31 Dec 2010 19:37] Richard Secor
Please try with our binaries available at http://dev.mysql.com/downloads: we test with
Perl and PHP every release and have not seen such behavior. This easily could be port
problem.

Downloaded:
mysql-5.5.8-freebsd8.0-x86_64.tar.gz

Extracted to:
/usr/local/mysql-5.5.8-freebsd8.0-x86_64
Linked to /usr/local/mysql

And re-compiled/re-installed p5-DBD-mysql against it by doing the following:
export PATH=/usr/local/mysql:$PATH
cd /usr/ports/databases/p5-DBD-mysql
make clean
make deinstall
make install

This fixes the perl module. I would guess that the same would be true of the php modules.

I'm going to open up a ticket for the FreeBSD Port shortly and reference this ticket.

Am I right in guessing it has to do with either a patch from the FreeBSD Port system or a configure option?
[31 Dec 2010 19:45] Sveta Smirnova
Thank you for the feedback.

Closing as "Not a Bug" because this is not MySQL bug.

> Am I right in guessing it has to do with either a patch from the FreeBSD Port system or a
configure option?

Yes, most likely you are right.
[31 Dec 2010 19:51] Richard Secor
Reference:

FreeBSD Bug Report
http://www.freebsd.org/cgi/query-pr.cgi?pr=153588
[8 Jan 2011 22:59] Alex Dupre
I don't think it's a FreeBSD problem, but a MySQL problem uncovered by the FreeBSD port.
The FreeBSD port doesn't link the mysql client library with threading library, as this is (should be) not needed, since single-threaded applications can use the libc pthread_* stubs. The issue in fact is present only with single-threaded applications, while other applications linked with threading library work correclty.
The issue was not present in previous MySQL versions, built always without linking threading library.
[8 Jan 2011 23:19] Alex Dupre
It could be a problem with the pthread_once stub. Wondering why it shows up only on mysql 5.5.8.
[8 Jan 2011 23:30] Davi Arnaut
For what it's worth, with 5.5, we no longer support non-threaded libmysql.
[9 Jan 2011 4:23] Richard Secor
From the other comments here doesn't this still mean it could be the way the FreeBSD Port for 5.5.x is configuring for compiling mysql?
[9 Jan 2011 12:30] Alex Dupre
Fixed in FreeBSD port by addressing the pthread_once stub issue.
[9 Jan 2011 13:04] Davi Arnaut
Closed as not a MySQL bug. See FreeBSD PR#150959 for reference:

http://www.freebsd.org/cgi/query-pr.cgi?pr=150959