0

I am getting the 'illegal mix of collations' error when running function or stored procedures that have any form of text/string comparison in them. Yes, I have trawled the net for hours and cant find anything that quite matches my problem. Here is the detail.

We have 2 MySQL servers, one for dev one for test. The dev server is a packaged Wamp install done by the developer and is setup as it comes out of the box. So the charset is latin and the collation is the rather strange default of swedish. I am sure you have seen that. It is a 5.5 version server.

The test server is a manually installed and configured server (by me). It is a version 5.6 server and I set it up with DB default to utf8/utf8_unicode_ci.

All the tables are also set to utf8 etc.

The functions and procedures work fine on dev server (collation=swedish) but any funcs/procs/ that have any form of string comparison in them (ie 'where product_code='PRTRS123') they fail with an illegal collation mix error. (numeric comparisons work fine, ie where id = 22)

But If I pull out the exact sql from the function and just run it in a query window, all works fine. And If I just make a small change to the function/procedure (ie add a couple or carriage returns or just re-format the layout a bit), then save/update the procedure, it then works perfect as well.

So this is indicating to me that the funs/procs themselves somehow have their original collation stored somewhere in their definition.

Is this the case?

And if so, how can I update this setting to reflect the new host server's setting?

Going into every fund/proc and adding a carriage return or a couple of spaces to make it save and update is a real issue. We have hundreds!

One final point. I found a couple of articles saying to do an alter table convert statement. I tried this and sure enough it trawled through my selected table and did the conversions. It took a while (big table) so presumably it was also updating all the columns as well. That made no difference.

The only thing that fixed this was forcing a save update of the functions themselves. And no, just doing a compile without making an edit first didnt work either.

Hope there is an answer as this is driving me nuts! Thanks Mark

4

0 回答 0