Commit 6bb747bb authored by unknown's avatar unknown

Merge kishkin.ru:/home/wax/mysql-4n into kishkin.ru:/home/wax/mysql-4g

parents 284a6abe 0831433e
...@@ -270,6 +270,24 @@ latin2_general_ci 3 ...@@ -270,6 +270,24 @@ latin2_general_ci 3
select collation(concat_ws(_latin2'a',_latin2'b')), coercibility(concat_ws(_latin2'a',_latin2'b')); 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')) collation(concat_ws(_latin2'a',_latin2'b')) coercibility(concat_ws(_latin2'a',_latin2'b'))
latin2_general_ci 3 latin2_general_ci 3
select collation(trim(_latin2' a ')), coercibility(trim(_latin2' a '));
collation(trim(_latin2' a ')) coercibility(trim(_latin2' a '))
latin2_general_ci 3
select collation(ltrim(_latin2' a ')), coercibility(ltrim(_latin2' a '));
collation(ltrim(_latin2' a ')) coercibility(ltrim(_latin2' a '))
latin2_general_ci 3
select collation(rtrim(_latin2' a ')), coercibility(rtrim(_latin2' a '));
collation(rtrim(_latin2' a ')) coercibility(rtrim(_latin2' a '))
latin2_general_ci 3
select collation(trim(LEADING _latin2' ' FROM _latin2'a')), coercibility(trim(LEADING _latin2'a' FROM _latin2'a'));
collation(trim(LEADING _latin2' ' FROM _latin2'a')) coercibility(trim(LEADING _latin2'a' FROM _latin2'a'))
latin2_general_ci 3
select collation(trim(TRAILING _latin2' ' FROM _latin2'a')), coercibility(trim(TRAILING _latin2'a' FROM _latin2'a'));
collation(trim(TRAILING _latin2' ' FROM _latin2'a')) coercibility(trim(TRAILING _latin2'a' FROM _latin2'a'))
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
create table t1 create table t1
select select
left(_latin2'a',1), left(_latin2'a',1),
...@@ -278,7 +296,14 @@ lcase(_latin2'a'), ...@@ -278,7 +296,14 @@ lcase(_latin2'a'),
ucase(_latin2'a'), ucase(_latin2'a'),
substring(_latin2'a',1,1), substring(_latin2'a',1,1),
concat(_latin2'a',_latin2'b'), concat(_latin2'a',_latin2'b'),
concat_ws(_latin2'a',_latin2'b'); concat_ws(_latin2'a',_latin2'b'),
trim(_latin2' a '),
ltrim(_latin2' a '),
rtrim(_latin2' a '),
trim(LEADING _latin2' ' FROM _latin2' a '),
trim(TRAILING _latin2' ' FROM _latin2' a '),
trim(BOTH _latin2' ' FROM _latin2' a ')
;
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -288,6 +313,12 @@ t1 CREATE TABLE `t1` ( ...@@ -288,6 +313,12 @@ t1 CREATE TABLE `t1` (
`ucase(_latin2'a')` char(1) character set latin2 NOT NULL default '', `ucase(_latin2'a')` char(1) character set latin2 NOT NULL default '',
`substring(_latin2'a',1,1)` 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 '', `concat(_latin2'a',_latin2'b')` char(2) character set latin2 NOT NULL default '',
`concat_ws(_latin2'a',_latin2'b')` char(1) character set latin2 NOT NULL default '' `concat_ws(_latin2'a',_latin2'b')` char(1) 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 '',
`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 ''
) TYPE=MyISAM CHARSET=latin1 ) TYPE=MyISAM CHARSET=latin1
drop table t1; drop table t1;
...@@ -143,6 +143,12 @@ select collation(right(_latin2'a',1)), coercibility(right(_latin2'a',1)); ...@@ -143,6 +143,12 @@ 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(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(concat(_latin2'a',_latin2'b')), coercibility(concat(_latin2'a',_latin2'b'));
select collation(concat_ws(_latin2'a',_latin2'b')), coercibility(concat_ws(_latin2'a',_latin2'b')); select collation(concat_ws(_latin2'a',_latin2'b')), coercibility(concat_ws(_latin2'a',_latin2'b'));
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 '));
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'));
create table t1 create table t1
select select
left(_latin2'a',1), left(_latin2'a',1),
...@@ -151,7 +157,14 @@ select ...@@ -151,7 +157,14 @@ select
ucase(_latin2'a'), ucase(_latin2'a'),
substring(_latin2'a',1,1), substring(_latin2'a',1,1),
concat(_latin2'a',_latin2'b'), concat(_latin2'a',_latin2'b'),
concat_ws(_latin2'a',_latin2'b'); concat_ws(_latin2'a',_latin2'b'),
trim(_latin2' a '),
ltrim(_latin2' a '),
rtrim(_latin2' a '),
trim(LEADING _latin2' ' FROM _latin2' a '),
trim(TRAILING _latin2' ' FROM _latin2' a '),
trim(BOTH _latin2' ' FROM _latin2' a ')
;
show create table t1; show create table t1;
drop table t1; drop table t1;
...@@ -266,7 +266,7 @@ Item *create_func_lpad(Item* a, Item *b, Item *c) ...@@ -266,7 +266,7 @@ Item *create_func_lpad(Item* a, Item *b, Item *c)
Item *create_func_ltrim(Item* a) Item *create_func_ltrim(Item* a)
{ {
return new Item_func_ltrim(a,new Item_string(" ",1,default_charset_info)); return new Item_func_ltrim(a);
} }
Item *create_func_md5(Item* a) Item *create_func_md5(Item* a)
...@@ -365,7 +365,7 @@ Item *create_func_rpad(Item* a, Item *b, Item *c) ...@@ -365,7 +365,7 @@ Item *create_func_rpad(Item* a, Item *b, Item *c)
Item *create_func_rtrim(Item* a) Item *create_func_rtrim(Item* a)
{ {
return new Item_func_rtrim(a,new Item_string(" ",1,default_charset_info)); return new Item_func_rtrim(a);
} }
Item *create_func_sec_to_time(Item* a) Item *create_func_sec_to_time(Item* a)
...@@ -390,7 +390,20 @@ Item *create_func_sha(Item* a) ...@@ -390,7 +390,20 @@ Item *create_func_sha(Item* a)
Item *create_func_space(Item *a) Item *create_func_space(Item *a)
{ {
return new Item_func_repeat(new Item_string(" ",1,default_charset_info),a); CHARSET_INFO *cs= current_thd->variables.collation_connection;
Item *sp;
if (cs->state & MY_CS_NONTEXT)
{
sp= new Item_string("",0,cs);
if (sp)
sp->str_value.copy(" ",1,&my_charset_latin1,cs);
}
else
{
sp= new Item_string(" ",1,cs);
}
return new Item_func_repeat(sp, a);
} }
Item *create_func_soundex(Item* a) Item *create_func_soundex(Item* a)
......
...@@ -1136,7 +1136,7 @@ String *Item_func_ltrim::val_str(String *str) ...@@ -1136,7 +1136,7 @@ String *Item_func_ltrim::val_str(String *str)
return 0; /* purecov: inspected */ return 0; /* purecov: inspected */
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff),res->charset()); String tmp(buff,sizeof(buff),res->charset());
String *remove_str=args[1]->val_str(&tmp); String *remove_str= (arg_count==2) ? args[1]->val_str(&tmp) : &remove;
uint remove_length; uint remove_length;
LINT_INIT(remove_length); LINT_INIT(remove_length);
...@@ -1174,7 +1174,7 @@ String *Item_func_rtrim::val_str(String *str) ...@@ -1174,7 +1174,7 @@ String *Item_func_rtrim::val_str(String *str)
return 0; /* purecov: inspected */ return 0; /* purecov: inspected */
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff),res->charset()); String tmp(buff,sizeof(buff),res->charset());
String *remove_str=args[1]->val_str(&tmp); String *remove_str= (arg_count==2) ? args[1]->val_str(&tmp) : &remove;
uint remove_length; uint remove_length;
LINT_INIT(remove_length); LINT_INIT(remove_length);
...@@ -1246,7 +1246,7 @@ String *Item_func_trim::val_str(String *str) ...@@ -1246,7 +1246,7 @@ String *Item_func_trim::val_str(String *str)
return 0; /* purecov: inspected */ return 0; /* purecov: inspected */
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff),res->charset()); String tmp(buff,sizeof(buff),res->charset());
String *remove_str=args[1]->val_str(&tmp); String *remove_str= (arg_count==2) ? args[1]->val_str(&tmp) : &remove;
uint remove_length; uint remove_length;
LINT_INIT(remove_length); LINT_INIT(remove_length);
...@@ -1291,6 +1291,29 @@ String *Item_func_trim::val_str(String *str) ...@@ -1291,6 +1291,29 @@ String *Item_func_trim::val_str(String *str)
return &tmp_value; return &tmp_value;
} }
void Item_func_trim::fix_length_and_dec()
{
max_length= args[0]->max_length;
if (arg_count == 1)
{
set_charset(args[0]->charset(), args[0]->coercibility);
remove.set_charset(charset());
remove.set_ascii(" ",1);
}
else
if (set_charset(args[1]->charset(), args[1]->coercibility,
args[0]->charset(), args[0]->coercibility))
{
my_error(ER_CANT_AGGREGATE_COLLATIONS,MYF(0),
args[1]->charset()->name,coercion_name(args[1]->coercibility),
args[0]->charset()->name,coercion_name(args[0]->coercibility),
func_name());
}
}
void Item_func_password::fix_length_and_dec() void Item_func_password::fix_length_and_dec()
{ {
/* /*
......
...@@ -220,35 +220,37 @@ public: ...@@ -220,35 +220,37 @@ public:
}; };
class Item_func_ltrim :public Item_str_func class Item_func_trim :public Item_str_func
{ {
protected:
String tmp_value; String tmp_value;
String remove;
public: public:
Item_func_ltrim(Item *a,Item *b) :Item_str_func(a,b) {} Item_func_trim(Item *a,Item *b) :Item_str_func(a,b) {}
Item_func_trim(Item *a) :Item_str_func(a) {}
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec() { max_length= args[0]->max_length; } void fix_length_and_dec();
const char *func_name() const { return "ltrim"; } const char *func_name() const { return "trim"; }
}; };
class Item_func_rtrim :public Item_str_func class Item_func_ltrim :public Item_func_trim
{ {
String tmp_value;
public: public:
Item_func_rtrim(Item *a,Item *b) :Item_str_func(a,b) {} Item_func_ltrim(Item *a,Item *b) :Item_func_trim(a,b) {}
Item_func_ltrim(Item *a) :Item_func_trim(a) {}
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec() { max_length= args[0]->max_length; } const char *func_name() const { return "ltrim"; }
const char *func_name() const { return "rtrim"; }
}; };
class Item_func_trim :public Item_str_func
class Item_func_rtrim :public Item_func_trim
{ {
String tmp_value;
public: public:
Item_func_trim(Item *a,Item *b) :Item_str_func(a,b) {} Item_func_rtrim(Item *a,Item *b) :Item_func_trim(a,b) {}
Item_func_rtrim(Item *a) :Item_func_trim(a) {}
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec() { max_length= args[0]->max_length; } const char *func_name() const { return "rtrim"; }
const char *func_name() const { return "trim"; }
}; };
......
...@@ -593,7 +593,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -593,7 +593,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%type <item> %type <item>
literal text_literal insert_ident order_ident literal text_literal insert_ident order_ident
simple_ident select_item2 expr opt_expr opt_else sum_expr in_sum_expr simple_ident select_item2 expr opt_expr opt_else sum_expr in_sum_expr
table_wild opt_pad no_in_expr expr_expr simple_expr no_and_expr table_wild no_in_expr expr_expr simple_expr no_and_expr
using_list expr_or_default set_expr_or_default interval_expr using_list expr_or_default set_expr_or_default interval_expr
param_marker singlerow_subselect singlerow_subselect_init param_marker singlerow_subselect singlerow_subselect_init
exists_subselect exists_subselect_init exists_subselect exists_subselect_init
...@@ -2479,13 +2479,19 @@ simple_expr: ...@@ -2479,13 +2479,19 @@ simple_expr:
| SUBSTRING_INDEX '(' expr ',' expr ',' expr ')' | SUBSTRING_INDEX '(' expr ',' expr ',' expr ')'
{ $$= new Item_func_substr_index($3,$5,$7); } { $$= new Item_func_substr_index($3,$5,$7); }
| TRIM '(' expr ')' | TRIM '(' expr ')'
{ $$= new Item_func_trim($3,new Item_string(" ",1,default_charset_info)); } { $$= new Item_func_trim($3); }
| TRIM '(' LEADING opt_pad FROM expr ')' | TRIM '(' LEADING expr FROM expr ')'
{ $$= new Item_func_ltrim($6,$4); } { $$= new Item_func_ltrim($6,$4); }
| TRIM '(' TRAILING opt_pad FROM expr ')' | TRIM '(' TRAILING expr FROM expr ')'
{ $$= new Item_func_rtrim($6,$4); } { $$= new Item_func_rtrim($6,$4); }
| TRIM '(' BOTH opt_pad FROM expr ')' | TRIM '(' BOTH expr FROM expr ')'
{ $$= new Item_func_trim($6,$4); } { $$= new Item_func_trim($6,$4); }
| TRIM '(' LEADING FROM expr ')'
{ $$= new Item_func_ltrim($5); }
| TRIM '(' TRAILING FROM expr ')'
{ $$= new Item_func_rtrim($5); }
| TRIM '(' BOTH FROM expr ')'
{ $$= new Item_func_trim($5); }
| TRIM '(' expr FROM expr ')' | TRIM '(' expr FROM expr ')'
{ $$= new Item_func_trim($5,$3); } { $$= new Item_func_trim($5,$3); }
| TRUNCATE_SYM '(' expr ',' expr ')' | TRUNCATE_SYM '(' expr ',' expr ')'
...@@ -2707,10 +2713,6 @@ when_list2: ...@@ -2707,10 +2713,6 @@ when_list2:
sel->when_list.head()->push_back($5); sel->when_list.head()->push_back($5);
}; };
opt_pad:
/* empty */ { $$=new Item_string(" ",1,default_charset_info); }
| expr { $$=$1; };
join_table_list: join_table_list:
'(' join_table_list ')' { $$=$2; } '(' join_table_list ')' { $$=$2; }
| join_table { $$=$1; } | join_table { $$=$1; }
......
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