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
12c13e7d
Commit
12c13e7d
authored
Jun 18, 2007
by
gshchepa/uchum@gleb.loc
Browse files
Options
Browse Files
Download
Plain Diff
Merge gleb.loc:/home/uchum/work/bk/5.0-opt
into gleb.loc:/home/uchum/work/bk/5.1-opt
parents
6fc62a8e
c27988f9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
2 deletions
+34
-2
mysql-test/r/func_str.result
mysql-test/r/func_str.result
+16
-0
mysql-test/t/func_str.test
mysql-test/t/func_str.test
+15
-0
sql/item_strfunc.cc
sql/item_strfunc.cc
+3
-2
No files found.
mysql-test/r/func_str.result
View file @
12c13e7d
...
...
@@ -2469,5 +2469,21 @@ id
2
3
4
DROP TABLE t1;
SELECT SUBSTR('foo',1,0) FROM DUAL;
SUBSTR('foo',1,0)
SELECT SUBSTR('foo',1,CAST(0 AS SIGNED)) FROM DUAL;
SUBSTR('foo',1,CAST(0 AS SIGNED))
SELECT SUBSTR('foo',1,CAST(0 AS UNSIGNED)) FROM DUAL;
SUBSTR('foo',1,CAST(0 AS UNSIGNED))
CREATE TABLE t1 (a varchar(10), len int unsigned);
INSERT INTO t1 VALUES ('bar', 2), ('foo', 0);
SELECT SUBSTR(a,1,len) FROM t1;
SUBSTR(a,1,len)
ba
DROP TABLE t1;
End of 5.0 tests
mysql-test/t/func_str.test
View file @
12c13e7d
...
...
@@ -1216,4 +1216,19 @@ SELECT id FROM t1 WHERE LOCATE(a,p) <=> NULL;
DROP
TABLE
t1
;
#
# Bug #27130: SUBSTR with UNSIGNED 0 as the last argument
#
SELECT
SUBSTR
(
'foo'
,
1
,
0
)
FROM
DUAL
;
SELECT
SUBSTR
(
'foo'
,
1
,
CAST
(
0
AS
SIGNED
))
FROM
DUAL
;
SELECT
SUBSTR
(
'foo'
,
1
,
CAST
(
0
AS
UNSIGNED
))
FROM
DUAL
;
CREATE
TABLE
t1
(
a
varchar
(
10
),
len
int
unsigned
);
INSERT
INTO
t1
VALUES
(
'bar'
,
2
),
(
'foo'
,
0
);
SELECT
SUBSTR
(
a
,
1
,
len
)
FROM
t1
;
DROP
TABLE
t1
;
--
echo
End
of
5.0
tests
sql/item_strfunc.cc
View file @
12c13e7d
...
...
@@ -1143,8 +1143,9 @@ String *Item_func_substr::val_str(String *str)
(
arg_count
==
3
&&
args
[
2
]
->
null_value
))))
return
0
;
/* purecov: inspected */
/* Negative length, will return empty string. */
if
((
arg_count
==
3
)
&&
(
length
<=
0
)
&&
!
args
[
2
]
->
unsigned_flag
)
/* Negative or zero length, will return empty string. */
if
((
arg_count
==
3
)
&&
(
length
<=
0
)
&&
(
length
==
0
||
!
args
[
2
]
->
unsigned_flag
))
return
&
my_empty_string
;
/* Assumes that the maximum length of a String is < INT_MAX32. */
...
...
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