diff options
author | Alexander Barkov <bar@mariadb.com> | 2019-06-22 09:15:37 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2019-06-24 06:25:16 +0400 |
commit | c62eaa7bdf492501c7d7155f8e69d37437f71876 (patch) | |
tree | 98627e1437a0e3110e238e5dc917df54811d26d5 | |
parent | 5e474f92b5fd2d0bae800025e6f9acacd4412d04 (diff) | |
download | mariadb-git-c62eaa7bdf492501c7d7155f8e69d37437f71876.tar.gz |
MDEV-19843 Modify ST_FIELD_INFO to use Type_handler and LEX_CSTRING
-rw-r--r-- | sql/sql_i_s.h | 142 | ||||
-rw-r--r-- | sql/sql_profile.cc | 6 | ||||
-rw-r--r-- | sql/sql_profile.h | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 20 | ||||
-rw-r--r-- | sql/sql_show.cc | 61 | ||||
-rw-r--r-- | sql/sql_string.h | 4 | ||||
-rw-r--r-- | sql/sql_type.cc | 54 | ||||
-rw-r--r-- | sql/sql_type.h | 10 |
8 files changed, 145 insertions, 154 deletions
diff --git a/sql/sql_i_s.h b/sql/sql_i_s.h index 4ee9cd8540e..998a5a460a6 100644 --- a/sql/sql_i_s.h +++ b/sql/sql_i_s.h @@ -22,6 +22,7 @@ #include "lex_string.h" // LEX_CSTRING #include "mysql_com.h" // enum_field_types #include "my_time.h" // TIME_SECOND_PART_DIGITS +#include "sql_type.h" // Type_handler_xxx struct TABLE_LIST; struct TABLE; @@ -36,10 +37,6 @@ bool schema_table_store_record(THD *thd, TABLE *table); COND *make_cond_for_info_schema(THD *thd, COND *cond, TABLE_LIST *table); -#define MY_I_S_MAYBE_NULL 1U -#define MY_I_S_UNSIGNED 2U - - enum enum_show_open_table { SKIP_OPEN_TABLE= 0U, // do not open table @@ -48,86 +45,88 @@ enum enum_show_open_table }; -struct ST_FIELD_INFO +namespace Show { +class Type { - /** - This is used as column name. - */ - const char* field_name; - /** - For string-type columns, this is the maximum number of - characters. Otherwise, it is the 'display-length' for the column. - */ - uint field_length; /** This denotes data type for the column. For the most part, there seems to be one entry in the enum for each SQL data type, although there seem to be a number of additional entries in the enum. */ - enum enum_field_types field_type; - int value; + const Type_handler *m_type_handler; /** - This is used to set column attributes. By default, columns are @c NOT - @c NULL and @c SIGNED, and you can deviate from the default - by setting the appopriate flags. You can use either one of the flags - @c MY_I_S_MAYBE_NULL and @cMY_I_S_UNSIGNED or - combine them using the bitwise or operator @c |. Both flags are - defined in table.h. - */ - uint field_flags; // Field atributes(maybe_null, signed, unsigned etc.) - const char* old_name; - /** - This should be one of @c SKIP_OPEN_TABLE, - @c OPEN_FRM_ONLY or @c OPEN_FULL_TABLE. + For string-type columns, this is the maximum number of + characters. Otherwise, it is the 'display-length' for the column. */ - uint open_method; - - LEX_CSTRING get_name() const - { - return LEX_CSTRING({field_name, strlen(field_name)}); - } - LEX_CSTRING get_old_name() const - { - return LEX_CSTRING({old_name, strlen(old_name)}); - } - bool unsigned_flag() const { return field_flags & MY_I_S_UNSIGNED; } + uint m_char_length; + uint m_unsigned_flag; +public: + Type(const Type_handler *th, uint length, uint unsigned_flag) + :m_type_handler(th), m_char_length(length), m_unsigned_flag(unsigned_flag) + { } + const Type_handler *type_handler() const { return m_type_handler; } + uint char_length() const { return m_char_length; } + uint decimal_precision() const { return (m_char_length / 100) % 100; } + uint decimal_scale() const { return m_char_length % 10; } uint fsp() const { - DBUG_ASSERT(field_length <= TIME_SECOND_PART_DIGITS); - return field_length; + DBUG_ASSERT(m_char_length <= TIME_SECOND_PART_DIGITS); + return m_char_length; } + uint unsigned_flag() const { return m_unsigned_flag; } }; +} // namespace Show -namespace Show -{ -class Type +class ST_FIELD_INFO: public Show::Type { - enum enum_field_types m_type; - uint m_char_length; - uint m_unsigned_flag; +protected: + LEX_CSTRING m_name; // I_S column name + enum_nullability m_nullability; // NULLABLE or NOT NULL + LEX_CSTRING m_old_name; // SHOW column name + enum_show_open_table m_open_method; public: - Type(enum_field_types type, uint length, uint unsigned_flag) - :m_type(type), m_char_length(length), m_unsigned_flag(unsigned_flag) + ST_FIELD_INFO(const LEX_CSTRING &name, const Type &type, + enum_nullability nullability, + LEX_CSTRING &old_name, + enum_show_open_table open_method) + :Type(type), m_name(name), m_nullability(nullability), m_old_name(old_name), + m_open_method(open_method) { } - enum_field_types type() const { return m_type; } - uint char_length() const { return m_char_length; } - uint unsigned_flag() const { return m_unsigned_flag; } + ST_FIELD_INFO(const char *name, const Type &type, + enum_nullability nullability, + const char *old_name, + enum_show_open_table open_method) + :Type(type), m_nullability(nullability), m_open_method(open_method) + { + m_name.str= name; + m_name.length= safe_strlen(name); + m_old_name.str= old_name; + m_old_name.length= safe_strlen(old_name); + } + const LEX_CSTRING &name() const { return m_name; } + bool nullable() const { return m_nullability == NULLABLE; } + const LEX_CSTRING &old_name() const { return m_old_name; } + enum_show_open_table open_method() const { return m_open_method; } + bool end_marker() const { return m_name.str == NULL; } }; +namespace Show +{ + class Blob: public Type { public: - Blob(uint length) :Type(MYSQL_TYPE_BLOB, length, false) { } + Blob(uint length) :Type(&type_handler_blob, length, false) { } }; class Varchar: public Type { public: - Varchar(uint length) :Type(MYSQL_TYPE_STRING, length, false) + Varchar(uint length) :Type(&type_handler_varchar, length, false) { DBUG_ASSERT(length * 3 <= MAX_FIELD_VARCHARLENGTH); } @@ -137,7 +136,7 @@ public: class Longtext: public Type { public: - Longtext(uint length) :Type(MYSQL_TYPE_STRING, length, false) { } + Longtext(uint length) :Type(&type_handler_varchar, length, false) { } }; @@ -193,21 +192,21 @@ public: class Datetime: public Type { public: - Datetime(uint dec) :Type(MYSQL_TYPE_DATETIME, dec, false) { } + Datetime(uint dec) :Type(&type_handler_datetime2, dec, false) { } }; class Decimal: public Type { public: - Decimal(uint length) :Type(MYSQL_TYPE_DECIMAL, length, false) { } + Decimal(uint length) :Type(&type_handler_newdecimal, length, false) { } }; class ULonglong: public Type { public: - ULonglong(uint length) :Type(MYSQL_TYPE_LONGLONG, length, true) { } + ULonglong(uint length) :Type(&type_handler_longlong, length, true) { } ULonglong() :ULonglong(MY_INT64_NUM_DECIMAL_DIGITS) { } }; @@ -215,7 +214,7 @@ public: class ULong: public Type { public: - ULong(uint length) :Type(MYSQL_TYPE_LONG, length, true) { } + ULong(uint length) :Type(&type_handler_long, length, true) { } ULong() :ULong(MY_INT32_NUM_DECIMAL_DIGITS) { } }; @@ -223,7 +222,7 @@ public: class SLonglong: public Type { public: - SLonglong(uint length) :Type(MYSQL_TYPE_LONGLONG, length, false) { } + SLonglong(uint length) :Type(&type_handler_longlong, length, false) { } SLonglong() :SLonglong(MY_INT64_NUM_DECIMAL_DIGITS) { } }; @@ -231,7 +230,7 @@ public: class SLong: public Type { public: - SLong(uint length) :Type(MYSQL_TYPE_LONG, length, false) { } + SLong(uint length) :Type(&type_handler_long, length, false) { } SLong() :SLong(MY_INT32_NUM_DECIMAL_DIGITS) { } }; @@ -239,28 +238,28 @@ public: class SShort: public Type { public: - SShort(uint length) :Type(MYSQL_TYPE_SHORT, length, false) { } + SShort(uint length) :Type(&type_handler_short, length, false) { } }; class STiny: public Type { public: - STiny(uint length) :Type(MYSQL_TYPE_TINY, length, false) { } + STiny(uint length) :Type(&type_handler_tiny, length, false) { } }; class Double: public Type { public: - Double(uint length) :Type(MYSQL_TYPE_DOUBLE, length, false) { } + Double(uint length) :Type(&type_handler_double, length, false) { } }; class Float: public Type { public: - Float(uint length) :Type(MYSQL_TYPE_FLOAT, length, false) { } + Float(uint length) :Type(&type_handler_float, length, false) { } }; @@ -271,17 +270,8 @@ public: Column(const char *name, const Type &type, enum_nullability nullability, const char *old_name, enum_show_open_table open_method= SKIP_OPEN_TABLE) - { - ST_FIELD_INFO::field_name= name; - ST_FIELD_INFO::field_length= type.char_length(); - ST_FIELD_INFO::field_type= type.type(); - ST_FIELD_INFO::value= 0; - ST_FIELD_INFO::field_flags= - (type.unsigned_flag() ? MY_I_S_UNSIGNED : 0) | - (nullability == NULLABLE ? MY_I_S_MAYBE_NULL : 0); - ST_FIELD_INFO::old_name= old_name; - ST_FIELD_INFO::open_method= open_method; - } + :ST_FIELD_INFO(name, type, nullability, old_name, open_method) + { } Column(const char *name, const Type &type, enum_nullability nullability, enum_show_open_table open_method= SKIP_OPEN_TABLE) :Column(name, type, nullability, NullS, open_method) diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc index 996a7249db4..5949287ea8d 100644 --- a/sql/sql_profile.cc +++ b/sql/sql_profile.cc @@ -115,17 +115,17 @@ int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table) Name_resolution_context *context= &thd->lex->first_select_lex()->context; int i; - for (i= 0; schema_table->fields_info[i].field_name != NULL; i++) + for (i= 0; !schema_table->fields_info[i].end_marker(); i++) { if (! fields_include_condition_truth_values[i]) continue; field_info= &schema_table->fields_info[i]; Item_field *field= new (thd->mem_root) Item_field(thd, context, - Lex_cstring_strlen(field_info->field_name)); + field_info->name()); if (field) { - field->set_name(thd, field_info->get_old_name()); + field->set_name(thd, field_info->old_name()); if (add_item_to_list(thd, field)) return 1; } diff --git a/sql/sql_profile.h b/sql/sql_profile.h index 59db4682440..b0b1642ee02 100644 --- a/sql/sql_profile.h +++ b/sql/sql_profile.h @@ -19,7 +19,7 @@ class Item; struct TABLE_LIST; class THD; -struct ST_FIELD_INFO; +class ST_FIELD_INFO; typedef struct st_schema_table ST_SCHEMA_TABLE; namespace Show { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a64eee24110..9d31f266ee0 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -18730,12 +18730,12 @@ bool Create_tmp_table::add_schema_fields(THD *thd, TABLE *table, MEM_ROOT *mem_root_save= thd->mem_root; thd->mem_root= &table->mem_root; - for (fieldnr= 0; defs[fieldnr].field_name; fieldnr++) + for (fieldnr= 0; !defs[fieldnr].end_marker(); fieldnr++) { const ST_FIELD_INFO &def= defs[fieldnr]; bool visible= bitmap_is_set(&bitmap, fieldnr); - Record_addr addr(def.field_flags & MY_I_S_MAYBE_NULL); - const Type_handler *h= Type_handler::get_handler_by_real_type(def.field_type); + Record_addr addr(def.nullable()); + const Type_handler *h= def.type_handler(); Field *field= h->make_schema_field(table, addr, def, visible); if (!field) { @@ -26173,16 +26173,14 @@ bool JOIN_TAB::save_explain_data(Explain_table_access *eta, table_list->schema_table->i_s_requested_object & OPTIMIZE_I_S_TABLE) { IS_table_read_plan *is_table_read_plan= table_list->is_table_read_plan; - const char *tmp_buff; - int f_idx; StringBuffer<64> key_name_buf; if (is_table_read_plan->trivial_show_command || is_table_read_plan->has_db_lookup_value()) { /* The "key" has the name of the column referring to the database */ - f_idx= table_list->schema_table->idx_field1; - tmp_buff= table_list->schema_table->fields_info[f_idx].field_name; - key_name_buf.append(tmp_buff, strlen(tmp_buff), cs); + int f_idx= table_list->schema_table->idx_field1; + LEX_CSTRING tmp= table_list->schema_table->fields_info[f_idx].name(); + key_name_buf.append(tmp, cs); } if (is_table_read_plan->trivial_show_command || is_table_read_plan->has_table_lookup_value()) @@ -26191,9 +26189,9 @@ bool JOIN_TAB::save_explain_data(Explain_table_access *eta, is_table_read_plan->has_db_lookup_value()) key_name_buf.append(','); - f_idx= table_list->schema_table->idx_field2; - tmp_buff= table_list->schema_table->fields_info[f_idx].field_name; - key_name_buf.append(tmp_buff, strlen(tmp_buff), cs); + int f_idx= table_list->schema_table->idx_field2; + LEX_CSTRING tmp= table_list->schema_table->fields_info[f_idx].name(); + key_name_buf.append(tmp, cs); } if (key_name_buf.length()) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 6b9a35f2888..947985fa6bf 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3960,9 +3960,9 @@ bool get_lookup_value(THD *thd, Item_func *item_func, ST_SCHEMA_TABLE *schema_table= table->schema_table; ST_FIELD_INFO *field_info= schema_table->fields_info; const char *field_name1= schema_table->idx_field1 >= 0 ? - field_info[schema_table->idx_field1].field_name : ""; + field_info[schema_table->idx_field1].name().str : ""; const char *field_name2= schema_table->idx_field2 >= 0 ? - field_info[schema_table->idx_field2].field_name : ""; + field_info[schema_table->idx_field2].name().str : ""; if (item_func->functype() == Item_func::EQ_FUNC || item_func->functype() == Item_func::EQUAL_FUNC) @@ -4098,9 +4098,9 @@ bool uses_only_table_name_fields(Item *item, TABLE_LIST *table) ST_SCHEMA_TABLE *schema_table= table->schema_table; ST_FIELD_INFO *field_info= schema_table->fields_info; const char *field_name1= schema_table->idx_field1 >= 0 ? - field_info[schema_table->idx_field1].field_name : ""; + field_info[schema_table->idx_field1].name().str : ""; const char *field_name2= schema_table->idx_field2 >= 0 ? - field_info[schema_table->idx_field2].field_name : ""; + field_info[schema_table->idx_field2].name().str : ""; if (table->table != item_field->field->table || (cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1), (uchar *) item_field->field_name.str, @@ -4806,18 +4806,18 @@ uint get_table_open_method(TABLE_LIST *tables, if (schema_table->i_s_requested_object & OPTIMIZE_I_S_TABLE) { Field **ptr, *field; - int table_open_method= 0, field_indx= 0; + uint table_open_method= 0, field_indx= 0; uint star_table_open_method= OPEN_FULL_TABLE; bool used_star= true; // true if '*' is used in select for (ptr=tables->table->field; (field= *ptr) ; ptr++) { + const ST_FIELD_INFO &def= schema_table->fields_info[field_indx]; star_table_open_method= - MY_MIN(star_table_open_method, - (uint) schema_table->fields_info[field_indx].open_method); + MY_MIN(star_table_open_method, (uint) def.open_method()); if (bitmap_is_set(tables->table->read_set, field->field_index)) { used_star= false; - table_open_method|= schema_table->fields_info[field_indx].open_method; + table_open_method|= (uint) def.open_method(); } field_indx++; } @@ -8132,9 +8132,9 @@ mark_all_fields_used_in_query(THD *thd, bitmap_set_all(bitmap); break; } - for (count=0; fields->field_name; fields++, count++) + for (count=0; !fields->end_marker(); fields++, count++) { - if (!my_strcasecmp(system_charset_info, fields->field_name, + if (!my_strcasecmp(system_charset_info, fields->name().str, item_field->field_name.str)) { bitmap_set_bit(bitmap, count); @@ -8179,7 +8179,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list) my_bitmap_map *buf; DBUG_ENTER("create_schema_table"); - for (field_count= 0, fields= fields_info; fields->field_name; fields++) + for (field_count= 0, fields= fields_info; !fields->end_marker(); fields++) field_count++; if (!(buf= (my_bitmap_map*) thd->alloc(bitmap_buffer_size(field_count)))) DBUG_RETURN(NULL); @@ -8239,16 +8239,16 @@ static int make_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) { ST_FIELD_INFO *field_info= schema_table->fields_info; Name_resolution_context *context= &thd->lex->first_select_lex()->context; - for (; field_info->field_name; field_info++) + for (; !field_info->end_marker(); field_info++) { - if (field_info->old_name) + if (field_info->old_name().str) { - LEX_CSTRING field_name= field_info->get_name(); + LEX_CSTRING field_name= field_info->name(); Item_field *field= new (thd->mem_root) Item_field(thd, context, field_name); if (field) { - field->set_name(thd, field_info->get_old_name()); + field->set_name(thd, field_info->old_name()); if (add_item_to_list(thd, field)) return 1; } @@ -8270,11 +8270,11 @@ int make_schemata_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) ST_FIELD_INFO *field_info= &schema_table->fields_info[1]; String buffer(tmp,sizeof(tmp), system_charset_info); Item_field *field= new (thd->mem_root) Item_field(thd, context, - field_info->get_name()); + field_info->name()); if (!field || add_item_to_list(thd, field)) return 1; buffer.length(0); - buffer.append(field_info->get_old_name()); + buffer.append(field_info->old_name()); if (lex->wild && lex->wild->ptr()) { buffer.append(STRING_WITH_LEN(" (")); @@ -8294,10 +8294,10 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) LEX *lex= thd->lex; Name_resolution_context *context= &lex->first_select_lex()->context; ST_FIELD_INFO *field_info= &schema_table->fields_info[2]; - LEX_CSTRING field_name= Lex_cstring_strlen(field_info->field_name); + LEX_CSTRING field_name= field_info->name(); buffer.length(0); - buffer.append(field_info->get_old_name()); + buffer.append(field_info->old_name()); buffer.append(&lex->first_select_lex()->db); if (lex->wild && lex->wild->ptr()) { @@ -8312,11 +8312,10 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) if (thd->lex->verbose) { field_info= &schema_table->fields_info[3]; - field= new (thd->mem_root) Item_field(thd, context, - Lex_cstring_strlen(field_info->field_name)); + field= new (thd->mem_root) Item_field(thd, context, field_info->name()); if (add_item_to_list(thd, field)) return 1; - field->set_name(thd, field_info->get_old_name()); + field->set_name(thd, field_info->old_name()); } return 0; } @@ -8337,10 +8336,10 @@ int make_columns_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) *field_num == 19)) continue; Item_field *field= new (thd->mem_root) Item_field(thd, context, - Lex_cstring_strlen(field_info->field_name)); + field_info->name()); if (field) { - field->set_name(thd, field_info->get_old_name()); + field->set_name(thd, field_info->old_name()); if (add_item_to_list(thd, field)) return 1; } @@ -8360,10 +8359,10 @@ int make_character_sets_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) { field_info= &schema_table->fields_info[*field_num]; Item_field *field= new (thd->mem_root) Item_field(thd, context, - Lex_cstring_strlen(field_info->field_name)); + field_info->name()); if (field) { - field->set_name(thd, field_info->get_old_name()); + field->set_name(thd, field_info->old_name()); if (add_item_to_list(thd, field)) return 1; } @@ -8383,10 +8382,10 @@ int make_proc_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) { field_info= &schema_table->fields_info[*field_num]; Item_field *field= new (thd->mem_root) Item_field(thd, context, - Lex_cstring_strlen(field_info->field_name)); + field_info->name()); if (field) { - field->set_name(thd, field_info->get_old_name()); + field->set_name(thd, field_info->old_name()); if (add_item_to_list(thd, field)) return 1; } @@ -9437,7 +9436,7 @@ ST_FIELD_INFO files_fields_info[]= void init_fill_schema_files_row(TABLE* table) { int i; - for(i=0; Show::files_fields_info[i].field_name!=NULL; i++) + for(i=0; !Show::files_fields_info[i].end_marker(); i++) table->field[i]->set_null(); table->field[IS_FILES_STATUS]->set_notnull(); @@ -9729,8 +9728,8 @@ int initialize_schema_table(st_plugin_int *plugin) } if (!schema_table->old_format) - for (ST_FIELD_INFO *f= schema_table->fields_info; f->field_name; f++) - if (f->old_name && f->old_name[0]) + for (ST_FIELD_INFO *f= schema_table->fields_info; !f->end_marker(); f++) + if (f->old_name().str && f->old_name().str[0]) { schema_table->old_format= make_old_format; break; diff --git a/sql/sql_string.h b/sql/sql_string.h index b343200aa77..4e4164b9d37 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -904,6 +904,10 @@ public: // Append with optional character set conversion from cs to charset() bool append(const char *s, size_t arg_length, CHARSET_INFO *cs); + bool append(const LEX_CSTRING &s, CHARSET_INFO *cs) + { + return append(s.str, s.length, cs); + } void strip_sp(); friend int sortcmp(const String *a,const String *b, CHARSET_INFO *cs); diff --git a/sql/sql_type.cc b/sql/sql_type.cc index 1a1051f9fbe..33096a193d3 100644 --- a/sql/sql_type.cc +++ b/sql/sql_type.cc @@ -3437,9 +3437,9 @@ Field *Type_handler_float::make_schema_field(TABLE *table, const ST_FIELD_INFO &def, bool show_field) const { - Lex_cstring_strlen name(def.field_name); + LEX_CSTRING name= def.name(); return new (table->in_use->mem_root) - Field_float(addr.ptr(), def.field_length, + Field_float(addr.ptr(), def.char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, (uint8) NOT_FIXED_DEC, @@ -3452,9 +3452,9 @@ Field *Type_handler_double::make_schema_field(TABLE *table, const ST_FIELD_INFO &def, bool show_field) const { - Lex_cstring_strlen name(def.field_name); + LEX_CSTRING name= def.name(); return new (table->in_use->mem_root) - Field_double(addr.ptr(), def.field_length, + Field_double(addr.ptr(), def.char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, (uint8) NOT_FIXED_DEC, @@ -3467,9 +3467,9 @@ Field *Type_handler_decimal_result::make_schema_field(TABLE *table, const ST_FIELD_INFO &def, bool show_field) const { - Lex_cstring_strlen name(def.field_name); - uint dec= def.field_length % 10; - uint prec= (def.field_length / 100) % 100; + LEX_CSTRING name= def.name(); + uint dec= def.decimal_scale(); + uint prec= def.decimal_precision(); DBUG_ASSERT(dec <= DECIMAL_MAX_SCALE); uint32 len= my_decimal_precision_to_length(prec, dec, def.unsigned_flag()); return new (table->in_use->mem_root) @@ -3484,7 +3484,7 @@ Field *Type_handler_blob_common::make_schema_field(TABLE *table, const ST_FIELD_INFO &def, bool show_field) const { - Lex_cstring_strlen name(def.field_name); + LEX_CSTRING name= def.name(); if (show_field) { return new (table->in_use->mem_root) @@ -3499,15 +3499,15 @@ Field *Type_handler_blob_common::make_schema_field(TABLE *table, } -Field *Type_handler_string::make_schema_field(TABLE *table, - const Record_addr &addr, - const ST_FIELD_INFO &def, - bool show_field) const +Field *Type_handler_varchar::make_schema_field(TABLE *table, + const Record_addr &addr, + const ST_FIELD_INFO &def, + bool show_field) const { - DBUG_ASSERT(def.field_length); - Lex_cstring_strlen name(def.field_name); - uint32 octet_length= (uint32) def.field_length * 3; - if (def.field_length * 3 > MAX_FIELD_VARCHARLENGTH) + DBUG_ASSERT(def.char_length()); + LEX_CSTRING name= def.name(); + uint32 octet_length= (uint32) def.char_length() * 3; + if (octet_length > MAX_FIELD_VARCHARLENGTH) { Field *field= new (table->in_use->mem_root) Field_blob(addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, @@ -3536,9 +3536,9 @@ Field *Type_handler_tiny::make_schema_field(TABLE *table, const ST_FIELD_INFO &def, bool show_field) const { - Lex_cstring_strlen name(def.field_name); + LEX_CSTRING name= def.name(); return new (table->in_use->mem_root) - Field_tiny(addr.ptr(), def.field_length, + Field_tiny(addr.ptr(), def.char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, 0/*zerofill*/, def.unsigned_flag()); } @@ -3549,9 +3549,9 @@ Field *Type_handler_short::make_schema_field(TABLE *table, const ST_FIELD_INFO &def, bool show_field) const { - Lex_cstring_strlen name(def.field_name); + LEX_CSTRING name= def.name(); return new (table->in_use->mem_root) - Field_short(addr.ptr(), def.field_length, + Field_short(addr.ptr(), def.char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, 0/*zerofill*/, def.unsigned_flag()); } @@ -3562,9 +3562,9 @@ Field *Type_handler_long::make_schema_field(TABLE *table, const ST_FIELD_INFO &def, bool show_field) const { - Lex_cstring_strlen name(def.field_name); + LEX_CSTRING name= def.name(); return new (table->in_use->mem_root) - Field_long(addr.ptr(), def.field_length, + Field_long(addr.ptr(), def.char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, 0/*zerofill*/, def.unsigned_flag()); } @@ -3575,9 +3575,9 @@ Field *Type_handler_longlong::make_schema_field(TABLE *table, const ST_FIELD_INFO &def, bool show_field) const { - Lex_cstring_strlen name(def.field_name); + LEX_CSTRING name= def.name(); return new (table->in_use->mem_root) - Field_longlong(addr.ptr(), def.field_length, + Field_longlong(addr.ptr(), def.char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, 0/*zerofill*/, def.unsigned_flag()); } @@ -3588,7 +3588,7 @@ Field *Type_handler_date_common::make_schema_field(TABLE *table, const ST_FIELD_INFO &def, bool show_field) const { - Lex_cstring_strlen name(def.field_name); + LEX_CSTRING name= def.name(); return new (table->in_use->mem_root) Field_newdate(addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name); @@ -3600,7 +3600,7 @@ Field *Type_handler_time_common::make_schema_field(TABLE *table, const ST_FIELD_INFO &def, bool show_field) const { - Lex_cstring_strlen name(def.field_name); + LEX_CSTRING name= def.name(); return new_Field_time(table->in_use->mem_root, addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, def.fsp()); @@ -3612,7 +3612,7 @@ Field *Type_handler_datetime_common::make_schema_field(TABLE *table, const ST_FIELD_INFO &def, bool show_field) const { - Lex_cstring_strlen name(def.field_name); + LEX_CSTRING name= def.name(); return new_Field_datetime(table->in_use->mem_root, addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, def.fsp()); diff --git a/sql/sql_type.h b/sql/sql_type.h index aaf42558fa3..691945383a8 100644 --- a/sql/sql_type.h +++ b/sql/sql_type.h @@ -86,7 +86,7 @@ struct SORT_FIELD_ATTR; class Vers_history_point; class Virtual_column_info; class Conv_source; -struct ST_FIELD_INFO; +class ST_FIELD_INFO; #define my_charset_numeric my_charset_latin1 @@ -6044,10 +6044,6 @@ public: const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; - Field *make_schema_field(TABLE *table, - const Record_addr &addr, - const ST_FIELD_INFO &def, - bool show_field) const; Field *make_table_field_from_def(TABLE_SHARE *share, MEM_ROOT *mem_root, const LEX_CSTRING *name, @@ -6128,6 +6124,10 @@ public: const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; + Field *make_schema_field(TABLE *table, + const Record_addr &addr, + const ST_FIELD_INFO &def, + bool show_field) const; Field *make_table_field_from_def(TABLE_SHARE *share, MEM_ROOT *mem_root, const LEX_CSTRING *name, |