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
c2b60a6f
Commit
c2b60a6f
authored
Dec 04, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for bug#1944 'Function RPad() sometimes produce unexpected result'
parent
d8e425c2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
12 deletions
+20
-12
mysql-test/r/func_str.result
mysql-test/r/func_str.result
+12
-6
mysql-test/t/func_str.test
mysql-test/t/func_str.test
+4
-2
sql/item_strfunc.cc
sql/item_strfunc.cc
+2
-2
sql/item_strfunc.h
sql/item_strfunc.h
+2
-2
No files found.
mysql-test/r/func_str.result
View file @
c2b60a6f
...
...
@@ -119,12 +119,12 @@ montymontymontymontymonty * *
select reverse('abc'),reverse('abcd');
reverse('abc') reverse('abcd')
cba dcba
select rpad('a',4,'1'),rpad('a',4,'12'),rpad('abcd',3,'12');
rpad('a',4,'1') rpad('a',4,'12') rpad('abcd',3,'12')
a111 a121 abc
select lpad('a',4,'1'),lpad('a',4,'12'),lpad('abcd',3,'12');
lpad('a',4,'1') lpad('a',4,'12') lpad('abcd',3,'12')
111a 121a abc
select rpad('a',4,'1'),rpad('a',4,'12'),rpad('abcd',3,'12')
, rpad(11, 10 , 22), rpad("ab", 10, 22)
;
rpad('a',4,'1') rpad('a',4,'12') rpad('abcd',3,'12')
rpad(11, 10 , 22) rpad("ab", 10, 22)
a111 a121 abc
1122222222 ab22222222
select lpad('a',4,'1'),lpad('a',4,'12'),lpad('abcd',3,'12')
, lpad(11, 10 , 22)
;
lpad('a',4,'1') lpad('a',4,'12') lpad('abcd',3,'12')
lpad(11, 10 , 22)
111a 121a abc
2222222211
select rpad(741653838,17,'0'),lpad(741653838,17,'0');
rpad(741653838,17,'0') lpad(741653838,17,'0')
74165383800000000 00000000741653838
...
...
@@ -134,6 +134,12 @@ abcdaba abaabcd
select rpad('abcd',1,'ab'),lpad('abcd',1,'ab');
rpad('abcd',1,'ab') lpad('abcd',1,'ab')
a a
select rpad('STRING', 20, CONCAT('p','a','d') );
rpad('STRING', 20, CONCAT('p','a','d') )
STRINGpadpadpadpadpa
select lpad('STRING', 20, CONCAT('p','a','d') );
lpad('STRING', 20, CONCAT('p','a','d') )
padpadpadpadpaSTRING
select LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'),GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD');
LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD') GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD')
HAROLD HARRY
...
...
mysql-test/t/func_str.test
View file @
c2b60a6f
...
...
@@ -49,11 +49,13 @@ select aes_decrypt("a","a");
select
aes_decrypt
(
aes_encrypt
(
""
,
"a"
),
"a"
);
select
repeat
(
'monty'
,
5
),
concat
(
'*'
,
space
(
5
),
'*'
);
select
reverse
(
'abc'
),
reverse
(
'abcd'
);
select
rpad
(
'a'
,
4
,
'1'
),
rpad
(
'a'
,
4
,
'12'
),
rpad
(
'abcd'
,
3
,
'12'
);
select
lpad
(
'a'
,
4
,
'1'
),
lpad
(
'a'
,
4
,
'12'
),
lpad
(
'abcd'
,
3
,
'12'
);
select
rpad
(
'a'
,
4
,
'1'
),
rpad
(
'a'
,
4
,
'12'
),
rpad
(
'abcd'
,
3
,
'12'
)
,
rpad
(
11
,
10
,
22
),
rpad
(
"ab"
,
10
,
22
)
;
select
lpad
(
'a'
,
4
,
'1'
),
lpad
(
'a'
,
4
,
'12'
),
lpad
(
'abcd'
,
3
,
'12'
)
,
lpad
(
11
,
10
,
22
)
;
select
rpad
(
741653838
,
17
,
'0'
),
lpad
(
741653838
,
17
,
'0'
);
select
rpad
(
'abcd'
,
7
,
'ab'
),
lpad
(
'abcd'
,
7
,
'ab'
);
select
rpad
(
'abcd'
,
1
,
'ab'
),
lpad
(
'abcd'
,
1
,
'ab'
);
select
rpad
(
'STRING'
,
20
,
CONCAT
(
'p'
,
'a'
,
'd'
)
);
select
lpad
(
'STRING'
,
20
,
CONCAT
(
'p'
,
'a'
,
'd'
)
);
select
LEAST
(
NULL
,
'HARRY'
,
'HARRIOT'
,
NULL
,
'HAROLD'
),
GREATEST
(
NULL
,
'HARRY'
,
'HARRIOT'
,
NULL
,
'HAROLD'
);
select
least
(
1
,
2
,
3
)
|
greatest
(
16
,
32
,
8
),
least
(
5
,
4
)
*
1
,
greatest
(
-
1.0
,
1.0
)
*
1
,
least
(
3
,
2
,
1
)
*
1.0
,
greatest
(
1
,
1.1
,
1.0
),
least
(
"10"
,
9
),
greatest
(
"A"
,
"B"
,
"0"
);
...
...
sql/item_strfunc.cc
View file @
c2b60a6f
...
...
@@ -1806,7 +1806,7 @@ String *Item_func_rpad::val_str(String *str)
const
char
*
ptr_pad
;
int32
count
=
(
int32
)
args
[
1
]
->
val_int
();
String
*
res
=
args
[
0
]
->
val_str
(
str
);
String
*
rpad
=
args
[
2
]
->
val_str
(
str
);
String
*
rpad
=
args
[
2
]
->
val_str
(
&
rpad_
str
);
if
(
!
res
||
args
[
1
]
->
null_value
||
!
rpad
||
count
<
0
)
goto
err
;
...
...
@@ -1866,7 +1866,7 @@ String *Item_func_lpad::val_str(String *str)
const
char
*
ptr_pad
;
ulong
count
=
(
long
)
args
[
1
]
->
val_int
();
String
*
res
=
args
[
0
]
->
val_str
(
str
);
String
*
lpad
=
args
[
2
]
->
val_str
(
str
);
String
*
lpad
=
args
[
2
]
->
val_str
(
&
lpad_
str
);
if
(
!
res
||
args
[
1
]
->
null_value
||
!
lpad
)
goto
err
;
...
...
sql/item_strfunc.h
View file @
c2b60a6f
...
...
@@ -436,7 +436,7 @@ class Item_func_repeat :public Item_str_func
class
Item_func_rpad
:
public
Item_str_func
{
String
tmp_value
;
String
tmp_value
,
rpad_str
;
public:
Item_func_rpad
(
Item
*
arg1
,
Item
*
arg2
,
Item
*
arg3
)
:
Item_str_func
(
arg1
,
arg2
,
arg3
)
{}
...
...
@@ -449,7 +449,7 @@ class Item_func_rpad :public Item_str_func
class
Item_func_lpad
:
public
Item_str_func
{
String
tmp_value
;
String
tmp_value
,
lpad_str
;
public:
Item_func_lpad
(
Item
*
arg1
,
Item
*
arg2
,
Item
*
arg3
)
:
Item_str_func
(
arg1
,
arg2
,
arg3
)
{}
...
...
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