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
74ef77fd
Commit
74ef77fd
authored
Jul 14, 2003
by
venu@myvenu.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge venu@bk-internal.mysql.com:/home/bk/mysql-4.1
into myvenu.com:/home/venu/work/sql/dev-4.1
parents
e26b90c2
f4518cdc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
1 deletion
+35
-1
mysql-test/r/func_str.result
mysql-test/r/func_str.result
+21
-0
mysql-test/t/func_str.test
mysql-test/t/func_str.test
+11
-0
sql/item_strfunc.cc
sql/item_strfunc.cc
+2
-1
sql/lex.h
sql/lex.h
+1
-0
No files found.
mysql-test/r/func_str.result
View file @
74ef77fd
...
...
@@ -532,3 +532,24 @@ t1 CREATE TABLE `t1` (
`replace(_latin2'abcd',_latin2'b',_latin2'B')` char(4) character set latin2 NOT NULL default ''
) TYPE=MyISAM CHARSET=latin1
drop table t1;
select SUBSTR('abcdefg',3,2);
SUBSTR('abcdefg',3,2)
cd
select SUBSTRING('abcdefg',3,2);
SUBSTRING('abcdefg',3,2)
cd
select SUBSTR('abcdefg',-3,2) FROM DUAL;
SUBSTR('abcdefg',-3,2)
ef
select SUBSTR('abcdefg',-1,5) FROM DUAL;
SUBSTR('abcdefg',-1,5)
g
select SUBSTR('abcdefg',0,0) FROM DUAL;
SUBSTR('abcdefg',0,0)
select SUBSTR('abcdefg',-1,-1) FROM DUAL;
SUBSTR('abcdefg',-1,-1)
select SUBSTR('abcdefg',1,-1) FROM DUAL;
SUBSTR('abcdefg',1,-1)
mysql-test/t/func_str.test
View file @
74ef77fd
...
...
@@ -294,3 +294,14 @@ select
;
show
create
table
t1
;
drop
table
t1
;
#
# test for SUBSTR
#
select
SUBSTR
(
'abcdefg'
,
3
,
2
);
select
SUBSTRING
(
'abcdefg'
,
3
,
2
);
select
SUBSTR
(
'abcdefg'
,
-
3
,
2
)
FROM
DUAL
;
select
SUBSTR
(
'abcdefg'
,
-
1
,
5
)
FROM
DUAL
;
select
SUBSTR
(
'abcdefg'
,
0
,
0
)
FROM
DUAL
;
select
SUBSTR
(
'abcdefg'
,
-
1
,
-
1
)
FROM
DUAL
;
select
SUBSTR
(
'abcdefg'
,
1
,
-
1
)
FROM
DUAL
;
sql/item_strfunc.cc
View file @
74ef77fd
...
...
@@ -979,13 +979,14 @@ void Item_func_right::fix_length_and_dec()
String
*
Item_func_substr
::
val_str
(
String
*
str
)
{
String
*
res
=
args
[
0
]
->
val_str
(
str
);
int32
start
=
(
int32
)
args
[
1
]
->
val_int
()
-
1
;
int32
start
=
(
int32
)
args
[
1
]
->
val_int
();
int32
length
=
arg_count
==
3
?
(
int32
)
args
[
2
]
->
val_int
()
:
INT_MAX32
;
int32
tmp_length
;
if
((
null_value
=
(
args
[
0
]
->
null_value
||
args
[
1
]
->
null_value
||
(
arg_count
==
3
&&
args
[
2
]
->
null_value
))))
return
0
;
/* purecov: inspected */
start
=
(
int32
)((
start
<
0
)
?
res
->
length
()
+
start
:
start
-
1
);
start
=
res
->
charpos
(
start
);
length
=
res
->
charpos
(
length
,
start
);
if
(
start
<
0
||
(
uint
)
start
+
1
>
res
->
length
()
||
length
<=
0
)
...
...
sql/lex.h
View file @
74ef77fd
...
...
@@ -627,6 +627,7 @@ static SYMBOL sql_functions[] = {
{
"STD"
,
SYM
(
STD_SYM
),
0
,
0
},
{
"STDDEV"
,
SYM
(
STD_SYM
),
0
,
0
},
{
"STRCMP"
,
SYM
(
FUNC_ARG2
),
0
,
CREATE_FUNC
(
create_func_strcmp
)},
{
"SUBSTR"
,
SYM
(
SUBSTRING
),
0
,
0
},
{
"SUBSTRING"
,
SYM
(
SUBSTRING
),
0
,
0
},
{
"SUBSTRING_INDEX"
,
SYM
(
SUBSTRING_INDEX
),
0
,
0
},
{
"SUBTIME"
,
SYM
(
FUNC_ARG2
),
0
,
CREATE_FUNC
(
create_func_subtime
)},
...
...
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