[MDEV-16888] Add virtual Type_handler::cond_notnull_field_isnull_to_field_eq_zero() Created: 2018-08-03  Updated: 2018-08-03  Resolved: 2018-08-03

Status: Closed
Project: MariaDB Server
Component/s: Data 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-4912 Data type plugin API version 1 Closed

 Description   

The code rewriting "datetime_field IS NULL" to "datetime_field='0000-00-00'" has tests for field_type():

class Item_func_isnull :public Item_func_null_predicate
{
  ..
  bool arg_is_datetime_notnull_field()
  {
    Item **args= arguments();
    if (args[0]->real_item()->type() == Item::FIELD_ITEM)
    {
      Field *field=((Item_field*) args[0]->real_item())->field;
 
      if (((field->type() == MYSQL_TYPE_DATE) ||
          (field->type() == MYSQL_TYPE_DATETIME)) &&
          (field->flags & NOT_NULL_FLAG))
        return true;
    }
  ..
};

COND *
Item_func_isnull::remove_eq_conds(THD *thd, Item::cond_result *cond_value,
                                  bool top_level_arg)
{
 ..
   if (((field->type() == MYSQL_TYPE_DATE) ||
        (field->type() == MYSQL_TYPE_DATETIME)) &&
        (field->flags & NOT_NULL_FLAG))
  ..
}

This is not friendly to new data types.

We'll remove these tests and add a new method in Type_handler_instead:

  virtual bool cond_notnull_field_isnull_to_field_eq_zero() const
  {
    return false;
  }

and override it for Type_handler_date_common and Type_handler_datetime_common to return true.


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