[MDEV-17317] Add THD* parameter into Item::get_date() and stricter data type control to "fuzzydate" Created: 2018-09-28  Updated: 2018-10-01  Resolved: 2018-09-28

Status: Closed
Project: MariaDB Server
Component/s: Data types, Temporal Types
Fix Version/s: 10.4.0

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

Issue Links:
Blocks
blocks MDEV-16991 Rounding vs truncation for TIME, DATE... Closed
is blocked by MDEV-17318 CAST(LEAST(zero_date,non_zero_date) A... Closed

 Description   

In many places in Item::get_date() we use current_thd. After adding of MDEV-16991, access to THD will be needed at every call of get_date(), to check rounding mode from thd->variables.

To avoid heavy use of current_thd, we'll add a THD* parameter to Item::get_date().
Also, at the same time, we'll change "ulonglong fuzzydate" to "date_mode_t fuzzydate".

After this change, the definition of Item::get_date() will look like this:

  virtual bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)= 0;

Where date_mode_t:

  • will have stricter data type control, so an attempt to pass to Item::get_date() an arbitrary integer value (instead of date_mode_t) won't compile
  • will have a enum-based storage, so in gdb we can see easy readable values instead of integers:

    Breakpoint 1, Item_date_typecast::get_date (this=0x7ffe6c016158, thd=
        0x7ffe6c000b00, ltime=0x7ffff0c1d8f8, fuzzydate=...)
        at /home/bar/maria-git/server.10.4.get_date/sql/item_timefunc.cc:2452
    2452	  date_mode_t tmp= (fuzzydate | sql_mode_for_dates(thd)) & ~TIME_TIME_ONLY;
    (gdb) p fuzzydate
    $1 = {
      m_mode = (date_mode_t::NO_ZERO_IN_DATE | date_mode_t::NO_ZERO_DATE | date_mode_t::INVALID_DATES)}
    

We'll also change a number of other dependency functions and methods to get "date_mode_t fuzzydate" instead of "ulonglong fuzzydate".


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