Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-16888

Add virtual Type_handler::cond_notnull_field_isnull_to_field_eq_zero()

    XMLWordPrintable

Details

    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.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.