From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH 07/12] space: pass new format instead of new space to space_vtab::check_format
Date: Sat, 7 Apr 2018 16:38:04 +0300 [thread overview]
Message-ID: <e32ff6c23f90e3cdd8674c982c5f5f8c692718b0.1523105106.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1523105106.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1523105106.git.vdavydov.dev@gmail.com>
The check_format method is supposed to check that all tuples stored in
an altered space conform to the new format. Let's change its signature
accordingly.
---
src/box/alter.cc | 2 +-
src/box/memtx_space.c | 8 ++++----
src/box/space.h | 16 +++++++---------
src/box/sysview_engine.c | 6 +++---
src/box/vinyl.c | 10 +++++-----
5 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/src/box/alter.cc b/src/box/alter.cc
index 947716c8..9dd8d8d5 100644
--- a/src/box/alter.cc
+++ b/src/box/alter.cc
@@ -914,7 +914,7 @@ CheckSpaceFormat::alter(struct alter_space *alter)
assert(new_format != NULL);
if (!tuple_format1_can_store_format2_tuples(new_format,
old_format))
- space_check_format_xc(new_space, old_space);
+ space_check_format_xc(old_space, new_format);
}
}
diff --git a/src/box/memtx_space.c b/src/box/memtx_space.c
index ca7b5937..be687288 100644
--- a/src/box/memtx_space.c
+++ b/src/box/memtx_space.c
@@ -704,11 +704,11 @@ memtx_space_add_primary_key(struct space *space)
}
static int
-memtx_space_check_format(struct space *new_space, struct space *old_space)
+memtx_space_check_format(struct space *space, struct tuple_format *format)
{
- if (old_space->index_count == 0)
+ if (space->index_count == 0)
return 0;
- struct index *pk = old_space->index[0];
+ struct index *pk = space->index[0];
if (index_size(pk) == 0)
return 0;
@@ -723,7 +723,7 @@ memtx_space_check_format(struct space *new_space, struct space *old_space)
* Check that the tuple is OK according to the
* new format.
*/
- rc = tuple_validate(new_space->format, tuple);
+ rc = tuple_validate(format, tuple);
if (rc != 0)
break;
}
diff --git a/src/box/space.h b/src/box/space.h
index 0cc1b00f..70da58b1 100644
--- a/src/box/space.h
+++ b/src/box/space.h
@@ -91,11 +91,10 @@ struct space_vtab {
*/
void (*drop_primary_key)(struct space *);
/**
- * Check that new fields of a space format are
- * compatible with existing tuples.
+ * Check that all tuples stored in a space are compatible
+ * with the new format.
*/
- int (*check_format)(struct space *new_space,
- struct space *old_space);
+ int (*check_format)(struct space *space, struct tuple_format *format);
/**
* Build a new index, primary or secondary, and fill it
* with tuples stored in the given space. The function is
@@ -317,10 +316,9 @@ space_add_primary_key(struct space *space)
}
static inline int
-space_check_format(struct space *new_space, struct space *old_space)
+space_check_format(struct space *space, struct tuple_format *format)
{
- assert(old_space->vtab == new_space->vtab);
- return new_space->vtab->check_format(new_space, old_space);
+ return space->vtab->check_format(space, format);
}
static inline void
@@ -472,9 +470,9 @@ space_add_primary_key_xc(struct space *space)
}
static inline void
-space_check_format_xc(struct space *new_space, struct space *old_space)
+space_check_format_xc(struct space *space, struct tuple_format *format)
{
- if (space_check_format(new_space, old_space) != 0)
+ if (space_check_format(space, format) != 0)
diag_raise();
}
diff --git a/src/box/sysview_engine.c b/src/box/sysview_engine.c
index 8cfdeeba..bb31edbf 100644
--- a/src/box/sysview_engine.c
+++ b/src/box/sysview_engine.c
@@ -154,10 +154,10 @@ sysview_space_prepare_alter(struct space *old_space, struct space *new_space)
}
static int
-sysview_space_check_format(struct space *new_space, struct space *old_space)
+sysview_space_check_format(struct space *space, struct tuple_format *format)
{
- (void)old_space;
- (void)new_space;
+ (void)space;
+ (void)format;
unreachable();
return 0;
}
diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index 7db7a60f..cbafa122 100644
--- a/src/box/vinyl.c
+++ b/src/box/vinyl.c
@@ -1035,14 +1035,14 @@ vinyl_space_prepare_alter(struct space *old_space, struct space *new_space)
}
static int
-vinyl_space_check_format(struct space *new_space, struct space *old_space)
+vinyl_space_check_format(struct space *space, struct tuple_format *format)
{
- (void)new_space;
- struct vy_env *env = vy_env(old_space->engine);
+ (void)format;
+ struct vy_env *env = vy_env(space->engine);
/* @sa vy_prepare_alter_space for checks below. */
- if (old_space->index_count == 0)
+ if (space->index_count == 0)
return 0;
- struct vy_lsm *pk = vy_lsm(old_space->index[0]);
+ struct vy_lsm *pk = vy_lsm(space->index[0]);
if (env->status != VINYL_ONLINE)
return 0;
if (pk->stat.disk.count.rows == 0 && pk->stat.memory.count.rows == 0)
--
2.11.0
next prev parent reply other threads:[~2018-04-07 13:38 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-07 13:37 [PATCH 00/12] vinyl: allow to modify format of non-empty spaces Vladimir Davydov
2018-04-07 13:37 ` [PATCH 01/12] alter: introduce CheckSpaceFormat AlterSpaceOp for validating format Vladimir Davydov
2018-04-09 20:25 ` Konstantin Osipov
2018-04-07 13:37 ` [PATCH 02/12] alter: fold ModifySpaceFormat into ModifySpace Vladimir Davydov
2018-04-09 20:26 ` Konstantin Osipov
2018-04-07 13:38 ` [PATCH 03/12] alter: move dictionary update from ModifySpace::alter_def to alter Vladimir Davydov
2018-04-09 20:32 ` Konstantin Osipov
2018-04-10 7:53 ` Vladimir Davydov
2018-04-10 11:45 ` Vladimir Davydov
2018-04-07 13:38 ` [PATCH 04/12] alter: use space_index instead of index_find where appropriate Vladimir Davydov
2018-04-09 20:34 ` Konstantin Osipov
2018-04-07 13:38 ` [PATCH 05/12] alter: allocate triggers before the point of no return Vladimir Davydov
2018-04-09 20:36 ` Konstantin Osipov
2018-04-10 7:57 ` Vladimir Davydov
2018-04-10 11:54 ` Vladimir Davydov
2018-04-07 13:38 ` [PATCH 06/12] space: space_vtab::build_secondary_key => build_index Vladimir Davydov
2018-04-09 20:39 ` Konstantin Osipov
2018-04-10 8:05 ` Vladimir Davydov
2018-04-10 12:14 ` Vladimir Davydov
2018-04-07 13:38 ` Vladimir Davydov [this message]
2018-04-09 20:40 ` [PATCH 07/12] space: pass new format instead of new space to space_vtab::check_format Konstantin Osipov
2018-04-07 13:38 ` [PATCH 08/12] alter: introduce preparation phase Vladimir Davydov
2018-04-09 20:46 ` [tarantool-patches] " Konstantin Osipov
2018-04-10 8:31 ` Vladimir Davydov
2018-04-10 8:46 ` Konstantin Osipov
2018-04-07 13:38 ` [PATCH 09/12] alter: zap space_def_check_compatibility Vladimir Davydov
2018-04-09 20:49 ` Konstantin Osipov
2018-04-07 13:38 ` [PATCH 10/12] vinyl: remove superfluous ddl checks Vladimir Davydov
2018-04-09 20:49 ` Konstantin Osipov
2018-04-07 13:38 ` [PATCH 11/12] vinyl: force index rebuild if indexed field type is narrowed Vladimir Davydov
2018-04-09 20:51 ` Konstantin Osipov
2018-04-07 13:38 ` [PATCH 12/12] vinyl: allow to modify format of non-empty spaces Vladimir Davydov
2018-04-09 8:24 ` Vladimir Davydov
2018-04-09 20:55 ` Konstantin Osipov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e32ff6c23f90e3cdd8674c982c5f5f8c692718b0.1523105106.git.vdavydov.dev@gmail.com \
--to=vdavydov.dev@gmail.com \
--cc=kostja@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [PATCH 07/12] space: pass new format instead of new space to space_vtab::check_format' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox