1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-18794 append_drop_column() small refactoring

Bogus if() logic inside the func.
This commit is contained in:
Aleksey Midenkov
2019-06-13 19:29:02 +03:00
parent dac1280a65
commit 3e9b96b6ff

View File

@ -7824,16 +7824,13 @@ blob_length_by_type(enum_field_types type)
} }
static void append_drop_column(THD *thd, bool dont, String *str, static inline
Field *field) void append_drop_column(THD *thd, String *str, Field *field)
{ {
if (!dont) if (str->length())
{ str->append(STRING_WITH_LEN(", "));
if (str->length()) str->append(STRING_WITH_LEN("DROP COLUMN "));
str->append(STRING_WITH_LEN(", ")); append_identifier(thd, str, &field->field_name);
str->append(STRING_WITH_LEN("DROP COLUMN "));
append_identifier(thd, str, &field->field_name);
}
} }
@ -8088,7 +8085,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
field->invisible < INVISIBLE_SYSTEM) field->invisible < INVISIBLE_SYSTEM)
{ {
StringBuffer<NAME_LEN*3> tmp; StringBuffer<NAME_LEN*3> tmp;
append_drop_column(thd, false, &tmp, field); append_drop_column(thd, &tmp, field);
my_error(ER_MISSING, MYF(0), table->s->table_name.str, tmp.c_ptr()); my_error(ER_MISSING, MYF(0), table->s->table_name.str, tmp.c_ptr());
goto err; goto err;
} }
@ -8141,10 +8138,10 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
!vers_system_invisible) !vers_system_invisible)
{ {
StringBuffer<NAME_LEN*3> tmp; StringBuffer<NAME_LEN*3> tmp;
append_drop_column(thd, dropped_sys_vers_fields & VERS_SYS_START_FLAG, if (!(dropped_sys_vers_fields & VERS_SYS_START_FLAG))
&tmp, table->vers_start_field()); append_drop_column(thd, &tmp, table->vers_start_field());
append_drop_column(thd, dropped_sys_vers_fields & VERS_SYS_END_FLAG, if (!(dropped_sys_vers_fields & VERS_SYS_END_FLAG))
&tmp, table->vers_end_field()); append_drop_column(thd, &tmp, table->vers_end_field());
my_error(ER_MISSING, MYF(0), table->s->table_name.str, tmp.c_ptr()); my_error(ER_MISSING, MYF(0), table->s->table_name.str, tmp.c_ptr());
goto err; goto err;
} }