[MDEV-10317] EXCTACT(MINUTE_MICROSECOND) truncates data Created: 2016-07-01  Updated: 2016-07-03  Resolved: 2016-07-03

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Temporary
Affects Version/s: 10.1, 10.2
Fix Version/s: 10.1.16

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

Issue Links:
Relates
relates to MCOL-80 EXTRACT() function returned assertion... Closed
relates to MDEV-10309 COALESCE(12345678900) makes a column ... Closed

 Description   

A script demonstrating the problem with EXTRACT:

SET timestamp=UNIX_TIMESTAMP('2001-01-01 23:59:59.999999');
SELECT EXTRACT(MINUTE_MICROSECOND FROM NOW(6));
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 AS SELECT EXTRACT(MINUTE_MICROSECOND FROM NOW(6));
SELECT * FROM t1;
SHOW CREATE TABLE t1;

SELECT EXTRACT() correctly returns 5959999999

+-----------------------------------------+
| EXTRACT(MINUTE_MICROSECOND FROM NOW(6)) |
+-----------------------------------------+
|                              5959999999 |
+-----------------------------------------+

The value stored in the table is erroneously truncated to 2147483647

+-----------------------------------------+
| EXTRACT(MINUTE_MICROSECOND FROM NOW(6)) |
+-----------------------------------------+
|                              2147483647 |
+-----------------------------------------+

And the created column data type is wrong:

+-------+-----------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                |
+-------+-----------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `EXTRACT(MINUTE_MICROSECOND FROM NOW(6))` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+-----------------------------------------------------------------------------------------------------------------------------+

The expected data type is bigint.


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