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
bf7a2bb1
Commit
bf7a2bb1
authored
Sep 07, 2015
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-8704 Wrong result for SELECT..WHERE LENGTH(double_column)!=6 AND double_column=100e0
parent
5448e0a6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
183 additions
and
0 deletions
+183
-0
mysql-test/r/type_float.result
mysql-test/r/type_float.result
+95
-0
mysql-test/t/type_float.test
mysql-test/t/type_float.test
+64
-0
sql/field.cc
sql/field.cc
+22
-0
sql/field.h
sql/field.h
+2
-0
No files found.
mysql-test/r/type_float.result
View file @
bf7a2bb1
...
...
@@ -532,3 +532,98 @@ DROP TABLE t1,t2;
#
# End of 10.0 tests
#
#
# MDEV-8704 Wrong result for SELECT..WHERE LENGTH(double_column)!=6 AND double_column=100e0
#
CREATE TABLE t1 (a DOUBLE(9,2));
INSERT INTO t1 VALUES (100),(110);
SELECT * FROM t1 WHERE LENGTH(a)!=6;
a
SELECT * FROM t1 WHERE LENGTH(a)!=6 AND a=100e0;
a
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE);
INSERT INTO t1 VALUES (100),(110);
SELECT * FROM t1 WHERE LENGTH(a)!=6;
a
100
110
SELECT * FROM t1 WHERE LENGTH(a)!=6 AND a=100e0;
a
100
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE LENGTH(a)!=6 AND a=100e0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 100e0)
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE LENGTH(a)!=RAND() AND a=100e0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 100e0) and (<cache>(length(100)) <> rand()))
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE(10,1));
INSERT INTO t1 VALUES (1.1),(1.2),(1.3);
SELECT * FROM t1 WHERE LENGTH(a)!=3;
a
SELECT * FROM t1 WHERE LENGTH(a)!=3 AND a=1.10e0;
a
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE LENGTH(a)!=3 AND a=1.10e0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 0
# Notice 1.1 instead of 1.10 in the final WHERE condition
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE LENGTH(a)!=RAND() AND a=1.10e0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 1.10e0) and (<cache>(length(1.1)) <> rand()))
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE(10,2));
INSERT INTO t1 VALUES (1.1),(1.2),(1.3);
SELECT * FROM t1 WHERE LENGTH(a)!=4;
a
SELECT * FROM t1 WHERE LENGTH(a)!=4 AND a=1.10e0;
a
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE LENGTH(a)!=4 AND a=1.10e0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 0
# Notice 1.10 in the final WHERE condition
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE LENGTH(a)!=RAND() AND a=1.10e0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 1.10e0) and (<cache>(length(1.10)) <> rand()))
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE(10,3));
INSERT INTO t1 VALUES (1.1),(1.2),(1.3);
SELECT * FROM t1 WHERE LENGTH(a)!=5;
a
SELECT * FROM t1 WHERE LENGTH(a)!=5 AND a=1.10e0;
a
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE LENGTH(a)!=5 AND a=1.10e0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 0
# Notice 1.100 rather than 1.10 in the final WHERE condition
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE LENGTH(a)!=RAND() AND a=1.10e0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 1.10e0) and (<cache>(length(1.100)) <> rand()))
DROP TABLE t1;
#
# End of 10.1 tests
#
mysql-test/t/type_float.test
View file @
bf7a2bb1
...
...
@@ -385,3 +385,67 @@ DROP TABLE t1,t2;
--
echo
#
--
echo
# End of 10.0 tests
--
echo
#
--
echo
#
--
echo
# MDEV-8704 Wrong result for SELECT..WHERE LENGTH(double_column)!=6 AND double_column=100e0
--
echo
#
# The original test case from the bug report
CREATE
TABLE
t1
(
a
DOUBLE
(
9
,
2
));
INSERT
INTO
t1
VALUES
(
100
),(
110
);
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
6
;
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
6
AND
a
=
100
e0
;
DROP
TABLE
t1
;
# DOUBLE with no specific precision
CREATE
TABLE
t1
(
a
DOUBLE
);
INSERT
INTO
t1
VALUES
(
100
),(
110
);
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
6
;
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
6
AND
a
=
100
e0
;
EXPLAIN
EXTENDED
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
6
AND
a
=
100
e0
;
EXPLAIN
EXTENDED
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
RAND
()
AND
a
=
100
e0
;
DROP
TABLE
t1
;
# The constant scale is bigger than the field scale
CREATE
TABLE
t1
(
a
DOUBLE
(
10
,
1
));
INSERT
INTO
t1
VALUES
(
1.1
),(
1.2
),(
1.3
);
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
3
;
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
3
AND
a
=
1.10e0
;
EXPLAIN
EXTENDED
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
3
AND
a
=
1.10e0
;
--
echo
# Notice 1.1 instead of 1.10 in the final WHERE condition
EXPLAIN
EXTENDED
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
RAND
()
AND
a
=
1.10e0
;
DROP
TABLE
t1
;
# The constant scale is equal to the field scale
CREATE
TABLE
t1
(
a
DOUBLE
(
10
,
2
));
INSERT
INTO
t1
VALUES
(
1.1
),(
1.2
),(
1.3
);
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
4
;
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
4
AND
a
=
1.10e0
;
EXPLAIN
EXTENDED
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
4
AND
a
=
1.10e0
;
--
echo
# Notice 1.10 in the final WHERE condition
EXPLAIN
EXTENDED
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
RAND
()
AND
a
=
1.10e0
;
DROP
TABLE
t1
;
# The constant scale is smaller than the field scale
CREATE
TABLE
t1
(
a
DOUBLE
(
10
,
3
));
INSERT
INTO
t1
VALUES
(
1.1
),(
1.2
),(
1.3
);
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
5
;
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
5
AND
a
=
1.10e0
;
EXPLAIN
EXTENDED
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
5
AND
a
=
1.10e0
;
--
echo
# Notice 1.100 rather than 1.10 in the final WHERE condition
EXPLAIN
EXTENDED
SELECT
*
FROM
t1
WHERE
LENGTH
(
a
)
!=
RAND
()
AND
a
=
1.10e0
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# End of 10.1 tests
--
echo
#
sql/field.cc
View file @
bf7a2bb1
...
...
@@ -4639,6 +4639,28 @@ bool Field_real::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
}
Item
*
Field_real
::
get_equal_const_item
(
THD
*
thd
,
const
Context
&
ctx
,
Item_field
*
field_item
,
Item
*
const_item
)
{
if
(
flags
&
ZEROFILL_FLAG
)
return
Field_num
::
get_equal_zerofill_const_item
(
thd
,
ctx
,
field_item
,
const_item
);
switch
(
ctx
.
subst_constraint
())
{
case
IDENTITY_SUBST
:
if
(
const_item
->
decimal_scale
()
!=
Field_real
::
decimals
())
{
double
val
=
const_item
->
val_real
();
return
new
(
thd
->
mem_root
)
Item_float
(
thd
,
val
,
Field_real
::
decimals
());
}
break
;
case
ANY_SUBST
:
break
;
}
return
const_item
;
}
String
*
Field_double
::
val_str
(
String
*
val_buffer
,
String
*
val_ptr
__attribute__
((
unused
)))
{
...
...
sql/field.h
View file @
bf7a2bb1
...
...
@@ -1363,6 +1363,8 @@ public:
my_decimal
*
val_decimal
(
my_decimal
*
);
uint32
max_display_length
()
{
return
field_length
;
}
uint
size_of
()
const
{
return
sizeof
(
*
this
);
}
Item
*
get_equal_const_item
(
THD
*
thd
,
const
Context
&
ctx
,
Item_field
*
field_item
,
Item
*
const_item
);
};
...
...
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