Commit 36e0b1cd authored by unknown's avatar unknown

LPAD, RPAD, MAKE_SET and EXPORT_SET now works correctly with collations

parent 59e1e7b2
......@@ -285,9 +285,21 @@ latin2_general_ci 3
select collation(concat(_latin2'a',_latin2'b')), coercibility(concat(_latin2'a',_latin2'b'));
collation(concat(_latin2'a',_latin2'b')) coercibility(concat(_latin2'a',_latin2'b'))
latin2_general_ci 3
select collation(lpad(_latin2'a',4,_latin2'b')), coercibility(lpad(_latin2'a',4,_latin2'b'));
collation(lpad(_latin2'a',4,_latin2'b')) coercibility(lpad(_latin2'a',4,_latin2'b'))
binary 3
select collation(rpad(_latin2'a',4,_latin2'b')), coercibility(rpad(_latin2'a',4,_latin2'b'));
collation(rpad(_latin2'a',4,_latin2'b')) coercibility(rpad(_latin2'a',4,_latin2'b'))
latin2_general_ci 3
select collation(concat_ws(_latin2'a',_latin2'b')), coercibility(concat_ws(_latin2'a',_latin2'b'));
collation(concat_ws(_latin2'a',_latin2'b')) coercibility(concat_ws(_latin2'a',_latin2'b'))
latin2_general_ci 3
select collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')), coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c'));
collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')) coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c'))
latin2_general_ci 3
select collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')), coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' '));
collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')) coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' '))
binary 3
select collation(trim(_latin2' a ')), coercibility(trim(_latin2' a '));
collation(trim(_latin2' a ')) coercibility(trim(_latin2' a '))
latin2_general_ci 3
......@@ -341,7 +353,11 @@ lcase(_latin2'a'),
ucase(_latin2'a'),
substring(_latin2'a',1,1),
concat(_latin2'a',_latin2'b'),
lpad(_latin2'a',4,_latin2'b'),
rpad(_latin2'a',4,_latin2'b'),
concat_ws(_latin2'a',_latin2'b'),
make_set(255,_latin2'a',_latin2'b',_latin2'c'),
export_set(255,_latin2'y',_latin2'n',_latin2' '),
trim(_latin2' a '),
ltrim(_latin2' a '),
rtrim(_latin2' a '),
......@@ -373,7 +389,11 @@ t1 CREATE TABLE `t1` (
`ucase(_latin2'a')` char(1) character set latin2 NOT NULL default '',
`substring(_latin2'a',1,1)` char(1) character set latin2 NOT NULL default '',
`concat(_latin2'a',_latin2'b')` char(2) character set latin2 NOT NULL default '',
`lpad(_latin2'a',4,_latin2'b')` char(4) character set latin2 NOT NULL default '',
`rpad(_latin2'a',4,_latin2'b')` char(4) character set latin2 NOT NULL default '',
`concat_ws(_latin2'a',_latin2'b')` char(1) character set latin2 NOT NULL default '',
`make_set(255,_latin2'a',_latin2'b',_latin2'c')` char(5) character set latin2 NOT NULL default '',
`export_set(255,_latin2'y',_latin2'n',_latin2' ')` char(127) character set latin2 NOT NULL default '',
`trim(_latin2' a ')` char(3) character set latin2 NOT NULL default '',
`ltrim(_latin2' a ')` char(3) character set latin2 NOT NULL default '',
`rtrim(_latin2' a ')` char(3) character set latin2 NOT NULL default '',
......
......@@ -148,7 +148,11 @@ select collation(left(_latin2'a',1)), coercibility(left(_latin2'a',1));
select collation(right(_latin2'a',1)), coercibility(right(_latin2'a',1));
select collation(substring(_latin2'a',1,1)), coercibility(substring(_latin2'a',1,1));
select collation(concat(_latin2'a',_latin2'b')), coercibility(concat(_latin2'a',_latin2'b'));
select collation(lpad(_latin2'a',4,_latin2'b')), coercibility(lpad(_latin2'a',4,_latin2'b'));
select collation(rpad(_latin2'a',4,_latin2'b')), coercibility(rpad(_latin2'a',4,_latin2'b'));
select collation(concat_ws(_latin2'a',_latin2'b')), coercibility(concat_ws(_latin2'a',_latin2'b'));
select collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')), coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c'));
select collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')), coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' '));
select collation(trim(_latin2' a ')), coercibility(trim(_latin2' a '));
select collation(ltrim(_latin2' a ')), coercibility(ltrim(_latin2' a '));
select collation(rtrim(_latin2' a ')), coercibility(rtrim(_latin2' a '));
......@@ -177,7 +181,11 @@ select
ucase(_latin2'a'),
substring(_latin2'a',1,1),
concat(_latin2'a',_latin2'b'),
lpad(_latin2'a',4,_latin2'b'),
rpad(_latin2'a',4,_latin2'b'),
concat_ws(_latin2'a',_latin2'b'),
make_set(255,_latin2'a',_latin2'b',_latin2'c'),
export_set(255,_latin2'y',_latin2'n',_latin2' '),
trim(_latin2' a '),
ltrim(_latin2' a '),
rtrim(_latin2' a '),
......
......@@ -1780,8 +1780,20 @@ void Item_func_make_set::split_sum_func(Item **ref_pointer_array,
void Item_func_make_set::fix_length_and_dec()
{
max_length=arg_count-1;
for (uint i=1 ; i < arg_count ; i++)
set_charset(args[0]->charset(), args[0]->coercibility);
for (uint i=0 ; i < arg_count ; i++)
{
max_length+=args[i]->max_length;
if (set_charset(charset(), coercibility,
args[i]->charset(), args[i]->coercibility))
{
my_error(ER_CANT_AGGREGATE_COLLATIONS,MYF(0),
charset()->name,coercion_name(coercibility),
args[i]->charset()->name,coercion_name(args[i]->coercibility),
func_name());
break;
}
}
used_tables_cache|=item->used_tables();
const_item_cache&=item->const_item();
with_sum_func= with_sum_func || item->with_sum_func;
......@@ -1964,6 +1976,15 @@ err:
void Item_func_rpad::fix_length_and_dec()
{
if (set_charset(args[0]->charset(), args[0]->coercibility,
args[2]->charset(), args[2]->coercibility))
{
my_error(ER_CANT_AGGREGATE_COLLATIONS,MYF(0),
args[0]->charset()->name,coercion_name(args[0]->coercibility),
args[2]->charset()->name,coercion_name(args[2]->coercibility),
func_name());
}
if (args[1]->const_item())
{
uint32 length= (uint32) args[1]->val_int();
......@@ -2024,6 +2045,15 @@ String *Item_func_rpad::val_str(String *str)
void Item_func_lpad::fix_length_and_dec()
{
if (set_charset(args[0]->charset(), args[0]->coercibility,
args[2]->charset(), args[2]->coercibility))
{
my_error(ER_CANT_AGGREGATE_COLLATIONS,MYF(0),
args[0]->charset()->name,coercion_name(args[0]->coercibility),
args[2]->charset()->name,coercion_name(args[2]->coercibility),
func_name());
}
if (args[1]->const_item())
{
uint32 length= (uint32) args[1]->val_int();
......@@ -2433,9 +2463,24 @@ String* Item_func_export_set::val_str(String* str)
void Item_func_export_set::fix_length_and_dec()
{
uint i;
uint length=max(args[1]->max_length,args[2]->max_length);
uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
max_length=length*64+sep_length*63;
set_charset(args[1]->charset(), args[1]->coercibility);
for (i=2 ; i < 4 && i < arg_count ; i++)
{
if (set_charset(charset(), coercibility,
args[i]->charset(), args[i]->coercibility))
{
my_error(ER_CANT_AGGREGATE_COLLATIONS,MYF(0),
charset()->name,coercion_name(coercibility),
args[i]->charset()->name,coercion_name(args[i]->coercibility),
func_name());
break;
}
}
}
String* Item_func_inet_ntoa::val_str(String* str)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment