Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Won't Fix
-
1.4.3
-
None
Description
Original support for TIMESTAMP data type that was added to ColumnStore (https://github.com/mariadb-corporation/mariadb-columnstore-engine/pull/739) did not add support for TIMESTAMP NULL. I.e., when the user creates a table like so:
CREATE TABLE cs1 (a TIMESTAMP NULL)engine=columnstore; |
Even though the NULL constraint is specified in the DDL, we internally set the constraint to NOT NULL in ColumnStore for this column. This is because the default constraint in the server is NOT NULL, when no constraint is specified in the DDL:
create table i1 (a timestamp)engine=innodb; |
Query OK, 0 rows affected (0.069 sec) |
MariaDB [test]> show create table i1; |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------+ |
| Table | Create Table | |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------+ |
| i1 | CREATE TABLE `i1` ( |
`a` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() |
) ENGINE=InnoDB DEFAULT CHARSET=latin1 | |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------+ |
1 row in set (0.001 sec) |
The DDL parser currently does not track whether the user specified the NULL constraint or not; we assume NULL as the default constraint. This internal conversion from NULL to NOT NULL is therefore done due to this limitation in the parser, as well as to respect the default server behaviour for TIMESTAMP datatype.
Note that if the user accidentally creates a table which has one of the columns with TIMESTAMP NULL, and an LDI query is performed, we will have the "\N" values in the data file assigning NULL values to the wrong columns, because the server thinks this column is NULL, but our internal constraint on the column will be NOT NULL (the problematic function in question here is dbcon/mysql/ha_mcs_dml.cpp::ha_mcs_impl_write_batch_row_)
In this issue, we should fix these limitations of the TIMESTAMP datatype, as well as also track the NULL keyword in the DDL parser.