mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-34069 Zero datetime reinterprets as '1970-01-01 00:00:00' on field_datetime=field_timestamp
The code in Field_timestamp::save_in_field() did not catch zero datetime and stored it to the other field like a usual value using store_timestamp_dec(), which knows nothing about zero date and treats {tv_sec=0, tv_usec=0} as a normal timeval value corresponding to '1970-01-01 00:00:00 +00:00'. Fixing the code to catch the special combination (ts==0 && sec_pat==0) and store it using store_time_dec() with a zero datetime passed as an argument.
This commit is contained in:
@ -5184,6 +5184,8 @@ int Field_timestamp::save_in_field(Field *to)
|
||||
{
|
||||
ulong sec_part;
|
||||
my_time_t ts= get_timestamp(&sec_part);
|
||||
if (!ts && !sec_part)
|
||||
return to->store_time_dec(Datetime::zero().get_mysql_time(), decimals());
|
||||
return to->store_timestamp_dec(Timeval(ts, sec_part), decimals());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user