mirror of
https://github.com/MariaDB/server.git
synced 2025-12-28 08:10:14 +00:00
MDEV-38436 Remove Type_handler::Column_definition_fix_attributes()
This commit is contained in:
parent
797f50d107
commit
9e2cfac9c1
@ -329,11 +329,6 @@ public:
|
||||
return storage_type_handler()->Item_send(item, protocol, buf);
|
||||
}
|
||||
|
||||
bool Column_definition_fix_attributes(Column_definition *def) const override
|
||||
{
|
||||
return storage_type_handler()->Column_definition_fix_attributes(def);
|
||||
}
|
||||
|
||||
bool Column_definition_prepare_stage2(Column_definition *c,
|
||||
handler *file,
|
||||
ulonglong table_flags) const override
|
||||
|
||||
@ -37,7 +37,11 @@ public:
|
||||
Field *make_table_field(MEM_ROOT *, const LEX_CSTRING *,
|
||||
const Record_addr &, const Type_all_attributes &,
|
||||
TABLE_SHARE *) const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override
|
||||
{
|
||||
my_error(ER_NOT_ALLOWED_IN_THIS_CONTEXT, MYF(0), "MYSQL_JSON");
|
||||
return true;
|
||||
|
||||
@ -10986,7 +10986,7 @@ bool Column_definition::check(THD *thd)
|
||||
*/
|
||||
Item_func *fn= static_cast<Item_func*>(default_value->expr);
|
||||
if (fn->functype() == Item_func::NOW_FUNC &&
|
||||
(fn->decimals == 0 || fn->decimals >= length))
|
||||
(fn->decimals == 0 || fn->decimals >= decimals))
|
||||
{
|
||||
default_value= 0;
|
||||
unireg_check= Field::TIMESTAMP_DN_FIELD;
|
||||
@ -10996,7 +10996,7 @@ bool Column_definition::check(THD *thd)
|
||||
if (on_update)
|
||||
{
|
||||
if (mysql_timestamp_type() != MYSQL_TIMESTAMP_DATETIME ||
|
||||
on_update->decimals < length)
|
||||
on_update->decimals < decimals)
|
||||
{
|
||||
my_error(ER_INVALID_ON_UPDATE, MYF(0), field_name.str);
|
||||
DBUG_RETURN(TRUE);
|
||||
@ -11007,9 +11007,6 @@ bool Column_definition::check(THD *thd)
|
||||
else if (flags & AUTO_INCREMENT_FLAG)
|
||||
unireg_check= Field::NEXT_NUMBER;
|
||||
|
||||
if (type_handler()->Column_definition_fix_attributes(this))
|
||||
DBUG_RETURN(true);
|
||||
|
||||
/* Remember the value of length */
|
||||
char_length= (uint)length;
|
||||
|
||||
|
||||
@ -8785,7 +8785,9 @@ static Create_field *vers_init_sys_field(THD *thd,
|
||||
else
|
||||
{
|
||||
f->set_handler(&type_handler_timestamp2);
|
||||
f->length= MAX_DATETIME_PRECISION;
|
||||
f->length= MAX_DATETIME_FULL_WIDTH;
|
||||
f->decimals= MAX_DATETIME_PRECISION;
|
||||
f->flags|= UNSIGNED_FLAG;
|
||||
}
|
||||
f->invisible= DBUG_IF("sysvers_show") ? VISIBLE : INVISIBLE_SYSTEM;
|
||||
|
||||
|
||||
@ -737,7 +737,6 @@ public:
|
||||
function return values.
|
||||
|
||||
@param[in] thd Thread handle
|
||||
@param[in] lex Yacc parsing context
|
||||
@param[out] field_def An instance of create_field to be filled
|
||||
|
||||
@retval false on success
|
||||
@ -745,9 +744,7 @@ public:
|
||||
*/
|
||||
bool fill_field_definition(THD *thd, Column_definition *field_def)
|
||||
{
|
||||
const Type_handler *h= field_def->type_handler();
|
||||
return h->Column_definition_fix_attributes(field_def) ||
|
||||
field_def->sp_prepare_create_field(thd, mem_root);
|
||||
return field_def->sp_prepare_create_field(thd, mem_root);
|
||||
}
|
||||
bool row_fill_field_definitions(THD *thd, Row_definition_list *row)
|
||||
{
|
||||
|
||||
@ -204,7 +204,6 @@ bool quick_rm_table(THD *thd, handlerton *base, const LEX_CSTRING *db,
|
||||
const LEX_CSTRING *table_name, uint flags,
|
||||
const char *table_path=0);
|
||||
void close_cached_table(THD *thd, TABLE *table);
|
||||
void sp_prepare_create_field(THD *thd, Column_definition *sql_field);
|
||||
bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags);
|
||||
int write_bin_log(THD *thd, bool clear_error,
|
||||
char const *query, ulong query_length,
|
||||
|
||||
308
sql/sql_type.cc
308
sql/sql_type.cc
@ -2786,6 +2786,104 @@ Type_handler::Column_definition_set_attributes(THD *thd,
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Type_handler_general_purpose_int::Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
return
|
||||
Type_handler_int_result::Column_definition_set_attributes(thd, def,
|
||||
attr, type)||
|
||||
def->fix_attributes_int(type_limits_int()->char_length());
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Type_handler_int24::Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
return
|
||||
Type_handler_int_result::Column_definition_set_attributes(thd, def,
|
||||
attr, type) ||
|
||||
def->fix_attributes_int(MAX_MEDIUMINT_WIDTH + def->sign_length());
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Type_handler_year::Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
if (Type_handler_int_result::Column_definition_set_attributes(thd, def,
|
||||
attr, type))
|
||||
return true;
|
||||
if (!def->length || def->length != 2)
|
||||
def->length= 4; // Default length
|
||||
def->flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Type_handler_bit::Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
return
|
||||
Type_handler_int_result::Column_definition_set_attributes(thd, def,
|
||||
attr, type) ||
|
||||
def->fix_attributes_bit();
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_float::Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
return
|
||||
Type_handler_real_result::Column_definition_set_attributes(thd, def,
|
||||
attr, type) ||
|
||||
def->fix_attributes_real(MAX_FLOAT_STR_LENGTH);
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_double::Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
return
|
||||
Type_handler_real_result::Column_definition_set_attributes(thd, def,
|
||||
attr, type) ||
|
||||
def->fix_attributes_real(DBL_DIG + 7);
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_decimal_result::Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
// Old decimal is obsolete
|
||||
DBUG_ASSERT(!dynamic_cast<const Type_handler_olddecimal*>(this));
|
||||
return Type_handler::Column_definition_set_attributes(thd, def, attr, type) ||
|
||||
def->fix_attributes_decimal();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
In sql_mode=ORACLE, real size of VARCHAR and CHAR with no length
|
||||
in SP parameters is fixed at runtime with the length of real args.
|
||||
@ -2812,9 +2910,11 @@ Type_handler_string::Column_definition_set_attributes(
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
Type_handler::Column_definition_set_attributes(thd, def, attr, type);
|
||||
if (Type_handler_longstr::Column_definition_set_attributes(thd, def,
|
||||
attr, type))
|
||||
return true;
|
||||
if (attr.has_explicit_length())
|
||||
return false;
|
||||
return def->check_length(ER_TOO_BIG_FIELDLENGTH, MAX_FIELD_CHARLENGTH);
|
||||
switch (type) {
|
||||
case COLUMN_DEFINITION_ROUTINE_PARAM:
|
||||
case COLUMN_DEFINITION_FUNCTION_RETURN:
|
||||
@ -2843,9 +2943,17 @@ Type_handler_varchar::Column_definition_set_attributes(
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
Type_handler::Column_definition_set_attributes(thd, def, attr, type);
|
||||
if (Type_handler_longstr::Column_definition_set_attributes(thd, def,
|
||||
attr, type))
|
||||
return true;
|
||||
if (attr.has_explicit_length())
|
||||
return false;
|
||||
{
|
||||
/*
|
||||
Long VARCHAR's are automaticly converted to blobs in mysql_prepare_table
|
||||
if they don't have a default value
|
||||
*/
|
||||
return def->check_length(ER_TOO_BIG_DISPLAYWIDTH, MAX_FIELD_BLOBLENGTH);
|
||||
}
|
||||
switch (type) {
|
||||
case COLUMN_DEFINITION_ROUTINE_PARAM:
|
||||
case COLUMN_DEFINITION_FUNCTION_RETURN:
|
||||
@ -2870,156 +2978,110 @@ Type_handler_varchar::Column_definition_set_attributes(
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
bool Type_handler_null::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type_handler_tiny::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
{
|
||||
return def->fix_attributes_int(MAX_TINYINT_WIDTH + def->sign_length());
|
||||
}
|
||||
|
||||
bool Type_handler_short::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
{
|
||||
return def->fix_attributes_int(MAX_SMALLINT_WIDTH + def->sign_length());
|
||||
}
|
||||
|
||||
bool Type_handler_int24::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
{
|
||||
return def->fix_attributes_int(MAX_MEDIUMINT_WIDTH + def->sign_length());
|
||||
}
|
||||
|
||||
bool Type_handler_long::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
{
|
||||
return def->fix_attributes_int(MAX_INT_WIDTH + def->sign_length());
|
||||
}
|
||||
|
||||
bool Type_handler_longlong::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
{
|
||||
return def->fix_attributes_int(MAX_BIGINT_WIDTH/*no sign_length() added*/);
|
||||
}
|
||||
|
||||
bool Type_handler_newdecimal::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
{
|
||||
return def->fix_attributes_decimal();
|
||||
}
|
||||
|
||||
bool Type_handler_olddecimal::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
{
|
||||
DBUG_ASSERT(0); // Obsolete
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Type_handler_var_string::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
{
|
||||
DBUG_ASSERT(0); // Obsolete
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Type_handler_varchar::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
{
|
||||
/*
|
||||
Long VARCHAR's are automaticly converted to blobs in mysql_prepare_table
|
||||
if they don't have a default value
|
||||
*/
|
||||
return def->check_length(ER_TOO_BIG_DISPLAYWIDTH, MAX_FIELD_BLOBLENGTH);
|
||||
}
|
||||
|
||||
bool Type_handler_string::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
{
|
||||
return def->check_length(ER_TOO_BIG_FIELDLENGTH, MAX_FIELD_CHARLENGTH);
|
||||
}
|
||||
|
||||
bool Type_handler_blob_common::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
bool
|
||||
Type_handler_blob_common::Column_definition_set_attributes(
|
||||
THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
if (Type_handler_longstr::Column_definition_set_attributes(thd, def,
|
||||
attr, type))
|
||||
return true;
|
||||
def->flags|= BLOB_FLAG;
|
||||
return def->check_length(ER_TOO_BIG_DISPLAYWIDTH, MAX_FIELD_BLOBLENGTH);
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_year::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
bool Type_handler_enum::Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
if (!def->length || def->length != 2)
|
||||
def->length= 4; // Default length
|
||||
def->flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
|
||||
if (Type_handler_typelib::Column_definition_set_attributes(thd, def,
|
||||
attr, type))
|
||||
return true;
|
||||
def->pack_length= get_enum_pack_length(def->interval_list.elements);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type_handler_float::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
|
||||
bool Type_handler_set::Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
return def->fix_attributes_real(MAX_FLOAT_STR_LENGTH);
|
||||
if (Type_handler_typelib::Column_definition_set_attributes(thd, def,
|
||||
attr, type))
|
||||
return true;
|
||||
def->pack_length= get_set_pack_length(def->interval_list.elements);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_double::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
bool Type_handler_time_common::Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
return def->fix_attributes_real(DBL_DIG + 7);
|
||||
return
|
||||
Type_handler_temporal_result::Column_definition_set_attributes(thd, def,
|
||||
attr,
|
||||
type) ||
|
||||
def->fix_attributes_temporal_with_time(MIN_TIME_WIDTH);
|
||||
}
|
||||
|
||||
bool Type_handler_timestamp_common::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
{
|
||||
def->flags|= UNSIGNED_FLAG;
|
||||
return def->fix_attributes_temporal_with_time(MAX_DATETIME_WIDTH);
|
||||
}
|
||||
|
||||
bool Type_handler_date_common::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
bool Type_handler_date_common::Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
if (Type_handler_temporal_with_date::Column_definition_set_attributes(thd,
|
||||
def,
|
||||
attr,
|
||||
type))
|
||||
return true;
|
||||
// We don't support creation of MYSQL_TYPE_DATE anymore
|
||||
def->set_handler(&type_handler_newdate);
|
||||
def->length= MAX_DATE_WIDTH;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type_handler_time_common::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
|
||||
bool Type_handler_datetime_common::Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
return def->fix_attributes_temporal_with_time(MIN_TIME_WIDTH);
|
||||
return
|
||||
Type_handler_temporal_with_date::Column_definition_set_attributes(thd, def,
|
||||
attr,
|
||||
type) ||
|
||||
def->fix_attributes_temporal_with_time(MAX_DATETIME_WIDTH);
|
||||
}
|
||||
|
||||
bool Type_handler_datetime_common::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
|
||||
bool Type_handler_timestamp_common::Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
return def->fix_attributes_temporal_with_time(MAX_DATETIME_WIDTH);
|
||||
def->flags|= UNSIGNED_FLAG;
|
||||
return
|
||||
Type_handler_temporal_with_date::Column_definition_set_attributes(thd, def,
|
||||
attr,
|
||||
type) ||
|
||||
def->fix_attributes_temporal_with_time(MAX_DATETIME_WIDTH);
|
||||
}
|
||||
|
||||
bool Type_handler_set::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
{
|
||||
def->pack_length= get_set_pack_length(def->interval_list.elements);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type_handler_enum::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
{
|
||||
def->pack_length= get_enum_pack_length(def->interval_list.elements);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type_handler_bit::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
{
|
||||
return def->fix_attributes_bit();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
@ -4319,8 +4319,6 @@ public:
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const;
|
||||
// Fix attributes after the parser
|
||||
virtual bool Column_definition_fix_attributes(Column_definition *c) const= 0;
|
||||
/*
|
||||
Fix attributes from an existing field. Used for:
|
||||
- ALTER TABLE (for columns that do not change)
|
||||
@ -5081,6 +5079,11 @@ public:
|
||||
uint make_packed_sort_key_part(uchar *to, Item *item,
|
||||
const SORT_FIELD_ATTR *sort_field,
|
||||
String *tmp) const override;
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
void
|
||||
Column_definition_attributes_frm_pack(const Column_definition_attributes *at,
|
||||
uchar *buff) const override;
|
||||
@ -5455,6 +5458,11 @@ public:
|
||||
{
|
||||
return type_limits_int()->char_length();
|
||||
}
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
uint32 Item_decimal_notation_int_digits(const Item *item) const override;
|
||||
bool Item_hybrid_func_fix_attributes(THD *thd,
|
||||
const LEX_CSTRING &name,
|
||||
@ -5789,7 +5797,6 @@ public:
|
||||
Field *make_conversion_table_field(MEM_ROOT *root,
|
||||
TABLE *table, uint metadata,
|
||||
const Field *target) const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_prepare_stage2(Column_definition *c,
|
||||
handler *file,
|
||||
ulonglong table_flags) const override
|
||||
@ -5840,7 +5847,6 @@ public:
|
||||
Field *make_conversion_table_field(MEM_ROOT *root,
|
||||
TABLE *table, uint metadata,
|
||||
const Field *target) const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_prepare_stage2(Column_definition *c,
|
||||
handler *file,
|
||||
ulonglong table_flags) const override
|
||||
@ -5891,7 +5897,6 @@ public:
|
||||
Field *make_conversion_table_field(MEM_ROOT *root,
|
||||
TABLE *table, uint metadata,
|
||||
const Field *target) const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_prepare_stage2(Column_definition *c,
|
||||
handler *file,
|
||||
ulonglong table_flags) const override
|
||||
@ -5991,7 +5996,6 @@ public:
|
||||
Field *make_conversion_table_field(MEM_ROOT *root,
|
||||
TABLE *table, uint metadata,
|
||||
const Field *target) const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_prepare_stage2(Column_definition *c,
|
||||
handler *file,
|
||||
ulonglong table_flags) const override
|
||||
@ -6056,7 +6060,11 @@ public:
|
||||
Field *make_conversion_table_field(MEM_ROOT *mem_root,
|
||||
TABLE *table, uint metadata,
|
||||
const Field *target) const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
bool Column_definition_prepare_stage2(Column_definition *c,
|
||||
handler *file,
|
||||
ulonglong table_flags) const override
|
||||
@ -6102,7 +6110,11 @@ public:
|
||||
Field *make_conversion_table_field(MEM_ROOT *root,
|
||||
TABLE *table, uint metadata,
|
||||
const Field *target) const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
void Column_definition_reuse_fix_attributes(THD *thd,
|
||||
Column_definition *c,
|
||||
const Field *field)
|
||||
@ -6167,7 +6179,11 @@ public:
|
||||
Field *make_conversion_table_field(MEM_ROOT *root,
|
||||
TABLE *table, uint metadata,
|
||||
const Field *target) const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
bool Column_definition_prepare_stage1(THD *thd,
|
||||
MEM_ROOT *mem_root,
|
||||
Column_definition *c,
|
||||
@ -6224,7 +6240,11 @@ public:
|
||||
Field *make_conversion_table_field(MEM_ROOT *root,
|
||||
TABLE *table, uint metadata,
|
||||
const Field *target) const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
bool Column_definition_prepare_stage2(Column_definition *c,
|
||||
handler *file,
|
||||
ulonglong table_flags) const override
|
||||
@ -6279,7 +6299,11 @@ public:
|
||||
Field *make_conversion_table_field(MEM_ROOT *root,
|
||||
TABLE *table, uint metadata,
|
||||
const Field *target) const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
bool Column_definition_prepare_stage2(Column_definition *c,
|
||||
handler *file,
|
||||
ulonglong table_flags) const override
|
||||
@ -6365,7 +6389,11 @@ public:
|
||||
const override;
|
||||
void Column_definition_implicit_upgrade_to_this(
|
||||
Column_definition *old) const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
bool
|
||||
Column_definition_attributes_frm_unpack(Column_definition_attributes *attr,
|
||||
TABLE_SHARE *share,
|
||||
@ -6563,7 +6591,11 @@ public:
|
||||
bool validate_implicit_default_value(THD *thd,
|
||||
const Column_definition &def)
|
||||
const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
void
|
||||
Column_definition_attributes_frm_pack(const Column_definition_attributes *at,
|
||||
uchar *buff) const override;
|
||||
@ -6690,7 +6722,11 @@ public:
|
||||
const override;
|
||||
void Column_definition_implicit_upgrade_to_this(
|
||||
Column_definition *old) const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
bool
|
||||
Column_definition_attributes_frm_unpack(Column_definition_attributes *attr,
|
||||
TABLE_SHARE *share,
|
||||
@ -6862,7 +6898,11 @@ public:
|
||||
void sort_length(THD *thd,
|
||||
const Type_std_attributes *item,
|
||||
SORT_FIELD_ATTR *attr) const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
decimal_digits_t Item_decimal_scale(const Item *item) const override
|
||||
{
|
||||
return Item_decimal_scale_with_seconds(item);
|
||||
@ -6985,7 +7025,6 @@ public:
|
||||
Field *make_conversion_table_field(MEM_ROOT *root,
|
||||
TABLE *table, uint metadata,
|
||||
const Field *target) const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_prepare_stage2(Column_definition *c,
|
||||
handler *file,
|
||||
ulonglong table_flags) const override
|
||||
@ -7018,7 +7057,6 @@ public:
|
||||
Field *make_conversion_table_field(MEM_ROOT *root,
|
||||
TABLE *table, uint metadata,
|
||||
const Field *target) const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_prepare_stage1(THD *thd,
|
||||
MEM_ROOT *mem_root,
|
||||
Column_definition *c,
|
||||
@ -7075,7 +7113,6 @@ public:
|
||||
TABLE *table, uint metadata,
|
||||
const Field *target) const override;
|
||||
bool union_element_finalize(Item_type_holder* item) const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_prepare_stage1(THD *thd,
|
||||
MEM_ROOT *mem_root,
|
||||
Column_definition *c,
|
||||
@ -7151,7 +7188,6 @@ public:
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_prepare_stage2(Column_definition *c,
|
||||
handler *file,
|
||||
ulonglong table_flags) const override;
|
||||
@ -7191,7 +7227,6 @@ public:
|
||||
uint32 max_display_length_for_field(const Conv_source &src) const override;
|
||||
void show_binlog_type(const Conv_source &src, const Field &dst, String *str)
|
||||
const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_prepare_stage2(Column_definition *c,
|
||||
handler *file,
|
||||
ulonglong table_flags) const override
|
||||
@ -7248,7 +7283,6 @@ public:
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_prepare_stage2(Column_definition *c,
|
||||
handler *file,
|
||||
ulonglong table_flags) const override;
|
||||
@ -7347,7 +7381,11 @@ public:
|
||||
}
|
||||
bool is_param_long_data_type() const override { return true; }
|
||||
uint calc_key_length(const Column_definition &def) const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
bool Column_definition_prepare_stage2(Column_definition *c,
|
||||
handler *file,
|
||||
ulonglong table_flags) const override;
|
||||
@ -7547,7 +7585,11 @@ public:
|
||||
TABLE *table, uint metadata,
|
||||
const Field *target)
|
||||
const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
bool Column_definition_prepare_stage2(Column_definition *c,
|
||||
handler *file,
|
||||
ulonglong table_flags) const override;
|
||||
@ -7588,7 +7630,11 @@ public:
|
||||
TABLE *table, uint metadata,
|
||||
const Field *target)
|
||||
const override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
bool Column_definition_prepare_stage2(Column_definition *c,
|
||||
handler *file,
|
||||
ulonglong table_flags) const override;
|
||||
|
||||
@ -101,10 +101,6 @@ public:
|
||||
MY_ASSERT_UNREACHABLE();
|
||||
return nullptr;
|
||||
}
|
||||
bool Column_definition_fix_attributes(Column_definition *) const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
void Column_definition_reuse_fix_attributes(THD *, Column_definition *,
|
||||
const Field *) const override
|
||||
{
|
||||
|
||||
@ -1229,9 +1229,14 @@ public:
|
||||
const Record_addr tmp(NULL, Bit_addr(true));
|
||||
return new (table->in_use->mem_root) Field_fbt(&empty_clex_str, tmp);
|
||||
}
|
||||
// Fix attributes after the parser
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *c,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override
|
||||
{
|
||||
if (Type_handler::Column_definition_set_attributes(thd, c, attr, type))
|
||||
return true;
|
||||
c->length= FbtImpl::max_char_length();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -276,13 +276,20 @@ Field *Type_handler_geometry::make_conversion_table_field(MEM_ROOT *root,
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_geometry::
|
||||
Column_definition_fix_attributes(Column_definition *def) const
|
||||
bool Type_handler_geometry::Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
if (Type_handler_string_result::Column_definition_set_attributes(thd, def,
|
||||
attr, type))
|
||||
return true;
|
||||
def->flags|= BLOB_FLAG;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_geometry::
|
||||
Column_definition_reuse_fix_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
|
||||
@ -135,7 +135,11 @@ public:
|
||||
const uchar *buffer,
|
||||
LEX_CUSTRING *gis_options) const
|
||||
override;
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
void Column_definition_reuse_fix_attributes(THD *thd,
|
||||
Column_definition *c,
|
||||
const Field *field) const
|
||||
|
||||
@ -70,10 +70,18 @@ Field *Type_handler_vector::make_conversion_table_field(
|
||||
&empty_clex_str, table->s, metadata);
|
||||
}
|
||||
|
||||
bool Type_handler_vector::Column_definition_fix_attributes(
|
||||
Column_definition *def) const
|
||||
|
||||
bool Type_handler_vector::Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
if (def->length == 0 || def->charset != &my_charset_bin)
|
||||
if (Type_handler_varchar::Column_definition_set_attributes(thd, def,
|
||||
attr, type))
|
||||
return true;
|
||||
if (def->length == 0 || def->charset != &my_charset_bin ||
|
||||
attr.has_explicit_dec())
|
||||
{
|
||||
my_error(ER_WRONG_FIELD_SPEC, MYF(0), def->field_name.str);
|
||||
return true;
|
||||
|
||||
@ -42,7 +42,11 @@ public:
|
||||
charset_nr, false);
|
||||
}
|
||||
|
||||
bool Column_definition_fix_attributes(Column_definition *c) const override;
|
||||
bool Column_definition_set_attributes(THD *thd,
|
||||
Column_definition *def,
|
||||
const Lex_field_type_st &attr,
|
||||
column_definition_type_t type)
|
||||
const override;
|
||||
bool Key_part_spec_init_vector(Key_part_spec *part,
|
||||
const Column_definition &def) const override;
|
||||
Field *make_table_field(MEM_ROOT *root, const LEX_CSTRING *name,
|
||||
|
||||
@ -6307,25 +6307,24 @@ field_spec:
|
||||
;
|
||||
|
||||
field_type_or_serial:
|
||||
qualified_field_type
|
||||
qualified_field_type field_def
|
||||
{
|
||||
auto tmp= $1.charset_collation_attrs();
|
||||
if (tmp.merge_column_charset_clause_and_collate_clause(
|
||||
thd, thd->variables.character_set_collations, $2))
|
||||
MYSQL_YYABORT;
|
||||
$1.set_charset_collation_attrs(tmp);
|
||||
if (Lex->last_field->set_attributes(thd, $1,
|
||||
COLUMN_DEFINITION_TABLE_FIELD))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
field_def
|
||||
{
|
||||
auto tmp= $1.charset_collation_attrs();
|
||||
if (tmp.merge_column_charset_clause_and_collate_clause(
|
||||
thd, thd->variables.character_set_collations, $3))
|
||||
MYSQL_YYABORT;
|
||||
Lex->last_field->set_charset_collation_attrs(
|
||||
thd, thd->variables.character_set_collations,
|
||||
tmp);
|
||||
}
|
||||
| SERIAL_SYM
|
||||
{
|
||||
Lex->last_field->set_handler(&type_handler_ulonglong);
|
||||
Lex_field_type_st field_type;
|
||||
field_type.set(&type_handler_ulonglong,
|
||||
Lex_length_and_dec_st::empty());
|
||||
Lex->last_field->set_attributes(thd, field_type,
|
||||
COLUMN_DEFINITION_TABLE_FIELD);
|
||||
Lex->last_field->flags|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG
|
||||
| UNSIGNED_FLAG | UNIQUE_KEY_FLAG;
|
||||
Lex->alter_info.flags|= ALTER_ADD_INDEX;
|
||||
|
||||
@ -664,6 +664,12 @@ protected:
|
||||
"Lex_length_and_dec_st::m_collation_type bits check");
|
||||
|
||||
public:
|
||||
static Lex_length_and_dec_st empty()
|
||||
{
|
||||
Lex_length_and_dec_st tmp;
|
||||
tmp.reset();
|
||||
return tmp;
|
||||
}
|
||||
void reset()
|
||||
{
|
||||
m_length= 0;
|
||||
@ -751,21 +757,15 @@ public:
|
||||
const Lex_column_charset_collation_attrs_st &coll)
|
||||
{
|
||||
m_handler= handler;
|
||||
m_ci= coll.charset_info();
|
||||
Lex_length_and_dec_st::operator=(length_and_dec);
|
||||
// Using bit-and to avoid the warning:
|
||||
// conversion from ‘uint8’ to ‘unsigned char:3’ may change value
|
||||
m_collation_type= ((uint8) coll.type()) & LEX_CHARSET_COLLATION_TYPE_MASK;
|
||||
set_charset_collation_attrs(coll);
|
||||
}
|
||||
void set(const Type_handler *handler,
|
||||
const Lex_column_charset_collation_attrs_st &coll)
|
||||
{
|
||||
m_handler= handler;
|
||||
m_ci= coll.charset_info();
|
||||
Lex_length_and_dec_st::reset();
|
||||
// Using bit-and to avoid the warning:
|
||||
// conversion from ‘uint8’ to ‘unsigned char:3’ may change value
|
||||
m_collation_type= ((uint8) coll.type()) & LEX_CHARSET_COLLATION_TYPE_MASK;
|
||||
set_charset_collation_attrs(coll);
|
||||
}
|
||||
void set(const Type_handler *handler, CHARSET_INFO *cs= NULL)
|
||||
{
|
||||
@ -786,6 +786,14 @@ public:
|
||||
{
|
||||
m_handler= handler;
|
||||
}
|
||||
void set_charset_collation_attrs(const Lex_column_charset_collation_attrs_st
|
||||
&coll)
|
||||
{
|
||||
m_ci= coll.charset_info();
|
||||
// Using bit-and to avoid the warning:
|
||||
// conversion from ‘uint8’ to ‘unsigned char:3’ may change value
|
||||
m_collation_type= ((uint8) coll.type()) & LEX_CHARSET_COLLATION_TYPE_MASK;
|
||||
}
|
||||
const Type_handler *type_handler() const { return m_handler; }
|
||||
CHARSET_INFO *charset_collation() const { return m_ci; }
|
||||
Lex_column_charset_collation_attrs charset_collation_attrs() const
|
||||
|
||||
Loading…
Reference in New Issue
Block a user