Timestamp truncation is currently implemented inside these methods:
This is different comparing to how TIME and DATETIME do:
- store_TIME_with_warn() truncates the value according to the field scale
- store_TIME() gets a ready-to-store value
MDEV-8894 easier, we'll change Field_timestamp the same way:
- rename virtual store_TIME to:
and remove all truncation code from all virtual implementations. Move this method to "private" section.
- Fix store_TIME_with_warn() to do truncation, and call store_TIMEVAL() with a ready-to-store value.
- Add a non-virtual public method store_TIME(), because it's used externally. It will have exactly the same prototype as before (only non-virtual), with this implementation:
- Modify Field_timestamp::store_TIME_with_warnings() to have this layout (similar to Field_time and Field_temporal_with_date, with extra DATETIME-to-TIMESTAMP conversion specific blocks):
This is needed:
- To avoid duplicate rounding code in Field_timestamp, Field_timestampf, Field_timestamp_hires
- Rounding will possible issue its own warnings. It's important to have the warnings related code in one method, to avoid duplicate warnings, and to avoid less important notes if there is a truncation or rounding warning.
- For symmetry with the other temporal data implementation. We'll be adding TIMESTAMP WITH TIME ZONE soon. So symmetry gets even more important.
- To reuse store_TIME_return_code_with_warnings(), to guarantee that storeXXX() return the same return values under the same conditions.
Note, '2001-01-01 10:20:30garbage' currently makes Field::storeXXX() produce a return value of 2 for TIME/DATE/DATETIME, but 1 for TIMESTAMP. After this change, TIMESTAMP will also return 2. It will help to use range optimizer later for queries like this:
(currently it's not used).