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
1081e403
Commit
1081e403
authored
Apr 28, 2014
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-5702 Incorrect results are returned with NULLIF()
parent
968f4d4e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
97 additions
and
1 deletion
+97
-1
mysql-test/include/ctype_numconv.inc
mysql-test/include/ctype_numconv.inc
+11
-0
mysql-test/r/ctype_binary.result
mysql-test/r/ctype_binary.result
+17
-0
mysql-test/r/ctype_cp1251.result
mysql-test/r/ctype_cp1251.result
+17
-0
mysql-test/r/ctype_latin1.result
mysql-test/r/ctype_latin1.result
+17
-0
mysql-test/r/ctype_ucs.result
mysql-test/r/ctype_ucs.result
+17
-0
mysql-test/r/ctype_utf8.result
mysql-test/r/ctype_utf8.result
+17
-0
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+1
-1
No files found.
mysql-test/include/ctype_numconv.inc
View file @
1081e403
...
...
@@ -1794,6 +1794,17 @@ SELECT f1() FROM t1 LEFT JOIN (SELECT 1 AS a FROM t1 LIMIT 0) AS d ON 1 GROUP BY
DROP
FUNCTION
f1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# MDEV-5702 Incorrect results are returned with NULLIF()
--
echo
#
CREATE
TABLE
t1
(
d
DATE
);
INSERT
INTO
t1
VALUES
(
'1999-11-11'
),(
'2014-02-04'
);
SELECT
DISTINCT
d
,
CAST
(
d
AS
CHAR
),
NULLIF
(
d
,
"2000-01-01"
)
AS
bad
,
NULLIF
(
CAST
(
d
AS
CHAR
),
"2000-01-01"
)
AS
good
FROM
t1
;
CREATE
TABLE
t2
AS
SELECT
DISTINCT
d
,
NULLIF
(
d
,
'2000-01-01'
)
AS
bad
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t1
,
t2
;
SET
NAMES
latin1
;
SET
sql_mode
=
''
;
CREATE
TABLE
t1
(
a
char
(
215
)
CHARACTER
SET
utf8
NOT
NULL
DEFAULT
''
,
KEY
(
a
));
...
...
mysql-test/r/ctype_binary.result
View file @
1081e403
...
...
@@ -2848,6 +2848,23 @@ f1()
00:00:01
DROP FUNCTION f1;
DROP TABLE t1;
#
# MDEV-5702 Incorrect results are returned with NULLIF()
#
CREATE TABLE t1 (d DATE);
INSERT INTO t1 VALUES ('1999-11-11'),('2014-02-04');
SELECT DISTINCT d, CAST(d AS CHAR), NULLIF(d,"2000-01-01") AS bad, NULLIF(CAST(d AS CHAR),"2000-01-01") AS good FROM t1;
d CAST(d AS CHAR) bad good
1999-11-11 1999-11-11 1999-11-11 1999-11-11
2014-02-04 2014-02-04 2014-02-04 2014-02-04
CREATE TABLE t2 AS SELECT DISTINCT d, NULLIF(d,'2000-01-01') AS bad FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`d` date DEFAULT NULL,
`bad` varbinary(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1, t2;
SET NAMES latin1;
SET sql_mode='';
CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a));
...
...
mysql-test/r/ctype_cp1251.result
View file @
1081e403
...
...
@@ -3240,6 +3240,23 @@ f1()
00:00:01
DROP FUNCTION f1;
DROP TABLE t1;
#
# MDEV-5702 Incorrect results are returned with NULLIF()
#
CREATE TABLE t1 (d DATE);
INSERT INTO t1 VALUES ('1999-11-11'),('2014-02-04');
SELECT DISTINCT d, CAST(d AS CHAR), NULLIF(d,"2000-01-01") AS bad, NULLIF(CAST(d AS CHAR),"2000-01-01") AS good FROM t1;
d CAST(d AS CHAR) bad good
1999-11-11 1999-11-11 1999-11-11 1999-11-11
2014-02-04 2014-02-04 2014-02-04 2014-02-04
CREATE TABLE t2 AS SELECT DISTINCT d, NULLIF(d,'2000-01-01') AS bad FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`d` date DEFAULT NULL,
`bad` varchar(10) CHARACTER SET cp1251 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1, t2;
SET NAMES latin1;
SET sql_mode='';
CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a));
...
...
mysql-test/r/ctype_latin1.result
View file @
1081e403
...
...
@@ -3422,6 +3422,23 @@ f1()
00:00:01
DROP FUNCTION f1;
DROP TABLE t1;
#
# MDEV-5702 Incorrect results are returned with NULLIF()
#
CREATE TABLE t1 (d DATE);
INSERT INTO t1 VALUES ('1999-11-11'),('2014-02-04');
SELECT DISTINCT d, CAST(d AS CHAR), NULLIF(d,"2000-01-01") AS bad, NULLIF(CAST(d AS CHAR),"2000-01-01") AS good FROM t1;
d CAST(d AS CHAR) bad good
1999-11-11 1999-11-11 1999-11-11 1999-11-11
2014-02-04 2014-02-04 2014-02-04 2014-02-04
CREATE TABLE t2 AS SELECT DISTINCT d, NULLIF(d,'2000-01-01') AS bad FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`d` date DEFAULT NULL,
`bad` varchar(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1, t2;
SET NAMES latin1;
SET sql_mode='';
CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a));
...
...
mysql-test/r/ctype_ucs.result
View file @
1081e403
...
...
@@ -4238,6 +4238,23 @@ f1()
00:00:01
DROP FUNCTION f1;
DROP TABLE t1;
#
# MDEV-5702 Incorrect results are returned with NULLIF()
#
CREATE TABLE t1 (d DATE);
INSERT INTO t1 VALUES ('1999-11-11'),('2014-02-04');
SELECT DISTINCT d, CAST(d AS CHAR), NULLIF(d,"2000-01-01") AS bad, NULLIF(CAST(d AS CHAR),"2000-01-01") AS good FROM t1;
d CAST(d AS CHAR) bad good
1999-11-11 1999-11-11 1999-11-11 1999-11-11
2014-02-04 2014-02-04 2014-02-04 2014-02-04
CREATE TABLE t2 AS SELECT DISTINCT d, NULLIF(d,'2000-01-01') AS bad FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`d` date DEFAULT NULL,
`bad` varchar(10) CHARACTER SET ucs2 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1, t2;
SET NAMES latin1;
SET sql_mode='';
CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a));
...
...
mysql-test/r/ctype_utf8.result
View file @
1081e403
...
...
@@ -5059,6 +5059,23 @@ f1()
00:00:01
DROP FUNCTION f1;
DROP TABLE t1;
#
# MDEV-5702 Incorrect results are returned with NULLIF()
#
CREATE TABLE t1 (d DATE);
INSERT INTO t1 VALUES ('1999-11-11'),('2014-02-04');
SELECT DISTINCT d, CAST(d AS CHAR), NULLIF(d,"2000-01-01") AS bad, NULLIF(CAST(d AS CHAR),"2000-01-01") AS good FROM t1;
d CAST(d AS CHAR) bad good
1999-11-11 1999-11-11 1999-11-11 1999-11-11
2014-02-04 2014-02-04 2014-02-04 2014-02-04
CREATE TABLE t2 AS SELECT DISTINCT d, NULLIF(d,'2000-01-01') AS bad FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`d` date DEFAULT NULL,
`bad` varchar(10) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1, t2;
SET NAMES latin1;
SET sql_mode='';
CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a));
...
...
sql/item_cmpfunc.cc
View file @
1081e403
...
...
@@ -2723,13 +2723,13 @@ Item_func_nullif::fix_length_and_dec()
maybe_null
=
1
;
if
(
args
[
0
])
// Only false if EOM
{
max_length
=
args
[
0
]
->
max_length
;
decimals
=
args
[
0
]
->
decimals
;
unsigned_flag
=
args
[
0
]
->
unsigned_flag
;
cached_result_type
=
args
[
0
]
->
result_type
();
if
(
cached_result_type
==
STRING_RESULT
&&
agg_arg_charsets_for_comparison
(
collation
,
args
,
arg_count
))
return
;
fix_char_length
(
args
[
0
]
->
max_char_length
());
}
}
...
...
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