diff --git a/src/box/tuple_format.c b/src/box/tuple_format.c index 9a108077b27997ec27741441e1e86839485d90f7..fc6d1191823d2189dc53c243a64331574ff47417 100644 --- a/src/box/tuple_format.c +++ b/src/box/tuple_format.c @@ -211,6 +211,20 @@ tuple_format_new(struct tuple_format_vtab *vtab, struct key_def **keys, return format; } +bool +tuple_format_eq(const struct tuple_format *a, const struct tuple_format *b) +{ + if (a->field_map_size != b->field_map_size || + a->field_count != b->field_count) + return false; + for (uint32_t i = 0; i < a->field_count; ++i) { + if (a->fields[i].type != b->fields[i].type || + a->fields[i].offset_slot != b->fields[i].offset_slot) + return false; + } + return true; +} + struct tuple_format * tuple_format_dup(const struct tuple_format *src) { diff --git a/src/box/tuple_format.h b/src/box/tuple_format.h index a4a8a467f6e0982d0c96f82a9c8c607406f15780..ac84b28a20e7ce27158f13cfc6d278bd90037e6b 100644 --- a/src/box/tuple_format.h +++ b/src/box/tuple_format.h @@ -152,6 +152,14 @@ struct tuple_format * tuple_format_new(struct tuple_format_vtab *vtab, struct key_def **keys, uint16_t key_count, uint16_t extra_size); +/** + * Check that two tuple formats are identical. + * @param a format a + * @param b format b + */ +bool +tuple_format_eq(const struct tuple_format *a, const struct tuple_format *b); + /** * Register the duplicate of the specified format. * @param src Original format. diff --git a/src/box/vy_stmt.c b/src/box/vy_stmt.c index a22f57b5108b9439cbb96a2ff048b3f7e4f86632..01b8cf335b52d55d383aefc270eb218031ffe620 100644 --- a/src/box/vy_stmt.c +++ b/src/box/vy_stmt.c @@ -325,7 +325,6 @@ vy_stmt_replace_from_upsert(struct tuple_format *replace_format, /* Copy statement data excluding UPSERT operations */ struct tuple_format *format = tuple_format_by_id(upsert->format_id); - (void)format; /* * UPSERT must have the n_upserts field in the extra * memory. @@ -335,10 +334,7 @@ vy_stmt_replace_from_upsert(struct tuple_format *replace_format, * In other fields the REPLACE tuple format must equal to * the UPSERT tuple format. */ - assert(format->field_map_size == replace_format->field_map_size); - assert(format->field_count == replace_format->field_count); - assert(! memcmp(format->fields, replace_format->fields, - sizeof(struct tuple_field_format) * format->field_count)); + assert(tuple_format_eq(format, replace_format)); struct tuple *replace = vy_stmt_alloc(replace_format, bsize); if (replace == NULL) return NULL;