PDA

View Full Version : Notifications not working - MySQL character set problem


MikeW
26th May 2007, 06:47 PM
Hi,

I had a problem with SupportCenter - I had set up notifications, but wasn't
receiving any. If I added something into "Mail Gateway", I *did* get those.

I think I managed to get it working by:

Step 1 - I turned on debug level, and put stuff into the debug log.

Step 2 - I saw SQL in the debug log, so manually took the (very long) select statement out, and ran it manually.

This created an error:
ERROR 1270 (HY000): Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (utf8_general_ci,IMPLICIT), (latin1_swedish_ci,COERCIBLE) for operation 'concat'

I assume that this was happening in the application, even though it wasn't appearing in the logs.

I *hate* MySQL when it gets into character-set difficulties!

Step 3 - Investigated lots. Looks like the DB I used for this was set with a
default of "utf8", while the client connection I typed the command
in manually was defined to have a default of "latin1".

Step 4 - Changed the default character set of the manual client session:

mysql> set names 'utf8';

The SQL select worked, and gave me the expected notification.

Step 5 - Changed the default character set of the manual client back to 'latin1', as I assume that is how the SupportCenter PHP is connecting.

Step 6 - Use commands like:

mysql> show full columns from tickets;
mysql> show table status;

I could see that many tables were set to use the character set of UTF-8.

Step 7 - Used the following command to convert the tables used in the SQL Query:

mysql> ALTER TABLE tickets CONVERT TO CHARACTER SET latin1;
mysql> ALTER TABLE user_notifications CONVERT TO CHARACTER SET latin1;
mysql> ALTER TABLE queue_agents CONVERT TO CHARACTER SET latin1;
mysql> ALTER TABLE queues CONVERT TO CHARACTER SET latin1;
mysql> ALTER TABLE users CONVERT TO CHARACTER SET latin1;
mysql> ALTER TABLE mails CONVERT TO CHARACTER SET latin1;
mysql> ALTER TABLE mail_users CONVERT TO CHARACTER SET latin1;

A new ticket now caused the notification to work correctly.

Step 8 - Of course, a few other things were broken because of character-set problems, so I then had to convert the remaining tables.


I guess the root cause of this is that my MySQL was configured with a default character
set of UTF-8, at least at database level, which was probably picked up from the
system-level setting.


mysql> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | utf8 |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

I guess the table-creation script will have allowed all the tables to default to
using UTF-8, while the specification of string literals will take their charset from the
client connection; I guess this just picks up a default from PHP?

Cheers,

Mike

29th May 2007, 09:41 AM
Hello Mike,

SupportCenter will not work in other character set as UTF-8
All mails (special characters) will be corrupted in case you will use latin1 as db collation.

SupportCenter is designed to work just in UTF-8 encoding.

I would recomend you to reinstall the database again with UTF-8 collation.

Viktor

29th May 2007, 09:43 AM
We will add to next release also by default change of mysql client connection settings (UTF-8), so such error will not repeat.

29th May 2007, 09:53 AM
Hello,

I just want to notice, that in all versions higher as 1.5.4 will be this problem fixed and client connection collation will be changed to UTF-8 by default even your default mysql client connection will have other collation.

Viktor

MikeW
1st June 2007, 01:34 PM
Hello Mike,

SupportCenter will not work in other character set as UTF-8
All mails (special characters) will be corrupted in case you will use latin1 as db collation.

SupportCenter is designed to work just in UTF-8 encoding.

I would recomend you to reinstall the database again with UTF-8 collation.

Viktor
I guessed this was perhaps the case, but the code was the one thing I couldn't change.

I'll install the upgrade, and "fix" the table collations back again

Thanks!

3rd June 2007, 07:15 PM
You should be able to download newest version, where UTF-8 is predefined in connection settings by default to UTF-8

If you will have problems with installation, just let me know here: support@qualityunit.com

And we can install it for you.