Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
5.5.47, 10.0.23, 10.1.9, 5.3.13
-
Ver 15.1 Distrib 10.1.9-MariaDB, for osx10.11
Description
MariaDB seems to behave differently from other databases when selecting a time with a datetime. Maria requires truncating the date first, otherwise it returns the empty set. MySQL, Postgres, Sqlite, and SQL Server ignore the date and return rows matching the time portion.
Here are the examples:
https://gist.github.com/bronson/0a49e7d3fe7242cb5cd3 (thanks to litheum for this table)
Monty says: what looks wrong at my end is that we are converting the string to this time: "838:49:59.99999" and then trying to compare that. This is stored in a Item_time_literal.
Attachments
Activity
Field | Original Value | New Value |
---|---|---|
Description |
MariaDB seems to behave differently from other databases when selecting a time with a datetime. Maria requires truncating the date first, otherwise it will return the empty set. MySQL, Postgres, Sqlite, and SQL Server ignore the date and return matching rows. Here are the examples: https://gist.github.com/bronson/0a49e7d3fe7242cb5cd3 (thanks to litheum for this table) Monty says: what looks wrong at my end is that we are converting the string to this time: "838:49:59.99999" and then trying to compare that. This is stored in a Item_time_literal. |
MariaDB seems to behave differently from other databases when selecting a time with a datetime. Maria requires truncating the date first, otherwise it will return the empty set. MySQL, Postgres, Sqlite, and SQL Server ignore the date and return rows matching the time portion. Here are the examples: https://gist.github.com/bronson/0a49e7d3fe7242cb5cd3 (thanks to litheum for this table) Monty says: what looks wrong at my end is that we are converting the string to this time: "838:49:59.99999" and then trying to compare that. This is stored in a Item_time_literal. |
Description |
MariaDB seems to behave differently from other databases when selecting a time with a datetime. Maria requires truncating the date first, otherwise it will return the empty set. MySQL, Postgres, Sqlite, and SQL Server ignore the date and return rows matching the time portion. Here are the examples: https://gist.github.com/bronson/0a49e7d3fe7242cb5cd3 (thanks to litheum for this table) Monty says: what looks wrong at my end is that we are converting the string to this time: "838:49:59.99999" and then trying to compare that. This is stored in a Item_time_literal. |
MariaDB seems to behave differently from other databases when selecting a time with a datetime. Maria requires truncating the date first, otherwise it returns the empty set. MySQL, Postgres, Sqlite, and SQL Server ignore the date and return rows matching the time portion. Here are the examples: https://gist.github.com/bronson/0a49e7d3fe7242cb5cd3 (thanks to litheum for this table) Monty says: what looks wrong at my end is that we are converting the string to this time: "838:49:59.99999" and then trying to compare that. This is stored in a Item_time_literal. |
Assignee | Alexander Barkov [ bar ] |
Affects Version/s | 10.0.23 [ 20401 ] | |
Affects Version/s | 5.5.47 [ 20300 ] | |
Affects Version/s | 5.3.13 [ 12602 ] |
Labels | datatype |
Component/s | Temporal Types [ 11000 ] |
Fix Version/s | 10.0 [ 16000 ] | |
Fix Version/s | 10.1 [ 16100 ] | |
Fix Version/s | 10.2 [ 14601 ] |
Component/s | Data types [ 13906 ] |
Epic Link | MDEV-21071 [ 80504 ] |
Fix Version/s | 10.0 [ 16000 ] |
Fix Version/s | 10.1 [ 16100 ] |
Workflow | MariaDB v3 [ 73921 ] | MariaDB v4 [ 139940 ] |
Saving the data from the paste:
MariaDB-5.3, 5.5, 10.0, 10.1
mariadb 10.1.8-MariaDB-log (root) [test]> create table t1 (id serial, t time);
Query OK, 0 rows affected (0.01 sec)
mariadb 10.1.8-MariaDB-log (root) [test]> insert into t1 (t) values ('12:30:00');
Query OK, 1 row affected (0.00 sec)
mariadb 10.1.8-MariaDB-log (root) [test]> select * from t1 where t = '2000-01-01 12:30:00';
Empty set (0.00 sec)
MySQL, MariaDB-5.1, MariaDB-5.2
mysql 5.6.26-log (root) [test]> create table t1 (id serial, t time);
Query OK, 0 rows affected (0.01 sec)
mysql 5.6.26-log (root) [test]> insert into t1 (t) values ('12:30:00');
Query OK, 1 row affected (0.00 sec)
mysql 5.6.26-log (root) [test]> select * from t1 where t = '2000-01-01 12:30:00';
+----+----------+
| id | t |
+----+----------+
| 1 | 12:30:00 |
+----+----------+
1 row in set (0.00 sec)
MariaDB [test]> select * from t1 where t = TIMESTAMP('2000-01-01 12:30:00');
+----+----------+
| id | t |
+----+----------+
| 1 | 12:30:00 |
+----+----------+
MySQL [test]> select * from t1 where coalesce(t) = coalesce(TIMESTAMP'2000-01-01 12:30:00');
Empty set (0.00 sec)
MySQL [test]> select * from t1 where t = 20000101123000;
+----+----------+
| id | t |
+----+----------+
| 1 | 12:30:00 |
+----+----------+
1 row in set, 1 warning (0.00 sec)
PostgreSQL
postgresql=# create table t1 (id serial, t time);
CREATE TABLE
postgresql=# insert into t1 (t) values ('12:30:00');
INSERT 0 1
postgresql=# select * from t1 where t = '2000-01-01 12:30:00';
t
----------
12:30:00
(1 row)
SQL Server
create table t1 (id int identity(1,1), t time);
insert into t1 (t) values ('12:30:00');
select * from t1 where t = '2000-01-01 12:30:00';
1 12:30:00.0000000