Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5, 10.6, 10.7(EOL)
-
None
Description
This bug related to MDEV-27072 but happend because of a very different reason than MDEV-27072.
I create a table:
DROP TABLE IF EXISTS t1; |
CREATE TABLE t1 (d TIME); |
INSERT INTO t1 VALUES ('120:00:00'), ('20:00:00'), ('-120:00:00'), ('-220:00:00'); |
Now I run this query:
SELECT * FROM t1 WHERE d >= ALL (SELECT * FROM t1); |
+-----------+
|
| d |
|
+-----------+
|
| 120:00:00 |
|
| 20:00:00 |
|
+-----------+
|
The result is wrong. It should return only one row the maxumum value, which is '120:00:00'.
The same problem happens with this query:
SELECT * FROM t1 WHERE d <= ALL (SELECT * FROM t1); |
+------------+
|
| d |
|
+------------+
|
| -120:00:00 |
|
| -220:00:00 |
|
+------------+
|
It should return only one row with the minumum value, which is '-220:00:00'.
The problem happens because select_max_min_finder_subselect::cmp_str() is executed at some point during these queries. It compares values as strings, therefore:
- '120:00:00' is erroneously compared as less than '20:00:00'
- '-220:00:00' is erroneously compared as greater than '-120:00:00'
The TIME data type needs its own implementation, e.g. select_max_min_finder_subselect::cmp_time().
Attachments
Issue Links
- relates to
-
MDEV-27072 Subquery using the ALL keyword on date columns produces a wrong result
-
- Closed
-
-
MDEV-27099 Subquery using the ALL keyword on INET6 columns produces a wrong result
-
- Closed
-
-
MDEV-27100 Subquery using the ALL keyword on UUID columns produces a wrong result
-
- Closed
-
-
MDEV-27101 Subquery using the ALL keyword on TIMESTAMP columns produces a wrong result
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Description |
This bug related to I run create a table: {code:sql} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (d TIME); INSERT INTO t1 VALUES ('120:00:00'), ('20:00:00'), ('-120:00:00'), ('-220:00:00'); {code} Now I run this query: {code:sql} SELECT * FROM t1 WHERE d >= ALL (SELECT * FROM t1); {code} {noformat} +-----------+ | d | +-----------+ | 120:00:00 | | 20:00:00 | +-----------+ {noformat} The result is wrong. It should return only one row the maxumum value, which is '120:00:00'. The same problem happens with this query: {code:sql} SELECT * FROM t1 WHERE d <= ALL (SELECT * FROM t1); {code} {noformat} +------------+ | d | +------------+ | -120:00:00 | | -220:00:00 | +------------+ {noformat} It should return only one row with the minumum value, which is '-220:00:00'. The problem happens because {{select_max_min_finder_subselect::cmp_str()}} is executed at some point during these queries. It compares values as strings, therefore: - '120:00:00' is erroneously compared as less than '20:00:00' - '-220:00:00' is erroneously compared as greater than '-120:00:00' |
This bug related to I create a table: {code:sql} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (d TIME); INSERT INTO t1 VALUES ('120:00:00'), ('20:00:00'), ('-120:00:00'), ('-220:00:00'); {code} Now I run this query: {code:sql} SELECT * FROM t1 WHERE d >= ALL (SELECT * FROM t1); {code} {noformat} +-----------+ | d | +-----------+ | 120:00:00 | | 20:00:00 | +-----------+ {noformat} The result is wrong. It should return only one row the maxumum value, which is '120:00:00'. The same problem happens with this query: {code:sql} SELECT * FROM t1 WHERE d <= ALL (SELECT * FROM t1); {code} {noformat} +------------+ | d | +------------+ | -120:00:00 | | -220:00:00 | +------------+ {noformat} It should return only one row with the minumum value, which is '-220:00:00'. The problem happens because {{select_max_min_finder_subselect::cmp_str()}} is executed at some point during these queries. It compares values as strings, therefore: - '120:00:00' is erroneously compared as less than '20:00:00' - '-220:00:00' is erroneously compared as greater than '-120:00:00' |
Description |
This bug related to I create a table: {code:sql} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (d TIME); INSERT INTO t1 VALUES ('120:00:00'), ('20:00:00'), ('-120:00:00'), ('-220:00:00'); {code} Now I run this query: {code:sql} SELECT * FROM t1 WHERE d >= ALL (SELECT * FROM t1); {code} {noformat} +-----------+ | d | +-----------+ | 120:00:00 | | 20:00:00 | +-----------+ {noformat} The result is wrong. It should return only one row the maxumum value, which is '120:00:00'. The same problem happens with this query: {code:sql} SELECT * FROM t1 WHERE d <= ALL (SELECT * FROM t1); {code} {noformat} +------------+ | d | +------------+ | -120:00:00 | | -220:00:00 | +------------+ {noformat} It should return only one row with the minumum value, which is '-220:00:00'. The problem happens because {{select_max_min_finder_subselect::cmp_str()}} is executed at some point during these queries. It compares values as strings, therefore: - '120:00:00' is erroneously compared as less than '20:00:00' - '-220:00:00' is erroneously compared as greater than '-120:00:00' |
This bug related to I create a table: {code:sql} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (d TIME); INSERT INTO t1 VALUES ('120:00:00'), ('20:00:00'), ('-120:00:00'), ('-220:00:00'); {code} Now I run this query: {code:sql} SELECT * FROM t1 WHERE d >= ALL (SELECT * FROM t1); {code} {noformat} +-----------+ | d | +-----------+ | 120:00:00 | | 20:00:00 | +-----------+ {noformat} The result is wrong. It should return only one row the maxumum value, which is '120:00:00'. The same problem happens with this query: {code:sql} SELECT * FROM t1 WHERE d <= ALL (SELECT * FROM t1); {code} {noformat} +------------+ | d | +------------+ | -120:00:00 | | -220:00:00 | +------------+ {noformat} It should return only one row with the minumum value, which is '-220:00:00'. The problem happens because {{select_max_min_finder_subselect::cmp_str()}} is executed at some point during these queries. It compares values as strings, therefore: - '120:00:00' is erroneously compared as less than '20:00:00' - '-220:00:00' is erroneously compared as greater than '-120:00:00' The TIME data type needs its own implementation, e.g. {{select_max_min_finder_subselect::cmp_time()}}. |
Link |
This issue relates to |
Link |
This issue relates to |
Summary | Subquery using the ALL keyword on time columns produces a wrong result | Subquery using the ALL keyword on TIME columns produces a wrong result |
Link |
This issue relates to |
Status | Open [ 1 ] | In Progress [ 3 ] |
Fix Version/s | 10.2.43 [ 26804 ] | |
Fix Version/s | 10.3.34 [ 26806 ] | |
Fix Version/s | 10.4.24 [ 26808 ] | |
Fix Version/s | 10.5.15 [ 26810 ] | |
Fix Version/s | 10.6.7 [ 26812 ] | |
Fix Version/s | 10.2 [ 14601 ] | |
Fix Version/s | 10.3 [ 22126 ] | |
Fix Version/s | 10.4 [ 22408 ] | |
Fix Version/s | 10.5 [ 23123 ] | |
Fix Version/s | 10.6 [ 24028 ] | |
Fix Version/s | 10.7 [ 24805 ] | |
Resolution | Fixed [ 1 ] | |
Status | In Progress [ 3 ] | Closed [ 6 ] |
Link |
This issue relates to |
Workflow | MariaDB v3 [ 127878 ] | MariaDB v4 [ 159861 ] |
Fix Version/s | 10.2.42 [ 26803 ] | |
Fix Version/s | 10.2.43 [ 26804 ] |
Fix Version/s | 10.3.33 [ 26805 ] | |
Fix Version/s | 10.4.23 [ 26807 ] | |
Fix Version/s | 10.5.14 [ 26809 ] | |
Fix Version/s | 10.6.6 [ 26811 ] | |
Fix Version/s | 10.3.34 [ 26806 ] | |
Fix Version/s | 10.4.24 [ 26808 ] | |
Fix Version/s | 10.5.15 [ 26810 ] | |
Fix Version/s | 10.6.7 [ 26812 ] |
The same problem is repeatable with the INET6 data type: See
MDEV-27099.