Commit 8a40e2e8 authored by unknown's avatar unknown

Some more functions work according to coercibility now:

repeat, reverse, quote, soundex, substring
Test func_str has been extended to check them

parent 4b420bb2
......@@ -288,6 +288,21 @@ latin2_general_ci 3
select collation(trim(BOTH _latin2' ' FROM _latin2'a')), coercibility(trim(BOTH _latin2'a' FROM _latin2'a'));
collation(trim(BOTH _latin2' ' FROM _latin2'a')) coercibility(trim(BOTH _latin2'a' FROM _latin2'a'))
latin2_general_ci 3
select collation(repeat(_latin2'a',10)), coercibility(repeat(_latin2'a',10));
collation(repeat(_latin2'a',10)) coercibility(repeat(_latin2'a',10))
latin2_general_ci 3
select collation(reverse(_latin2'ab')), coercibility(reverse(_latin2'ab'));
collation(reverse(_latin2'ab')) coercibility(reverse(_latin2'ab'))
latin2_general_ci 3
select collation(quote(_latin2'ab')), coercibility(quote(_latin2'ab'));
collation(quote(_latin2'ab')) coercibility(quote(_latin2'ab'))
latin2_general_ci 3
select collation(soundex(_latin2'ab')), coercibility(soundex(_latin2'ab'));
collation(soundex(_latin2'ab')) coercibility(soundex(_latin2'ab'))
latin2_general_ci 3
select collation(substring(_latin2'ab',1)), coercibility(substring(_latin2'ab',1));
collation(substring(_latin2'ab',1)) coercibility(substring(_latin2'ab',1))
latin2_general_ci 3
create table t1
select
left(_latin2'a',1),
......@@ -302,7 +317,12 @@ ltrim(_latin2' a '),
rtrim(_latin2' a '),
trim(LEADING _latin2' ' FROM _latin2' a '),
trim(TRAILING _latin2' ' FROM _latin2' a '),
trim(BOTH _latin2' ' FROM _latin2' a ')
trim(BOTH _latin2' ' FROM _latin2' a '),
repeat(_latin2'a',10),
reverse(_latin2'ab'),
quote(_latin2'ab'),
soundex(_latin2'ab'),
substring(_latin2'ab',1)
;
show create table t1;
Table Create Table
......@@ -319,6 +339,11 @@ t1 CREATE TABLE `t1` (
`rtrim(_latin2' a ')` char(3) character set latin2 NOT NULL default '',
`trim(LEADING _latin2' ' FROM _latin2' a ')` char(3) character set latin2 NOT NULL default '',
`trim(TRAILING _latin2' ' FROM _latin2' a ')` char(3) character set latin2 NOT NULL default '',
`trim(BOTH _latin2' ' FROM _latin2' a ')` char(3) character set latin2 NOT NULL default ''
`trim(BOTH _latin2' ' FROM _latin2' a ')` char(3) character set latin2 NOT NULL default '',
`repeat(_latin2'a',10)` char(10) character set latin2 NOT NULL default '',
`reverse(_latin2'ab')` char(2) character set latin2 NOT NULL default '',
`quote(_latin2'ab')` char(6) character set latin2 NOT NULL default '',
`soundex(_latin2'ab')` char(4) character set latin2 NOT NULL default '',
`substring(_latin2'ab',1)` char(2) character set latin2 NOT NULL default ''
) TYPE=MyISAM CHARSET=latin1
drop table t1;
......@@ -149,6 +149,12 @@ select collation(rtrim(_latin2' a ')), coercibility(rtrim(_latin2' a '));
select collation(trim(LEADING _latin2' ' FROM _latin2'a')), coercibility(trim(LEADING _latin2'a' FROM _latin2'a'));
select collation(trim(TRAILING _latin2' ' FROM _latin2'a')), coercibility(trim(TRAILING _latin2'a' FROM _latin2'a'));
select collation(trim(BOTH _latin2' ' FROM _latin2'a')), coercibility(trim(BOTH _latin2'a' FROM _latin2'a'));
select collation(repeat(_latin2'a',10)), coercibility(repeat(_latin2'a',10));
select collation(reverse(_latin2'ab')), coercibility(reverse(_latin2'ab'));
select collation(quote(_latin2'ab')), coercibility(quote(_latin2'ab'));
select collation(soundex(_latin2'ab')), coercibility(soundex(_latin2'ab'));
select collation(substring(_latin2'ab',1)), coercibility(substring(_latin2'ab',1));
create table t1
select
left(_latin2'a',1),
......@@ -163,7 +169,12 @@ select
rtrim(_latin2' a '),
trim(LEADING _latin2' ' FROM _latin2' a '),
trim(TRAILING _latin2' ' FROM _latin2' a '),
trim(BOTH _latin2' ' FROM _latin2' a ')
trim(BOTH _latin2' ' FROM _latin2' a '),
repeat(_latin2'a',10),
reverse(_latin2'ab'),
quote(_latin2'ab'),
soundex(_latin2'ab'),
substring(_latin2'ab',1)
;
show create table t1;
......
......@@ -263,13 +263,6 @@ class Item_func_strcmp :public Item_bool_func2
public:
Item_func_strcmp(Item *a,Item *b) :Item_bool_func2(a,b) {}
longlong val_int();
void fix_length_and_dec()
{
max_length=2;
/* QQ: COERCIBILITY */
cmp_charset= args[0]->binary() || args[1]->binary() ?
&my_charset_bin : args[0]->charset();
}
optimize_type select_optimize() const { return OPTIMIZE_NONE; }
const char *func_name() const { return "strcmp"; }
};
......
......@@ -702,6 +702,7 @@ String *Item_func_reverse::val_str(String *str)
void Item_func_reverse::fix_length_and_dec()
{
set_charset(args[0]->charset(),args[0]->coercibility);
max_length = args[0]->max_length;
}
......@@ -1521,6 +1522,7 @@ String *Item_func_user::val_str(String *str)
void Item_func_soundex::fix_length_and_dec()
{
set_charset(args[0]->charset(), args[0]->coercibility);
max_length=args[0]->max_length;
set_if_bigger(max_length,4);
}
......@@ -1552,7 +1554,7 @@ String *Item_func_soundex::val_str(String *str)
{
String *res =args[0]->val_str(str);
char last_ch,ch;
CHARSET_INFO *cs= &my_charset_latin1;
CHARSET_INFO *cs= charset();
if ((null_value=args[0]->null_value))
return 0; /* purecov: inspected */
......@@ -2538,6 +2540,7 @@ String *Item_func_quote::val_str(String *str)
}
*to= '\'';
str->length(new_length);
str->set_charset(charset());
return str;
null:
......
......@@ -571,7 +571,11 @@ class Item_func_quote :public Item_str_func
Item_func_quote(Item *a) :Item_str_func(a) {}
const char *func_name() const { return "quote"; }
String *val_str(String *);
void fix_length_and_dec() { max_length= args[0]->max_length * 2 + 2; }
void fix_length_and_dec()
{
set_charset(args[0]->charset(), args[0]->coercibility);
max_length= args[0]->max_length * 2 + 2;
}
};
class Item_func_conv_charset :public Item_str_func
......
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