[MDEV-20342] Turn Field::flags from a member to a method Created: 2019-08-14  Updated: 2019-08-14  Resolved: 2019-08-14

Status: Closed
Project: MariaDB Server
Component/s: Data types
Fix Version/s: N/A

Type: Task Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Won't Do Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed

 Description   

Note: this patch was reverted from 10.5 on Monty's request.
It makes the engine code incompatible between 10.5 and earlier versions.

Old description

We should eventually split numeric type handlers into separate signed and unsigned variants. This is needed for function collection plugins, to define function prototypes easier.

For example, instead of Type_handler_longlong there should be Type_handler_slonglong and Type_handler_ulonglong.

In order to do this easier, let's change Field::flags and Column_definition::flags from a member to:

uint32 flags;

a method:

uint32 flags() const;

To share the code between Field and Column_definition, let's add a new class:

class Column_cached_flags
{
  uint32 m_flags;
public:
  Column_cached_flags(uint32 flags)
   :m_flags(flags)
  { }
  void set_flags(uint32 flags) { m_flags= flags; }
  void add_flags(uint32 flags) { m_flags|= flags; }
  void clear_flags(uint32 flags) { m_flags&= ~flags; }
  void mask_flags(uint32 flags) { m_flags&= flags; }
  void swap_flags(Column_cached_flags *other)
  {
    swap_variables(uint32, m_flags, other->m_flags);
  }
  uint32 cached_flags() const { return m_flags; }
};

and derive Field and Column definition from it.

Field::flags() and Column_definition::flags() will do something like this:

uint32 flags() cosnst
{
  return Cached_column_flags::cached_flags() | type_handler()->flags();
}

where type_handler()->flags() will be a new method in Type_handler:

virtual uint32 flags() const { return 0; }

Type_handler descendants will override the default implementation and will return data type specific flags:

  • ENUM_FLAG
  • SET_FLAG
  • BLOB_FLAG
  • UNSIGNED_FLAG

or their combination when necessary.

Note, under terms of this task will change only ENUM_FLAG, SET_FLAG and BLOB_FLAG to Type_handler::flags().

UNSIGNED_FLAG will be moved to Type_handler::flags() later, under terms of a separate task.


Generated at Thu Feb 08 08:58:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.