Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
6bb747bb
Commit
6bb747bb
authored
Jun 05, 2003
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge kishkin.ru:/home/wax/mysql-4n into kishkin.ru:/home/wax/mysql-4g
parents
284a6abe
0831433e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
116 additions
and
32 deletions
+116
-32
mysql-test/r/func_str.result
mysql-test/r/func_str.result
+33
-2
mysql-test/t/func_str.test
mysql-test/t/func_str.test
+14
-1
sql/item_create.cc
sql/item_create.cc
+16
-3
sql/item_strfunc.cc
sql/item_strfunc.cc
+26
-3
sql/item_strfunc.h
sql/item_strfunc.h
+16
-14
sql/sql_yacc.yy
sql/sql_yacc.yy
+11
-9
No files found.
mysql-test/r/func_str.result
View file @
6bb747bb
...
...
@@ -270,6 +270,24 @@ 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(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
select
left(_latin2'a',1),
...
...
@@ -278,7 +296,14 @@ lcase(_latin2'a'),
ucase(_latin2'a'),
substring(_latin2'a',1,1),
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;
Table Create Table
t1 CREATE TABLE `t1` (
...
...
@@ -288,6 +313,12 @@ 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 '',
`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
drop table t1;
mysql-test/t/func_str.test
View file @
6bb747bb
...
...
@@ -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
(
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
(
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
select
left
(
_latin2
'a'
,
1
),
...
...
@@ -151,7 +157,14 @@ select
ucase
(
_latin2
'a'
),
substring
(
_latin2
'a'
,
1
,
1
),
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
;
drop
table
t1
;
sql/item_create.cc
View file @
6bb747bb
...
...
@@ -266,7 +266,7 @@ Item *create_func_lpad(Item* a, Item *b, Item *c)
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
)
...
...
@@ -365,7 +365,7 @@ Item *create_func_rpad(Item* a, Item *b, Item *c)
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
)
...
...
@@ -390,7 +390,20 @@ Item *create_func_sha(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
)
...
...
sql/item_strfunc.cc
View file @
6bb747bb
...
...
@@ -1136,7 +1136,7 @@ String *Item_func_ltrim::val_str(String *str)
return
0
;
/* purecov: inspected */
char
buff
[
MAX_FIELD_WIDTH
];
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
;
LINT_INIT
(
remove_length
);
...
...
@@ -1174,7 +1174,7 @@ String *Item_func_rtrim::val_str(String *str)
return
0
;
/* purecov: inspected */
char
buff
[
MAX_FIELD_WIDTH
];
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
;
LINT_INIT
(
remove_length
);
...
...
@@ -1246,7 +1246,7 @@ String *Item_func_trim::val_str(String *str)
return
0
;
/* purecov: inspected */
char
buff
[
MAX_FIELD_WIDTH
];
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
;
LINT_INIT
(
remove_length
);
...
...
@@ -1291,6 +1291,29 @@ String *Item_func_trim::val_str(String *str)
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
()
{
/*
...
...
sql/item_strfunc.h
View file @
6bb747bb
...
...
@@ -220,35 +220,37 @@ public:
};
class
Item_func_
l
trim
:
public
Item_str_func
class
Item_func_trim
:
public
Item_str_func
{
protected:
String
tmp_value
;
String
remove
;
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
*
);
void
fix_length_and_dec
()
{
max_length
=
args
[
0
]
->
max_length
;
}
const
char
*
func_name
()
const
{
return
"
l
trim"
;
}
void
fix_length_and_dec
()
;
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:
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
*
);
void
fix_length_and_dec
()
{
max_length
=
args
[
0
]
->
max_length
;
}
const
char
*
func_name
()
const
{
return
"rtrim"
;
}
const
char
*
func_name
()
const
{
return
"ltrim"
;
}
};
class
Item_func_trim
:
public
Item_str_func
class
Item_func_rtrim
:
public
Item_func_trim
{
String
tmp_value
;
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
*
);
void
fix_length_and_dec
()
{
max_length
=
args
[
0
]
->
max_length
;
}
const
char
*
func_name
()
const
{
return
"trim"
;
}
const
char
*
func_name
()
const
{
return
"rtrim"
;
}
};
...
...
sql/sql_yacc.yy
View file @
6bb747bb
...
...
@@ -593,7 +593,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%type <item>
literal text_literal insert_ident order_ident
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
param_marker singlerow_subselect singlerow_subselect_init
exists_subselect exists_subselect_init
...
...
@@ -2479,13 +2479,19 @@ simple_expr:
| SUBSTRING_INDEX '(' expr ',' expr ',' expr ')'
{ $$= new Item_func_substr_index($3,$5,$7); }
| TRIM '(' expr ')'
{ $$= new Item_func_trim($3
,new Item_string(" ",1,default_charset_info)
); }
| TRIM '(' LEADING
opt_pad
FROM expr ')'
{ $$= new Item_func_trim($3); }
| TRIM '(' LEADING
expr
FROM expr ')'
{ $$= new Item_func_ltrim($6,$4); }
| TRIM '(' TRAILING
opt_pad
FROM expr ')'
| TRIM '(' TRAILING
expr
FROM expr ')'
{ $$= new Item_func_rtrim($6,$4); }
| TRIM '(' BOTH
opt_pad
FROM expr ')'
| TRIM '(' BOTH
expr
FROM expr ')'
{ $$= 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 ')'
{ $$= new Item_func_trim($5,$3); }
| TRUNCATE_SYM '(' expr ',' expr ')'
...
...
@@ -2707,10 +2713,6 @@ when_list2:
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 ')' { $$=$2; }
| join_table { $$=$1; }
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment