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
e81be028
Commit
e81be028
authored
Jun 17, 2007
by
igor@olga.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge olga.mysql.com:/home/igor/mysql-5.0-opt
into olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug27130
parents
dac7ce2d
63ab9109
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
2 deletions
+33
-2
mysql-test/r/func_str.result
mysql-test/r/func_str.result
+15
-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 @
e81be028
...
...
@@ -2137,4 +2137,19 @@ id
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 @
e81be028
...
...
@@ -1109,4 +1109,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 @
e81be028
...
...
@@ -1145,8 +1145,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