1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-5800 MyISAM support for indexed vcols

* don't issue an error for ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
* support keyread on vcols
* callback into the server to compute vcol values from mi_check/mi_repair
* DMLs just work. Automatically.
This commit is contained in:
Sergei Golubchik
2016-11-23 17:33:40 +01:00
parent a418c99200
commit d137b4dbba
26 changed files with 1681 additions and 87 deletions

View File

@ -3916,12 +3916,6 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
}
}
#endif
if (!sql_field->stored_in_db())
{
/* Key fields must always be physically stored. */
my_error(ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN, MYF(0));
DBUG_RETURN(TRUE);
}
if (key->type == Key::PRIMARY && sql_field->vcol_info)
{
my_error(ER_PRIMARY_KEY_BASED_ON_VIRTUAL_COLUMN, MYF(0));
@ -6226,9 +6220,11 @@ static int compare_uint(const uint *s, const uint *t)
Check if the column is computed and either
is stored or is used in the partitioning expression.
*/
static bool vcol_affecting_storage(const Virtual_column_info* vcol)
static bool vcol_affecting_storage(const Virtual_column_info* vcol,
bool indexed)
{
return vcol && (vcol->is_stored() || vcol->is_in_partitioning_expr());
return vcol &&
(vcol->is_stored() || vcol->is_in_partitioning_expr() || indexed);
}
/**
@ -6437,15 +6433,28 @@ static bool fill_alter_inplace_info(THD *thd,
ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_TYPE;
}
if (vcol_affecting_storage(field->vcol_info) ||
vcol_affecting_storage(new_field->vcol_info))
if (vcol_affecting_storage(field->vcol_info,
field->flags & PART_KEY_FLAG) ||
vcol_affecting_storage(new_field->vcol_info, false))
{
if (is_equal == IS_EQUAL_NO ||
!field->vcol_info || !new_field->vcol_info ||
!field->vcol_info->is_equal(new_field->vcol_info))
ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_VCOL;
else
maybe_alter_vcol= true;
{
if (!(ha_alter_info->handler_flags & Alter_inplace_info::ALTER_COLUMN_VCOL) &&
(ha_alter_info->handler_flags & Alter_inplace_info::ALTER_COLUMN_DEFAULT))
{ /*
a DEFAULT value of a some column was changed.
see if this vcol uses DEFAULT() function
*/
if (field->vcol_info->expr_item->walk(
&Item::check_func_default_processor, 0, 0))
ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_VCOL;
}
}
maybe_alter_vcol= true;
}
/* Check if field was renamed */
@ -6514,10 +6523,10 @@ static bool fill_alter_inplace_info(THD *thd,
if (maybe_alter_vcol)
{
/*
No virtual column was altered, but perhaps one of the other columns was,
and that column was part of the vcol expression?
We don't detect this correctly (FIXME), so let's just say that a vcol
*might* be affected if any other column was altered.
What if one of the normal columns was altered and it was part of the some
virtual column expression? Currently we don't detect this correctly
(FIXME), so let's just say that a vcol *might* be affected if any other
column was altered.
*/
if (ha_alter_info->handler_flags &
( Alter_inplace_info::ALTER_COLUMN_TYPE