[MDEV-23351] Rounding functions return wrong data types for DATE input Created: 2020-07-31  Updated: 2020-08-03  Resolved: 2020-07-31

Status: Closed
Project: MariaDB Server
Component/s: Data types, Temporal Types
Affects Version/s: 10.1, 10.2, 10.3, 10.4, 10.5
Fix Version/s: 10.4.14, 10.5.5

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-23032 FLOOR()/CEIL() incorrectly calculate ... Closed
relates to MDEV-23388 Assertion `args[0]->decimals == 0' fa... Closed

 Description   

CREATE OR REPLACE TABLE t1 (a date);
CREATE OR REPLACE TABLE t2 AS SELECT FLOOR(a), CEIL(a),ROUND(a),TRUNCATE(a,0) FROM t1;

+---------------+--------------+------+-----+---------+-------+
| Field         | Type         | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| FLOOR(a)      | bigint(12)   | YES  |     | NULL    |       |
| CEIL(a)       | bigint(12)   | YES  |     | NULL    |       |
| ROUND(a)      | double(17,0) | YES  |     | NULL    |       |
| TRUNCATE(a,0) | double(17,0) | YES  |     | NULL    |       |
+---------------+--------------+------+-----+---------+-------+

A date value has 8 digits in numeric format: YYYYMMDD.

  • INT(9) should be enough for ROUND() with a negative argument (to be checked in a separate MDEV)
  • INT(8) should be enough for ROUND() with a non-negative argument
  • INT(8) should be enough for all other functions

Generated at Thu Feb 08 09:21:45 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.