[MDEV-17460] Move the code from Item_extract::val_int() to a new class Extract_source Created: 2018-10-15  Updated: 2018-10-16  Resolved: 2018-10-16

Status: Closed
Project: MariaDB Server
Component/s: 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

 Description   

The new code responsible for rounding (MDEV-16991) will reside inside class Temporal.
To take advantage of this rounding functionality easier, we'll move the code from Item_extract::val_int() to a new class:

class Extract_source: public Temporal
{
...
};

The code in Item_extract::val_int() will change from:

MYSQL_TIME ltime;
if ((null_value= args[0]->get_date(current_thd, &ltime, is_time_flag)))
  return 0;
switch (int_type) {
case INTERVAL_YEAR:          return ltime.year;
case INTERVAL_YEAR_MONTH:    return ltime.year*100L+ltime.month;
case INTERVAL_QUARTER:       return (ltime.month+2)/3;
...
}

to:

Extract_source dt(current_thd, args[0], m_date_mode);
if ((null_value= !dt.is_valid_extract_source()))
  return 0;
switch (int_type) {
case INTERVAL_YEAR:                return dt.year();
case INTERVAL_YEAR_MONTH:          return dt.year_month();
case INTERVAL_QUARTER:             return dt.quarter();
...
}


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