[MDEV-10182] Bad value when inserting COALESCE(CURRENT_TIMESTAMP) into a DECIMAL column Created: 2016-06-06  Updated: 2018-06-15  Resolved: 2018-06-15

Status: Closed
Project: MariaDB Server
Component/s: Temporal Types
Affects Version/s: 5.5, 10.0, 10.1, 10.2
Fix Version/s: 10.3.0

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

Issue Links:
Blocks
is blocked by MDEV-11337 Split Item::save_in_field() into virt... Closed

 Description   

This script:

SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30.000000');
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL(30,0));
INSERT INTO t1 VALUES (CURRENT_TIMESTAMP(6));
SELECT * FROM t1;

returns:

+----------------+
| a              |
+----------------+
| 20010101102030 |
+----------------+

This is correct.

Now if I do:

SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30.000000');
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL(30,0));
INSERT INTO t1 VALUES (COALESCE(CURRENT_TIMESTAMP(6)));
SELECT * FROM t1;

it generates a warning on INSERT, and returns:

+------+
| a    |
+------+
| 2001 |
+------+



 Comments   
Comment by Alexander Barkov [ 2018-06-15 ]

The patch for MDEV-11337 fixed this problem.
Only added tests under terms of MDEV-10182.

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