[MDEV-8095] Split Create_field Created: 2015-05-04  Updated: 2021-05-11

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

Type: Task Priority: Major
Reporter: Alexander Barkov Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: refactoring

Issue Links:
Blocks
is blocked by MDEV-8092 Change Column_definition::field_name ... Closed
Epic Link: Data type cleanups

 Description   

Create_field is a big class and some of its parts are not really used in many contexts.
Before adding pluggable data types under terms of MDEV-4912, it would be nice to clean-up use of Create_field.

Under terms of this task we will:

1. Move members of Create_field that are needed only at ALTER time into a separate class Alter_column_specification:

class Alter_column_specification
{
public:
  const char *change;                   // If done with alter table
  const char *after;                    // Put column after this one
  Field *field;                         // For alter table
  TYPELIB *save_interval;               // Temporary copy for the above
                                        // Used only for UCS2 intervals
  uint offset;
  uint8 interval_id;                    // For rea_create_table
  bool create_if_not_exists;            // Used in ALTER TABLE IF NOT EXISTS
};

2. Move the rest of Create_field members (except field_name) into a separate class Column_specification.

class Column_specification
{
public:
  LEX_STRING comment;
  Item *def, *on_update;
  enum  enum_field_types sql_type;
  ulonglong length;
  uint32 char_length;
  uint  decimals, flags, pack_length, key_length;
  Field::utype unireg_check;
  TYPELIB *interval;
  List<String> interval_list;
  CHARSET_INFO *charset;
  uint32 srid;
  Field::geometry_type geom_type;
  engine_option_value *option_list;
  ha_field_option_struct *option_struct;
  uint  pack_flag;
  Virtual_column_info *vcol_info;
  bool stored_in_db;
};

3. Derive Create_field from Column_specification and Alter_column_specification:

class Create_field: public Column_specification,
                    public Alter_column_specification,
                    public Sql_alloc
{
public:
  LEX_CSTRING field_name;
};

Note, Create_field::field_name will be changed from "const char *" to LEX_CSTRING
under terms of MDEV-8092.

4. Change data type of sp_variable::field_def and sp_head::m_return_field_def
from Create_field to Column_specification. These classes need neither the
Alter_column_specification nor the "field_name" parts of Create_field.


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