[MDEV-9216] Split field.cc:make_field() into virtual methods in Type_handler Created: 2015-12-01  Updated: 2018-05-24  Resolved: 2018-05-24

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: refactoring

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed
is blocked by MDEV-16280 Add class Bit_addr Closed

 Description   

In order to make built-in and pluggable data types look similar inside the server, this function should be split into a new virtual method in Type_handler:

Field *make_field(TABLE_SHARE *share,
                  MEM_ROOT *mem_root,
                  uchar *ptr, uint32 field_length,
                  uchar *null_pos, uchar null_bit,
                  uint pack_flag,
                  enum_field_types field_type,
                  CHARSET_INFO *field_charset,
                  Field::geometry_type geom_type, uint srid,
                  Field::utype unireg_check,
                  TYPELIB *interval,
                  const char *field_name)

The relevant piece of the code in the original type handler patch:

@@ -9721,6 +9829,14 @@ Field *make_field(TABLE_SHARE *share, uc
     }
   }
 
+  if (const Type_handler *handler= Type_handlers.handler(field_type))
+  {
+    Field::Create_param param(share, ptr,
+                  field_length, null_pos, null_bit, pack_flag, field_charset,
+                  geom_type, unireg_check, interval);
+    return handler->make_field(&param, field_name);
+  }
+

A tentative new virtual Type_handler method prototype:

virtual Field *
make_table_field_from_def(TABLE_SHARE *share,
                          MEM_ROOT *mem_root,
                          const LEX_CSTRING *name,
                          const Record_addr *addr,
                          const Bit_addr *bit,
                          const Column_definition_attributes *attr,
                          uint32 flags) const= 0;

where:

  • Bit_addr is a new class representing the position and the offset of the extra bits (e.g. for the BIT(N) data type)
  • Column_definition_attributes is a new class collecting all attribute parameters:

class Column_definition_attributes
{
public:
  ulonglong length;
  Field::utype unireg_check;
  TYPELIB *interval;
  CHARSET_INFO *charset;
  uint32 srid;
  Field::geometry_type geom_type;
  uint pack_flag;
  ...
  // methods
  ...
};


Generated at Thu Feb 08 07:33:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.