Skip to content
Snippets Groups Projects
Commit 5d2614d8 authored by Vladislav Shpilevoy's avatar Vladislav Shpilevoy Committed by Konstantin Osipov
Browse files

Rename field_type_is_compatible to field_type1_contains_type2

Compatibility must be commutative, but this function is not
commutative. It checks, that one type can store values of another
type, but not conversely.
parent 06aa0266
No related branches found
No related tags found
No related merge requests found
......@@ -69,9 +69,9 @@ static const bool field_type_compatibility[] = {
};
bool
field_type_is_compatible(enum field_type old_type, enum field_type new_type)
field_type1_contains_type2(enum field_type type1, enum field_type type2)
{
int idx = old_type * field_type_MAX + new_type;
int idx = type2 * field_type_MAX + type1;
return field_type_compatibility[idx];
}
......
......@@ -63,9 +63,9 @@ enum field_type {
extern const char *field_type_strs[];
/** Check if @a new_type can store values of @an old_type. */
/** Check if @a type1 can store values of @a type2. */
bool
field_type_is_compatible(enum field_type old_type, enum field_type new_type);
field_type1_contains_type2(enum field_type type1, enum field_type type2);
/**
* Get field type by name
......
......@@ -225,7 +225,7 @@ key_part_check_compatibility(const struct key_part *old_parts,
const struct key_part *old_part = &old_parts[i];
if (old_part->fieldno != new_part->fieldno)
return false;
if (! field_type_is_compatible(old_part->type, new_part->type))
if (! field_type1_contains_type2(new_part->type, old_part->type))
return false;
if (old_part->coll != new_part->coll)
return false;
......
......@@ -296,7 +296,7 @@ space_def_check_compatibility(const struct space_def *old_def,
for (uint32_t i = 0; i < field_count; ++i) {
enum field_type old_type = old_def->fields[i].type;
enum field_type new_type = new_def->fields[i].type;
if (! field_type_is_compatible(old_type, new_type)) {
if (! field_type1_contains_type2(new_type, old_type)) {
const char *msg =
tt_sprintf("Can not change a field type from "\
"%s to %s on a not empty space",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment