[MDEV-23738] Get rid of Item::null_value Created: 2020-09-15  Updated: 2023-11-19

Status: Open
Project: MariaDB Server
Component/s: None
Fix Version/s: None

Type: Task Priority: Critical
Reporter: Alexander Barkov Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-6897 Making Items reentrant Open

 Description   

In order to make Items reentrant (see MDEV-6897) we need to get rid of the boolean member Item::null_value.

To remove this member, we'll need to modify the following methods in Item to return the actual value and the SQL NULL flag at the same time:

virtual bool val_bool();
virtual double val_real();
virtual longlong val_int();

Note, the other methods val_str(), val_decimal(), get_date(), get_time() do not necessarily need to be modified, because they already return SQL NULL as their return value:

  • val_str() returns NULL to mean SQL NULL
  • val_decimal() returns NULL to mean SQL NULL
  • get_date() returns true to mean SQL NULL
  • get_time() returns true to mean SQL NULL

Possible options

Add a pointer to the SQL NULL flag:

virtual bool val_bool_null(bool *null_value_arg);
virtual longlong val_int_null(bool *null_value_arg);
virtual double val_real_null(bool *null_value_arg);

Return SQL NULL, pass the value target as a pointer:

virtual bool get_bool(bool *to);
virtual bool get_longlong(longlong *to);
virtual bool get_double(double *to);

Return a structure consisting of the value and the SQL NULL flag

virtual Bool_null to_bool_null();
virtual Longlong_null to_longlong_null();
virtual Double_null to_double_null();

where the structures are about the following:

class Bool_null { bool value; bool is_null };
class Longlong_null { longlong value; bool is_null };
class Double_null { double value; bool is_null };

Mixed

A mixed API could be also considered depending on which exact method performs better for a certain data type. For example:

virtual Bool_null to_bool_null();
virtual longlong val_int_null(bool *null_value_arg);
virtual bool get_double(double *to);

But this probably won't be convenient.

Plan

Under terms of this task we'll:

  • Implement a bechmark program to test the performance of all proposed new API versions
  • Find the way which performs better for every data type
  • Discuss the winner methods
  • Decide the new API
  • Implement the decided API

Generated at Thu Feb 08 09:24:40 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.