Commit 55e67c3e authored by Alexander Barkov's avatar Alexander Barkov

MDEV-8095 Split Create_field

Part2: moving a few other fields from Column_definition to Create_field.
sizeof(sp_variable) is now 200 bytes (vs 248 bytes in 10.1)
parent 00ed55c7
...@@ -9757,7 +9757,6 @@ void Column_definition::init_for_tmp_table(enum_field_types sql_type_arg, ...@@ -9757,7 +9757,6 @@ void Column_definition::init_for_tmp_table(enum_field_types sql_type_arg,
FLAGSTR(pack_flag, FIELDFLAG_DECIMAL), FLAGSTR(pack_flag, FIELDFLAG_DECIMAL),
f_packtype(pack_flag))); f_packtype(pack_flag)));
vcol_info= 0; vcol_info= 0;
create_if_not_exists= FALSE;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -10429,7 +10428,6 @@ Field *make_field(TABLE_SHARE *share, ...@@ -10429,7 +10428,6 @@ Field *make_field(TABLE_SHARE *share,
Column_definition::Column_definition(THD *thd, Field *old_field, Column_definition::Column_definition(THD *thd, Field *old_field,
Field *orig_field) Field *orig_field)
{ {
field= old_field;
field_name= old_field->field_name; field_name= old_field->field_name;
length= old_field->field_length; length= old_field->field_length;
flags= old_field->flags; flags= old_field->flags;
...@@ -10441,7 +10439,6 @@ Column_definition::Column_definition(THD *thd, Field *old_field, ...@@ -10441,7 +10439,6 @@ Column_definition::Column_definition(THD *thd, Field *old_field,
comment= old_field->comment; comment= old_field->comment;
decimals= old_field->decimals(); decimals= old_field->decimals();
vcol_info= old_field->vcol_info; vcol_info= old_field->vcol_info;
create_if_not_exists= FALSE;
option_list= old_field->option_list; option_list= old_field->option_list;
option_struct= old_field->option_struct; option_struct= old_field->option_struct;
......
...@@ -3440,20 +3440,15 @@ class Column_definition: public Sql_alloc ...@@ -3440,20 +3440,15 @@ class Column_definition: public Sql_alloc
uint decimals, flags, pack_length, key_length; uint decimals, flags, pack_length, key_length;
Field::utype unireg_check; Field::utype unireg_check;
TYPELIB *interval; // Which interval to use TYPELIB *interval; // Which interval to use
TYPELIB *save_interval; // Temporary copy for the above
// Used only for UCS2 intervals
List<String> interval_list; List<String> interval_list;
CHARSET_INFO *charset; CHARSET_INFO *charset;
uint32 srid; uint32 srid;
Field::geometry_type geom_type; Field::geometry_type geom_type;
Field *field; // For alter table
engine_option_value *option_list; engine_option_value *option_list;
/** structure with parsed options (for comparing fields in ALTER TABLE) */ /** structure with parsed options (for comparing fields in ALTER TABLE) */
ha_field_option_struct *option_struct; ha_field_option_struct *option_struct;
uint8 interval_id; // For rea_create_table uint pack_flag;
uint offset,pack_flag;
bool create_if_not_exists; // Used in ALTER TABLE IF NOT EXISTS
/* /*
This is additinal data provided for any computed(virtual) field. This is additinal data provided for any computed(virtual) field.
...@@ -3467,8 +3462,8 @@ class Column_definition: public Sql_alloc ...@@ -3467,8 +3462,8 @@ class Column_definition: public Sql_alloc
def(0), on_update(0), sql_type(MYSQL_TYPE_NULL), def(0), on_update(0), sql_type(MYSQL_TYPE_NULL),
flags(0), pack_length(0), key_length(0), interval(0), flags(0), pack_length(0), key_length(0), interval(0),
srid(0), geom_type(Field::GEOM_GEOMETRY), srid(0), geom_type(Field::GEOM_GEOMETRY),
field(0), option_list(NULL), option_struct(NULL), option_list(NULL), option_struct(NULL),
create_if_not_exists(false), vcol_info(0) vcol_info(0)
{ {
interval_list.empty(); interval_list.empty();
} }
...@@ -3518,12 +3513,21 @@ class Create_field :public Column_definition ...@@ -3518,12 +3513,21 @@ class Create_field :public Column_definition
public: public:
const char *change; // If done with alter table const char *change; // If done with alter table
const char *after; // Put column after this one 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
Create_field(): Create_field():
Column_definition(), change(0), after(0) Column_definition(), change(0), after(0),
field(0), create_if_not_exists(false)
{ } { }
Create_field(THD *thd, Field *old_field, Field *orig_field): Create_field(THD *thd, Field *old_field, Field *orig_field):
Column_definition(thd, old_field, orig_field), Column_definition(thd, old_field, orig_field),
change(old_field->field_name), after(0) change(old_field->field_name), after(0),
field(old_field), create_if_not_exists(false)
{ } { }
/* Used to make a clone of this object for ALTER/CREATE TABLE */ /* Used to make a clone of this object for ALTER/CREATE TABLE */
Create_field *clone(MEM_ROOT *mem_root) const; Create_field *clone(MEM_ROOT *mem_root) const;
......
...@@ -867,7 +867,6 @@ void LEX::init_last_field(Column_definition *field, const char *field_name, ...@@ -867,7 +867,6 @@ void LEX::init_last_field(Column_definition *field, const char *field_name,
void LEX::set_last_field_type(const Lex_field_type_st &type) void LEX::set_last_field_type(const Lex_field_type_st &type)
{ {
last_field->sql_type= type.field_type(); last_field->sql_type= type.field_type();
last_field->create_if_not_exists= check_exists;
last_field->charset= charset; last_field->charset= charset;
if (type.length()) if (type.length())
...@@ -6150,6 +6149,7 @@ field_spec: ...@@ -6150,6 +6149,7 @@ field_spec:
lex->alter_info.create_list.push_back($$, thd->mem_root); lex->alter_info.create_list.push_back($$, thd->mem_root);
$$->create_if_not_exists= Lex->check_exists;
if ($$->flags & PRI_KEY_FLAG) if ($$->flags & PRI_KEY_FLAG)
add_key_to_list(lex, &$1, Key::PRIMARY, Lex->check_exists); add_key_to_list(lex, &$1, Key::PRIMARY, Lex->check_exists);
else if ($$->flags & UNIQUE_KEY_FLAG) else if ($$->flags & UNIQUE_KEY_FLAG)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment