[MDEV-19259] Separating Value from Item Created: 2019-04-16 Updated: 2023-05-04 |
|
| Status: | Stalled |
| Project: | MariaDB Server |
| Component/s: | Server |
| Fix Version/s: | 11.2 |
| Type: | Task | Priority: | Major |
| Reporter: | Oleksandr Byelkin | Assignee: | Oleksandr Byelkin |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
| Comments |
| Comment by Oleksandr Byelkin [ 2019-04-16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
first test is to make Item::val() method which return the value object and see how it will work in points where val_* used not in Item class. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2020-09-10 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I don't think "reference on Type" should be part of the Value. We already have problems with String and my_decimal that duplicate some of the Item's metadata. Perhaps the Value object should have only the data and metadata should be in the Item? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2020-09-11 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
serg, this is a good idea. I have only one concern: how getting, say, a double value will look like.
Something like this? It looks too cumbersome. I suggest this API that I proposed by email:
Note, Item::to_double_null() can use Value internally in the end:
The key point is that we can add methods like to_double_null() BEFORE adding Item::val(), thus split a huge change into smaller pieces: 1. Change val_real() to to_double_null()
Note, 1a and 1b will be separate small patches. Iterate these two steps for all non-reentrant methods (again, two patches for each method):
5. Remove Item::null_value After that, Item::val() can be added, if really needed, and all methods to_xxx_null(), to_date(), to_time(), to_datetime() can be modified to use val() internally. Don't mix too many changes! One change at a time! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2020-09-11 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
How will addition look like with Item::val()?
The above is cumbersome again. A much better version:
Even better version: why not add operator+() to Double_null and hide NULL processing inside, so the caller looks as simple as:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Michael Widenius [ 2020-09-11 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Just to get the discussion going: Here is an example of how to separate the null value by adding a pointer to null object to all val functions, except val_str() and val_decimal() who don't need it (a null pointer is a good way to detect the null value for these)
To usage of this would be:
Note that the plus function is coded slightly different from before to allow shortcutting the + operation if we get a null early |