Skip to content
Snippets Groups Projects
Commit 9255b607 authored by Nikita Pettik's avatar Nikita Pettik Committed by Vladimir Davydov
Browse files

space_upgrade: extend space_ugprade_new() signature

We are going to utilize primary key definition during space upgrade in
order to verify primary key invariant. So we need it to be stored in
space_upgrade metadata. Let's extend space_upgrade_new() signature and
pass there primary key definition. Also patch moves space_upgrade_new()
call a bit lower through code - now it's called after all indexes are
assigned (to simplify extraction of primary key definition).
Moreover, in order to print pretty error message during space upgrade
we should keep space in struct space_upgrade.

NO_DOC=ee
NO_TEST=ee
NO_CHANGELOG=ee
parent a74c549a
No related branches found
No related tags found
No related merge requests found
......@@ -232,13 +232,6 @@ space_create(struct space *space, struct engine *engine,
space->def = space_def_dup(def);
if (space->def->opts.upgrade_def != NULL) {
space->upgrade = space_upgrade_new(
space->def->opts.upgrade_def, format);
if (space->upgrade == NULL)
goto fail;
}
/* Create indexes and fill the index map. */
space->index_map = (struct index **)
calloc(index_count + index_id_max + 1, sizeof(struct index *));
......@@ -266,6 +259,16 @@ space_create(struct space *space, struct engine *engine,
}
space_fill_index_map(space);
if (space->def->opts.upgrade_def != NULL) {
struct index *pk = space_index(space, 0);
assert(pk != NULL);
space->upgrade = space_upgrade_new(
space->def->opts.upgrade_def, space->def->name,
pk->def->key_def, format);
if (space->upgrade == NULL)
goto fail_free_indexes;
}
rlist_create(&space->space_cache_pin_list);
if (space_init_constraints(space) != 0)
goto fail_free_indexes;
......
......@@ -19,6 +19,7 @@
extern "C" {
#endif /* defined(__cplusplus) */
struct key_def;
struct region;
struct space;
struct space_def;
......@@ -60,15 +61,17 @@ space_upgrade_def_delete(struct space_upgrade_def *def)
}
/**
* Creates a space upgrade state from a definition and the new space format.
* Returns NULL and sets diag on error.
* Creates a space upgrade state from a definition, space name, primary key
* definition and the new space format. Returns NULL and sets diag on error.
* The reference count of the new state is set to 1.
*/
static inline struct space_upgrade *
space_upgrade_new(const struct space_upgrade_def *def,
struct tuple_format *format)
space_upgrade_new(const struct space_upgrade_def *def, const char *space_name,
const struct key_def *pk_def, struct tuple_format *format)
{
(void)def;
(void)space_name;
(void)pk_def;
(void)format;
unreachable();
return NULL;
......
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