[MDEV-32496] TIMESTAMP variant to support YEAR range -4713 and +9999 Created: 2023-10-17  Updated: 2023-10-23

Status: Open
Project: MariaDB Server
Component/s: Data types, Temporal Types
Fix Version/s: None

Type: Task Priority: Major
Reporter: Alexander Barkov Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-10764 PL/SQL parser - Phase 2 Open
blocks MDEV-11070 Providing compatibility to other data... Open
blocks MDEV-15750 preserve MYSQL_TYPE_TIMESTAMP in temp... Stalled
Relates
relates to MDEV-341 64-bit support in FROM_UNIXTIME() Open
relates to MDEV-17389 sql_mode=ORACLE: Incompatibility in d... Open
relates to MDEV-32188 make TIMESTAMP use whole 32-bit unsig... In Testing
relates to MDEV-10018 Timestamp with time zone Open

 Description   

MariaDB TIMESTAMP supports year values in the range 1970..2038, and after MDEV-32188 it's going to support year values in the range 1970..2106.

This range is still narrower than most other databases support:

Data type Min Max
Oracle TIMESTAMP -4713 9999
DB2 TIMESTAP 0001 9999
PostgreSQL TIMESTAMP -4713 294276
SQL Server DATETIME2 0001 9999
SQL Server DATETIME 1753 9999

For migration purposes, we need a data type which will cover at least the range -4713..9999.

It will need 5 bytes (instead of 4 bytes) to store the "number of seconds since 1970-01-01 00:00:00 UTC" value.

Also, it will need a new C++ data type (instead of struct timeval) to transfer values inside the server.

struct {
  longlong tv_sec; -- signed, to store negative years
  uint32 tv_usec; 
};

This task is also a dependency for

  • MDEV-15750 preserve MYSQL_TYPE_TIMESTAMP in temporal arithmetic

Using TIMESTAMP arithmetic for the current TIMESTAMP implementation is not very meaningful because of the too small TIMESTAMP range.



 Comments   
Comment by Vladislav Vaintroub [ 2023-10-17 ]

bar, if possible, do not use ulong. It is a very badly portable type. for usec, int32_t is more than enough.

Comment by Alexander Barkov [ 2023-10-17 ]

wlad, thanks for your note. I agree. Changed to uint32.

Generated at Thu Feb 08 10:31:48 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.