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

Add Field::get_typelib() and Item::get_typelib()

    Details

      Description

      This code in item.cc is not friendly to pluggable data types:

      void Item_type_holder::get_full_info(Item *item)
      {
        if (Item_type_holder::real_type_handler() == &type_handler_enum ||
            Item_type_holder::real_type_handler() == &type_handler_set)
        {
          if (item->type() == Item::SUM_FUNC_ITEM &&
              (((Item_sum*)item)->sum_func() == Item_sum::MAX_FUNC ||
               ((Item_sum*)item)->sum_func() == Item_sum::MIN_FUNC))
            item = ((Item_sum*)item)->get_arg(0);
          /*
            We can have enum/set type after merging only if we have one enum|set
            field (or MIN|MAX(enum|set field)) and number of NULL fields
          */
          DBUG_ASSERT((enum_set_typelib &&
                       item->real_type_handler() == &type_handler_null) ||
                      (!enum_set_typelib &&
                       item->real_item()->type() == Item::FIELD_ITEM &&
                       (item->real_type_handler() == &type_handler_enum ||
                        item->real_type_handler() == &type_handler_set) &&
                       ((Field_enum*)((Item_field *) item->real_item())->field)->typelib;
          if (!enum_set_typelib)
          {
            enum_set_typelib= ((Field_enum*)((Item_field *) item->real_item())->field)
          }
        }
      }
      

      Unlike ENUM and SET, new TYPELIB-based data types may want to preserve the exact data type hybrid functions like CASE or LEAST.

      Instead of having this hard-coded logic that preserves TYPELIB only in UNION and only for fields and aggregate functions MIN(field) and MAX(field), will introduce new methods:

      virtual TYPELIB *Field::get_typelib() const;
      virtual TYPELIB *Item::get_typelib() const;
      

      and decompose this code into virtual implementations in Field, Field_enum, Item_field, Item_ref, Item_sum_hybrid.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: