we ran into a problem while using user variables and using different collations. It seems that a variable assignment can take place even if the condition to do so is not met.
Out server is set to use utf8mb4_unicode_ci. But some connections are using utf8_unicode_ci, and only those connections show the following problem.
We broke it down to the following example SQL (the real statement is much more complex and not so easy to work around the shown behaviour):
My expectation is, that the result is a single value 'bar', because the if condition should fail and therefore the "else" statement should be executed. But we observe that the result is 'L', which can only be if the if condition succeeds. A quick check shows that @bla is really 'bar'. How can this be?
If I leave out the line "set names utf8 collate utf8_unicode_ci", that is if I continue to use utf8mb4_unicode_ci, I get the expected result and behavior.
Is this a bug, or a somehow intended behavior?