Status: Open (View Workflow)
Fix Version/s: None
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:
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
- b. Modify the existing data type specific methods to return null flag together with the value itself. Possible options, using double as an example:
See MDEV-23738 for more details.
Many Item descendants, and especially Item_func*, store various intermediate String values inside themselves, as members.
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.
should be turned to:
Or, possibly, even to:
so the final String value can also be allocated on String_pool.
String_pool can have a constructor accepting a String object:
to keep polymorphism, so the old code still works:
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.