[MDEV-6983] BIGINT 99991231000000 to TIME'00:00:00' comparison is not consistent Created: 2014-10-30  Updated: 2022-10-26

Status: Open
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.14, 10.10.1, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10
Fix Version/s: 10.4

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Blocks
is blocked by MDEV-6991 GROUP_MIN_MAX optimization is erroneo... Closed

 Description   

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a BIGINT, b TIME);
INSERT INTO t1 VALUES (99991231000000,'00:00:00');
SELECT a, b, 99991231000000=TIME'00:00:00',a=TIME'00:00:00',99991231000000=b,a=b FROM t1;

returns the following:

+----------------+----------+-------------------------------+------------------+------------------+------+
| a              | b        | 99991231000000=TIME'00:00:00' | a=TIME'00:00:00' | 99991231000000=b | a=b  |
+----------------+----------+-------------------------------+------------------+------------------+------+
| 99991231000000 | 00:00:00 |                             1 |                0 |                1 |    0 |
+----------------+----------+-------------------------------+------------------+------------------+------+

That is 999991231000000=TIME'00:00:00' is:

  • equal when both are literals
  • not equal with a numeric field and a TIME literal
  • equal with a numeric literal and a TIME field
  • not equal when both are fields

This looks inconsistent, because in all cases it should be compared as TIME,
according to the current comparison rules.



 Comments   
Comment by Alexander Barkov [ 2014-11-10 ]

This should be easier to fix after pushing the refactoring done under terms of MDEV-6991.

Comment by Alexander Barkov [ 2022-10-26 ]

The inconsistency is still repeatable in all versions between 10.4 10.10, but in a different way:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a BIGINT, b TIME);
INSERT INTO t1 VALUES (99991231000000,'00:00:00');
SELECT a, b, 99991231000000=TIME'00:00:00',a=TIME'00:00:00',99991231000000=b,a=b FROM t1;

+----------------+----------+-------------------------------+------------------+------------------+------+
| a              | b        | 99991231000000=TIME'00:00:00' | a=TIME'00:00:00' | 99991231000000=b | a=b  |
+----------------+----------+-------------------------------+------------------+------------------+------+
| 99991231000000 | 00:00:00 |                             1 |                0 |                1 |    1 |
+----------------+----------+-------------------------------+------------------+------------------+------+

Generated at Thu Feb 08 07:16:04 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.