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
154ec0f4
Commit
154ec0f4
authored
Nov 19, 2014
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-6993 Bad results with join comparing DECIMAL and ENUM/SET columns
parent
55dd89e9
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
0 deletions
+114
-0
mysql-test/r/type_enum.result
mysql-test/r/type_enum.result
+34
-0
mysql-test/r/type_set.result
mysql-test/r/type_set.result
+34
-0
mysql-test/t/type_enum.test
mysql-test/t/type_enum.test
+21
-0
mysql-test/t/type_set.test
mysql-test/t/type_set.test
+21
-0
sql/field_conv.cc
sql/field_conv.cc
+4
-0
No files found.
mysql-test/r/type_enum.result
View file @
154ec0f4
...
...
@@ -2046,5 +2046,39 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL id 6 NULL 16 Using where; Using index
DROP TABLE t1;
#
# MDEV-6993 Bad results with join comparing DECIMAL and ENUM/SET columns
#
CREATE TABLE t1 (c1 DECIMAL(10,1) PRIMARY KEY);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (c1 ENUM('a','b'));
INSERT INTO t2 VALUES ('a'),('b');
SELECT t1.* FROM t1 NATURAL JOIN t2;
c1
1.0
2.0
ALTER TABLE t2 ADD PRIMARY KEY(c1);
SELECT t1.* FROM t1 NATURAL JOIN t2;
c1
1.0
2.0
SELECT t1.* FROM t1 LEFT OUTER JOIN t2 USING (c1);
c1
1.0
2.0
DROP TABLE t1,t2;
CREATE TABLE t1 (a DECIMAL(10,1), b ENUM('1','2'));
INSERT INTO t1 (a) VALUES (1),(2);
UPDATE t1 SET b=a;
SELECT * FROM t1;
a b
1.0 1
2.0 2
ALTER TABLE t1 MODIFY a ENUM('1','2');
SELECT * FROM t1;
a b
1 1
2 2
DROP TABLE t1;
#
# End of 10.0 tests
#
...
...
mysql-test/r/type_set.result
View file @
154ec0f4
...
...
@@ -227,5 +227,39 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index PRIMARY PRIMARY 1 NULL 2 Using where; Using index
DROP TABLE IF EXISTS t1,t2;
#
# MDEV-6993 Bad results with join comparing DECIMAL and ENUM/SET columns
#
CREATE TABLE t1 (c1 DECIMAL(10,1) PRIMARY KEY);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (c1 SET('a','b'));
INSERT INTO t2 VALUES ('a'),('b');
SELECT t1.* FROM t1 NATURAL JOIN t2;
c1
1.0
2.0
ALTER TABLE t2 ADD PRIMARY KEY(c1);
SELECT t1.* FROM t1 NATURAL JOIN t2;
c1
1.0
2.0
SELECT t1.* FROM t1 LEFT OUTER JOIN t2 USING (c1);
c1
1.0
2.0
DROP TABLE t1,t2;
CREATE TABLE t1 (a DECIMAL(10,1), b SET('1','2'));
INSERT INTO t1 (a) VALUES (1),(2);
UPDATE t1 SET b=a;
SELECT * FROM t1;
a b
1.0 1
2.0 2
ALTER TABLE t1 MODIFY a SET('1','2');
SELECT * FROM t1;
a b
1 1
2 2
DROP TABLE t1;
#
# End of 10.0 tests
#
mysql-test/t/type_enum.test
View file @
154ec0f4
...
...
@@ -333,6 +333,27 @@ SELECT id,MIN(a),MAX(a) FROM t1 WHERE a<=3 GROUP BY id;
EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a<=3 GROUP BY id;
DROP TABLE t1;
--echo #
--echo # MDEV-6993 Bad results with join comparing DECIMAL and ENUM/SET columns
--echo #
CREATE TABLE t1 (c1 DECIMAL(10,1) PRIMARY KEY);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (c1 ENUM('
a
','
b
'));
INSERT INTO t2 VALUES ('
a
'),('
b
');
SELECT t1.* FROM t1 NATURAL JOIN t2;
ALTER TABLE t2 ADD PRIMARY KEY(c1);
SELECT t1.* FROM t1 NATURAL JOIN t2;
SELECT t1.* FROM t1 LEFT OUTER JOIN t2 USING (c1);
DROP TABLE t1,t2;
CREATE TABLE t1 (a DECIMAL(10,1), b ENUM('
1
','
2
'));
INSERT INTO t1 (a) VALUES (1),(2);
UPDATE t1 SET b=a;
SELECT * FROM t1;
ALTER TABLE t1 MODIFY a ENUM('
1
','
2
'
);
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# End of 10.0 tests
--
echo
#
...
...
mysql-test/t/type_set.test
View file @
154ec0f4
...
...
@@ -161,6 +161,27 @@ SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1;
EXPLAIN
SELECT
t1
.*
FROM
t1
LEFT
JOIN
t2
ON
t1
.
c1
COLLATE
latin1_swedish_ci
=
t2
.
c1
;
DROP
TABLE
IF
EXISTS
t1
,
t2
;
--
echo
#
--
echo
# MDEV-6993 Bad results with join comparing DECIMAL and ENUM/SET columns
--
echo
#
CREATE
TABLE
t1
(
c1
DECIMAL
(
10
,
1
)
PRIMARY
KEY
);
INSERT
INTO
t1
VALUES
(
1
),(
2
);
CREATE
TABLE
t2
(
c1
SET
(
'a'
,
'b'
));
INSERT
INTO
t2
VALUES
(
'a'
),(
'b'
);
SELECT
t1
.*
FROM
t1
NATURAL
JOIN
t2
;
ALTER
TABLE
t2
ADD
PRIMARY
KEY
(
c1
);
SELECT
t1
.*
FROM
t1
NATURAL
JOIN
t2
;
SELECT
t1
.*
FROM
t1
LEFT
OUTER
JOIN
t2
USING
(
c1
);
DROP
TABLE
t1
,
t2
;
CREATE
TABLE
t1
(
a
DECIMAL
(
10
,
1
),
b
SET
(
'1'
,
'2'
));
INSERT
INTO
t1
(
a
)
VALUES
(
1
),(
2
);
UPDATE
t1
SET
b
=
a
;
SELECT
*
FROM
t1
;
ALTER
TABLE
t1
MODIFY
a
SET
(
'1'
,
'2'
);
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# End of 10.0 tests
--
echo
#
sql/field_conv.cc
View file @
154ec0f4
...
...
@@ -792,6 +792,10 @@ Copy_field::get_copy_func(Field *to,Field *from)
else
if
(
to
->
real_type
()
!=
from
->
real_type
()
||
to_length
!=
from_length
)
{
if
((
to
->
real_type
()
==
MYSQL_TYPE_ENUM
||
to
->
real_type
()
==
MYSQL_TYPE_SET
)
&&
from
->
real_type
()
==
MYSQL_TYPE_NEWDECIMAL
)
return
do_field_decimal
;
if
(
to
->
real_type
()
==
MYSQL_TYPE_DECIMAL
||
to
->
result_type
()
==
STRING_RESULT
)
return
do_field_string
;
...
...
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