1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

cleanup: remove Field->stored_in_db, Create_field->stored_in_db

and don't set Create_field->sql_type to MYSQL_TYPE_VIRTUAL
temporarily only to change it again few lines later.
This commit is contained in:
Sergei Golubchik
2015-11-24 22:20:32 +01:00
parent 13989b36c1
commit a099686e2e
16 changed files with 100 additions and 124 deletions

View File

@@ -3466,7 +3466,6 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
sql_field->flags= dup_field->flags;
sql_field->interval= dup_field->interval;
sql_field->vcol_info= dup_field->vcol_info;
sql_field->stored_in_db= dup_field->stored_in_db;
it2.remove(); // Remove first (create) definition
select_field_pos--;
break;
@@ -3508,14 +3507,14 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
(virtual fields) and update their offset later
(see the next loop).
*/
if (sql_field->stored_in_db)
if (sql_field->stored_in_db())
record_offset+= sql_field->pack_length;
}
/* Update virtual fields' offset*/
it.rewind();
while ((sql_field=it++))
{
if (!sql_field->stored_in_db)
if (!sql_field->stored_in_db())
{
sql_field->offset= record_offset;
record_offset+= sql_field->pack_length;
@@ -3868,7 +3867,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
}
}
#endif
if (!sql_field->stored_in_db)
if (!sql_field->stored_in_db())
{
/* Key fields must always be physically stored. */
my_error(ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN, MYF(0));
@@ -6240,18 +6239,6 @@ static bool fill_alter_inplace_info(THD *thd,
ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_TYPE;
}
/*
Check if the altered column is computed and either
is stored or is used in the partitioning expression.
TODO: Mark such a column with an alter flag only if
the defining expression has changed.
*/
if (field->vcol_info &&
(field->stored_in_db || field->vcol_info->is_in_partitioning_expr()))
{
ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_VCOL;
}
/* Check if field was renamed */
if (my_strcasecmp(system_charset_info, field->field_name,
new_field->field_name))
@@ -6318,20 +6305,29 @@ static bool fill_alter_inplace_info(THD *thd,
new_field_it.init(alter_info->create_list);
while ((new_field= new_field_it++))
{
if (! new_field->field)
Virtual_column_info *vcol_info;
if (new_field->field)
vcol_info= new_field->field->vcol_info;
else
{
vcol_info= new_field->vcol_info;
/*
Field is not present in old version of table and therefore was added.
Again corresponding storage engine flag should be already set.
*/
DBUG_ASSERT(ha_alter_info->handler_flags & Alter_inplace_info::ADD_COLUMN);
}
if (new_field->vcol_info &&
(new_field->stored_in_db || new_field->vcol_info->is_in_partitioning_expr()))
{
ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_VCOL;
}
break;
/*
Check if the altered column is computed and either
is stored or is used in the partitioning expression.
TODO: Mark such a column with an alter flag only if
the defining expression has changed.
*/
if (vcol_info &&
(vcol_info->stored_in_db || vcol_info->is_in_partitioning_expr()))
{
ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_VCOL;
}
}
@@ -7394,7 +7390,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
of the list for now. Their positions will be corrected later.
*/
new_create_list.push_back(def, thd->mem_root);
if (field->stored_in_db != def->stored_in_db)
if (field->stored_in_db() != def->stored_in_db())
{
my_error(ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN, MYF(0));
goto err;