[MDEV-6897] Making Items reentrant Created: 2014-10-20 Updated: 2024-02-01 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | None |
| Fix Version/s: | 11.6 |
| Type: | New Feature | Priority: | Critical |
| Reporter: | Alexander Barkov | Assignee: | Oleksandr Byelkin |
| Resolution: | Unresolved | Votes: | 3 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||
| 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_valueThe 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:
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:
All these members should be removed. The reasonably short values should be moved on stack, The long values should be moved to THD, as a sort of String pool. The method
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. |
| Comments |
| Comment by Sergei Golubchik [ 2015-01-27 ] |
|
I don't know whether it's a good approach. There are other fields in Item that prevent it from being reentrant. |
| Comment by Oleksandr Byelkin [ 2017-09-14 ] |
|
With Monty we discussed 2 main methods to make it (+ mix of both): |
| Comment by Oleksandr Byelkin [ 2017-11-06 ] |
|
As it was discussed on Helsinki meeting we do: 1) value class and use it where it possible Nearest task is to make "value" object returned as result of Item::val() and try to replace all top calls of val_*() with it. |
| Comment by Oleksandr Byelkin [ 2020-09-15 ] |
|
Data stored in the Item are one of 3 type (by Serg):
|