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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
8ae717d3
Commit
8ae717d3
authored
Jun 03, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LTRIM, RTRIM and TRIM now honors coercibility
LTRIM, RTRIM and TRIM now work fine with ucs2
parent
27d95e96
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
28 deletions
+55
-28
sql/item_create.cc
sql/item_create.cc
+2
-2
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.
sql/item_create.cc
View file @
8ae717d3
...
...
@@ -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
)
...
...
sql/item_strfunc.cc
View file @
8ae717d3
...
...
@@ -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 @
8ae717d3
...
...
@@ -220,35 +220,37 @@ class Item_func_substr_index :public Item_str_func
};
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 @
8ae717d3
...
...
@@ -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