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
e9f171b4
Commit
e9f171b4
authored
Nov 20, 2021
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-27098 Subquery using the ALL keyword on TIME columns produces a wrong result
parent
7efcc279
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
2 deletions
+46
-2
mysql-test/r/type_time.result
mysql-test/r/type_time.result
+12
-0
mysql-test/t/type_time.test
mysql-test/t/type_time.test
+10
-0
sql/sql_class.cc
sql/sql_class.cc
+23
-2
sql/sql_class.h
sql/sql_class.h
+1
-0
No files found.
mysql-test/r/type_time.result
View file @
e9f171b4
...
@@ -1368,5 +1368,17 @@ Warning 1292 Incorrect datetime value: '1995.0000000'
...
@@ -1368,5 +1368,17 @@ Warning 1292 Incorrect datetime value: '1995.0000000'
Note 1003 select `test`.`t1`.`f` AS `f` from `test`.`t1` where '00:00:00.000000' between `test`.`t1`.`f` and <cache>('23:59:59')
Note 1003 select `test`.`t1`.`f` AS `f` from `test`.`t1` where '00:00:00.000000' between `test`.`t1`.`f` and <cache>('23:59:59')
DROP TABLE t1;
DROP TABLE t1;
#
#
# MDEV-27098 Subquery using the ALL keyword on TIME columns produces a wrong result
#
CREATE TABLE t1 (d TIME);
INSERT INTO t1 VALUES ('120:00:00'), ('20:00:00'), ('-120:00:00'), ('-220:00:00');
SELECT * FROM t1 WHERE d >= ALL (SELECT * FROM t1);
d
120:00:00
SELECT * FROM t1 WHERE d <= ALL (SELECT * FROM t1);
d
-220:00:00
DROP TABLE t1;
#
# End of 10.2 tests
# End of 10.2 tests
#
#
mysql-test/t/type_time.test
View file @
e9f171b4
...
@@ -823,6 +823,16 @@ INSERT INTO t1 VALUES ('10:10:10'),('20:20:20');
...
@@ -823,6 +823,16 @@ INSERT INTO t1 VALUES ('10:10:10'),('20:20:20');
EXPLAIN
EXTENDED
SELECT
*
FROM
t1
WHERE
1995.0000000
BETWEEN
f
AND
'23:59:59'
;
EXPLAIN
EXTENDED
SELECT
*
FROM
t1
WHERE
1995.0000000
BETWEEN
f
AND
'23:59:59'
;
DROP
TABLE
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# MDEV-27098 Subquery using the ALL keyword on TIME columns produces a wrong result
--
echo
#
CREATE
TABLE
t1
(
d
TIME
);
INSERT
INTO
t1
VALUES
(
'120:00:00'
),
(
'20:00:00'
),
(
'-120:00:00'
),
(
'-220:00:00'
);
SELECT
*
FROM
t1
WHERE
d
>=
ALL
(
SELECT
*
FROM
t1
);
SELECT
*
FROM
t1
WHERE
d
<=
ALL
(
SELECT
*
FROM
t1
);
DROP
TABLE
t1
;
--
echo
#
--
echo
#
--
echo
# End of 10.2 tests
--
echo
# End of 10.2 tests
--
echo
#
--
echo
#
sql/sql_class.cc
View file @
e9f171b4
...
@@ -3394,7 +3394,7 @@ int select_max_min_finder_subselect::send_data(List<Item> &items)
...
@@ -3394,7 +3394,7 @@ int select_max_min_finder_subselect::send_data(List<Item> &items)
if
(
!
cache
)
if
(
!
cache
)
{
{
cache
=
Item_cache
::
get_cache
(
thd
,
val_item
);
cache
=
Item_cache
::
get_cache
(
thd
,
val_item
);
switch
(
val_item
->
result
_type
())
{
switch
(
val_item
->
cmp
_type
())
{
case
REAL_RESULT
:
case
REAL_RESULT
:
op
=
&
select_max_min_finder_subselect
::
cmp_real
;
op
=
&
select_max_min_finder_subselect
::
cmp_real
;
break
;
break
;
...
@@ -3407,8 +3407,13 @@ int select_max_min_finder_subselect::send_data(List<Item> &items)
...
@@ -3407,8 +3407,13 @@ int select_max_min_finder_subselect::send_data(List<Item> &items)
case
DECIMAL_RESULT
:
case
DECIMAL_RESULT
:
op
=
&
select_max_min_finder_subselect
::
cmp_decimal
;
op
=
&
select_max_min_finder_subselect
::
cmp_decimal
;
break
;
break
;
case
ROW_RESULT
:
case
TIME_RESULT
:
case
TIME_RESULT
:
if
(
val_item
->
field_type
()
==
MYSQL_TYPE_TIME
)
op
=
&
select_max_min_finder_subselect
::
cmp_time
;
else
op
=
&
select_max_min_finder_subselect
::
cmp_str
;
break
;
case
ROW_RESULT
:
// This case should never be choosen
// This case should never be choosen
DBUG_ASSERT
(
0
);
DBUG_ASSERT
(
0
);
op
=
0
;
op
=
0
;
...
@@ -3453,6 +3458,22 @@ bool select_max_min_finder_subselect::cmp_int()
...
@@ -3453,6 +3458,22 @@ bool select_max_min_finder_subselect::cmp_int()
return
(
val1
<
val2
);
return
(
val1
<
val2
);
}
}
bool
select_max_min_finder_subselect
::
cmp_time
()
{
Item
*
maxmin
=
((
Item_singlerow_subselect
*
)
item
)
->
element_index
(
0
);
longlong
val1
=
cache
->
val_time_packed
(),
val2
=
maxmin
->
val_time_packed
();
/* Ignore NULLs for ANY and keep them for ALL subqueries */
if
(
cache
->
null_value
)
return
(
is_all
&&
!
maxmin
->
null_value
)
||
(
!
is_all
&&
maxmin
->
null_value
);
if
(
maxmin
->
null_value
)
return
!
is_all
;
if
(
fmax
)
return
(
val1
>
val2
);
return
(
val1
<
val2
);
}
bool
select_max_min_finder_subselect
::
cmp_decimal
()
bool
select_max_min_finder_subselect
::
cmp_decimal
()
{
{
Item
*
maxmin
=
((
Item_singlerow_subselect
*
)
item
)
->
element_index
(
0
);
Item
*
maxmin
=
((
Item_singlerow_subselect
*
)
item
)
->
element_index
(
0
);
...
...
sql/sql_class.h
View file @
e9f171b4
...
@@ -5396,6 +5396,7 @@ class select_max_min_finder_subselect :public select_subselect
...
@@ -5396,6 +5396,7 @@ class select_max_min_finder_subselect :public select_subselect
bool
cmp_int
();
bool
cmp_int
();
bool
cmp_decimal
();
bool
cmp_decimal
();
bool
cmp_str
();
bool
cmp_str
();
bool
cmp_time
();
};
};
/* EXISTS subselect interface class */
/* EXISTS subselect interface class */
...
...
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