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

Split Item_func_min_max::fix_length_and_dec() into methods in Type_handler

    XMLWordPrintable

Details

    Description

      Item_func_min_max::fix_length_and_dec() is hard-coded for the built-in data types. To allow pluggable data type determine behavior of the functions LEAST and GREATEST, we'll move the code to Type_handler as follows:

      1. Add a new method in Type_handler_hybrid_field_type:

      bool aggregate_for_min_max(const char *funcname, Item **items, uint nitems);
      

      This method will decide which data type handler should be used for the result of LEAST/GREATEST.

      2. Add a new virtual method in Type_handler:

      virtual bool Item_func_min_max_fix_attributes(THD *thd,
                                                    Item_func_min_max *func,
                                                    Item **items,
                                                     uint nitems) const;
      

      This method will calculate the data type attributes. See Type_std_attributes.

      Note, implementations for the particular Type_handler_xxx classes should reuse the code from Item_hybrid_func_fix_attributes as much as possible, because the current implementation of Item_func_min_max::fix_length_and_dec() is quite buggy:

      • MDEV-12497 Wrong data type for LEAST(latin1_expr, utf8_expr)
      • MDEV-12504 Wrong data type for LEAST(date_expr,time_expr)
      • MDEV-12505 Wrong data type for GREATEST(bit_column, int_column)

      Sharing the code with Item_hybrid_func should fix these problems.

      3. Remove the current implementation of Item_func_min_max::fix_length_and_dec() and replace it to the new methods.

      Under terms of this task we'll also disallow LEAST and GREATEST to have arguments of the GEOMETRY data type mixed with numeric and temporal arguments, as this has no sense.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.