Bug #3087 CONCAT_WS makes the server die in case of illegal mix of collations

This commit is contained in:
bar@bar.intranet.mysql.r18.ru 2004-03-19 12:09:14 +04:00
parent f897144c4e
commit 66631a3c1e
3 changed files with 6 additions and 0 deletions

View file

@ -339,6 +339,8 @@ select concat(_latin1'a',_latin2'a',_latin5'a');
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin5_turkish_ci,COERCIBLE) for operation 'concat'
select concat(_latin1'a',_latin2'a',_latin5'a',_latin7'a');
ERROR HY000: Illegal mix of collations for operation 'concat'
select concat_ws(_latin1'a',_latin2'a');
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat_ws'
select FIELD('b','A','B');
FIELD('b','A','B')
2

View file

@ -195,6 +195,8 @@ select concat(_latin1'a',_latin2'a');
select concat(_latin1'a',_latin2'a',_latin5'a');
--error 1271
select concat(_latin1'a',_latin2'a',_latin5'a',_latin7'a');
--error 1267
select concat_ws(_latin1'a',_latin2'a');
#
# Test FIELD() and collations

View file

@ -628,9 +628,11 @@ void Item_func_concat_ws::fix_length_and_dec()
max_length=separator->max_length*(arg_count-1);
for (uint i=0 ; i < arg_count ; i++)
{
DTCollation tmp(collation.collation, collation.derivation);
max_length+=args[i]->max_length;
if (collation.aggregate(args[i]->collation))
{
collation.set(tmp); // Restore the previous value
my_coll_agg_error(collation, args[i]->collation, func_name());
break;
}