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

Move Type_handler_row from Type_collection_std to Type_collection_row




      This is a cleanup task to simplify future development of SQL function and operator overloading.

      The only user visible side affect will be the change in error reporting in some cases, e.g.:

      -ERROR 21000: Operand should contain 1 column(s)
      +ERROR HY000: Illegal parameter data types row and int for operation '+'

      To implement easier overloading for SQL operators and functions for user defined data type arguments, we should:

      • Gradually turn all Item_func descendants (for which we want overloading) into Item_handled_func
      • Add infrastructure to search and choose best overload candidates. Overload candidates will be searched and chosen during fix_length_and_dec() time.
      • The default implementation of Item_func::check_arguments(), which disallows ROW type arguments, should be removed for all Item_func_xxx classes that we want overloading for.

      As a first step, let's cleanup Item_num_op and Item_func_min_max. Namely, let's do the following:
      1. Move Type_handler_row into its own Type_collection_row (separate from Type_collection_std, which after this change will hold only scalar built-in types).
      2. Overload Item_num_op::check_arguments() and Item_func_min_max::check_arguments() from the default implementation to:

      bool check_arguments() const
        return false;

      Arguments for these classes are checked during aggregate_for_num_op() and aggregate_for_min_max(), which after change #1, will return an error for a combination of ROW and scalar arguments, e.g.:

      SELECT ROW(1,1)+2;
      SELECT 2+ROW(1,1);
      SELECT LEAST(ROW(1,1), 2);
      SELECT LEAST(2, ROW(1,1));

      and for two ROW arguments:

      SELECT ROW(1,1)+ROW(2,2);
      SELECT LEAST(ROW(1,1),ROW(2,2));

      so the second test for ROW type arguments in check_arguments() won't be needed.

      As an additional benefit:

      • The virtual method Type_handler::is_traditional_type() will be removed
      • A non-virtual method Type_handller::is_traditional_scalar_type() will be added, with this implementation

        bool Type_handler::is_traditional_scalar_type() const
          return type_collection() == &type_collection_std;


        Issue Links



              bar Alexander Barkov
              bar Alexander Barkov
              0 Vote for this issue
              1 Start watching this issue



                Git Integration

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