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

Making Items reentrant

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      We want to make Items reentrant, so calculation can be distributed between different processors. This will be very useful for UNIONs, but possible use cases will not be really limited only to UNIONs.

      Currently there are the following obstacles to make Items reentrant:

      1. Item::null_value

      The member Item::null_value. It should be removed. Value getter methods should be rewritten to return the value together with the null flag. There are two options here:

      • a. Remove all non-reentrant data type specific methods: val_int(), val_bool(), val_real() and replace them by a single method

        bool Item::val(Value *);

        See MDEV-19259

      • b. Modify the existing data type specific methods to return null flag together with the value itself. Possible options, using double as an example:

          virtual double val_real_null(bool *null_value_arg)= 0; // Add a pointer to null flag
          virtual bool get_double(double *to)= 0; // return NULL flag, pass the destination by pointer
          virtual Double_null to_double_null()= 0; // return a structure {double,bool}
        


        See MDEV-23738 for more details.

      2. Temporary values (e.g. Item::str_value, Item_func_xxx::tmp_value)

      Many Item descendants, and especially Item_func*, store various intermediate String values inside themselves, as members.

      Some examples:

      class Item_func_ord :public Item_int_func
      {
        String value;
      public:
        ...
      };
      

      class Item_func_md5 :public Item_str_ascii_func
      {
        String tmp_value;
      public:
       ...
      }
      

      class Item_func_date_format :public Item_str_func
      {
        int fixed_length;
        const bool is_time_format;
        String value;
      public:
        ...
      }
      

      All these members should be removed.

      The reasonably short values should be moved on stack,
      e.g. using the StringBuffer<size> template.

      The long values should be moved to THD, as a sort of String pool.

      The method

      String *Item::val_str(String *to);
      

      should be turned to:

      String *Item::val_str(String *to, String_pool *pool) const;
      

      Or, possibly, even to:

      String *Item::val_str(String_pool *pool) const;
      

      so the final String value can also be allocated on String_pool.

      String_pool can have a constructor accepting a String object:

      String_pool(String *str);
      

      to keep polymorphism, so the old code still works:

      String buffer, *tmp= item->val_str(&buffer);
      

      The above call will be convenient for the cases when we don't need to reuse the memory allocated by intermediate values during Item->val_str() calculation.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sanja Oleksandr Byelkin
              Reporter:
              bar Alexander Barkov
              Votes:
              3 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated: