[MDEV-11331] Wrong result for INSERT INTO t1 (datetime_field) VALUES (hybrid_function_of_TIME_data_type) Created: 2016-11-22  Updated: 2017-04-07  Resolved: 2016-11-25

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

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

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed
blocks MDEV-11337 Split Item::save_in_field() into virt... Closed

 Description   

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DATETIME);
INSERT INTO t1 VALUES (TIME'10:20:30'),(COALESCE(TIME'10:20:30'));
SHOW WARNINGS;
SELECT * FROM t1;

+---------+------+----------------------------------------+
| Level   | Code | Message                                |
+---------+------+----------------------------------------+
| Warning | 1265 | Data truncated for column 'a' at row 2 |
+---------+------+----------------------------------------+

+---------------------+
| a                   |
+---------------------+
| 2016-11-22 10:20:30 |
| 0000-00-00 00:00:00 |
+---------------------+

This result is wrong. The expected result would be 2016-11-22 10:20:30 for both values.

The same problem is repeatable in this script:

SET timestamp=UNIX_TIMESTAMP('2001-02-03 10:20:30.123456');
CREATE OR REPLACE TABLE t1 (a DECIMAL(30,6) DEFAULT COALESCE(CURRENT_TIMESTAMP(6)));
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES (CURRENT_TIMESTAMP(6));
INSERT INTO t1 VALUES (COALESCE(CURRENT_TIMESTAMP(6)));
INSERT INTO t1 VALUES();
SELECT * FROM t1;

+-----------------------+
| a                     |
+-----------------------+
| 20010203102030.123456 |
|           2001.000000 |
|           2001.000000 |
+-----------------------+

The second and the third rows look wrong.



 Comments   
Comment by Alexander Barkov [ 2016-11-25 ]

Fixed in a join patch for MDEV-11337.

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