[MDEV-16910] Add class VDec Created: 2018-08-07 Updated: 2018-08-15 Resolved: 2018-08-07 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data types |
| Fix Version/s: | 10.4.0 |
| Type: | Task | Priority: | Major |
| Reporter: | Alexander Barkov | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||
| Description |
|
There is a lot of duplicate code related to retrieving and processing val_decimal() results. This task will reduce the amount of duplicate code using the following changes. 1. Move repeatable pieces as methods to my_decimal Examples:
Also, add new constructors:
2. Add a new class VDec, with approximate this structure:
and change a lot of duplicate peaces like this:
to:
or even to a shorter notation when applicable:
3. Add a similar class VDec_op. It will initialize its value using Item_func_hybrid_field_type::decimal_op() instead of Item::val_decimal(). 4. Remove methods:
5. Add a helper class VDec2_lazy with approximately this definition:
and reuse it instead of duplicate code pieces in Item_func_(plus|minus|mul|div|int_div|mod)::decimal_op(). 6. Change tests for item->null_value to tests for VDec::is_null(). For example:
to
This will be a good step towards MDEV-6897 (particular, to get rid of Item::null_value). As a good advantage, this change will make the code more symmetric with the implementation for temporal data types. The new class VDec will to for DECIMAL what classes Time, Date and Datetime do (for TIME, DATE and DATETIME respectively). |