[server 3/4] iproto: add IPROTO_NOP request type
Vladimir Davydov
vdavydov.dev at gmail.com
Tue Jan 23 19:28:57 MSK 2018
To implement space:before_replace trigger, we need to introduce a new
request type for bumping LSN, because the new trigger may turn any DML
operation into a no-op. Let's call it IPROTO_NOP. It is treated as DML
(passed to apply_row, etc), but it is ignored by space_execute_dml() and
so doesn't actually modify anyting, only bumps LSN on the server. The
new request type has name "NOP" (for xlog reader), however it isn't
reported via box.stat().
Needed for #2993
---
src/box/iproto.cc | 3 ++-
src/box/iproto_constants.c | 5 ++++-
src/box/iproto_constants.h | 11 ++++++++++-
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/box/iproto.cc b/src/box/iproto.cc
index 13594a46..5dfb2b83 100644
--- a/src/box/iproto.cc
+++ b/src/box/iproto.cc
@@ -913,7 +913,8 @@ static const struct cmsg_hop *dml_route[IPROTO_TYPE_STAT_MAX] = {
misc_route, /* IPROTO_AUTH */
call_route, /* IPROTO_EVAL */
process1_route, /* IPROTO_UPSERT */
- call_route /* IPROTO_CALL */
+ call_route, /* IPROTO_CALL */
+ NULL, /* IPROTO_NOP */
};
static const struct cmsg_hop join_route[] = {
diff --git a/src/box/iproto_constants.c b/src/box/iproto_constants.c
index ff7a755f..7710196d 100644
--- a/src/box/iproto_constants.c
+++ b/src/box/iproto_constants.c
@@ -101,7 +101,8 @@ const char *iproto_type_strs[] =
"AUTH",
"EVAL",
"UPSERT",
- "CALL"
+ "CALL",
+ NULL, /* NOP */
};
#define bit(c) (1ULL<<IPROTO_##c)
@@ -116,6 +117,8 @@ const uint64_t iproto_body_key_map[IPROTO_TYPE_STAT_MAX] = {
0, /* AUTH */
0, /* EVAL */
bit(SPACE_ID) | bit(OPS) | bit(TUPLE), /* UPSERT */
+ 0, /* CALL */
+ bit(SPACE_ID), /* NOP */
};
#undef bit
diff --git a/src/box/iproto_constants.h b/src/box/iproto_constants.h
index e1192e91..94b111ad 100644
--- a/src/box/iproto_constants.h
+++ b/src/box/iproto_constants.h
@@ -141,6 +141,8 @@ enum iproto_type {
IPROTO_UPSERT = 9,
/** CALL request - returns arbitrary MessagePack */
IPROTO_CALL = 10,
+ /** No operation. Treated as DML, used to bump LSN. */
+ IPROTO_NOP = 11,
/** The maximum typecode used for box.stat() */
IPROTO_TYPE_STAT_MAX,
@@ -174,6 +176,13 @@ extern const char *iproto_type_strs[];
static inline const char *
iproto_type_name(uint32_t type)
{
+ /*
+ * Sic: iptoto_type_strs[IPROTO_NOP] is NULL
+ * to suppress box.stat() output.
+ */
+ if (type == IPROTO_NOP)
+ return "NOP";
+
if (type < IPROTO_TYPE_STAT_MAX)
return iproto_type_strs[type];
@@ -207,7 +216,7 @@ static inline bool
iproto_type_is_dml(uint32_t type)
{
return (type >= IPROTO_SELECT && type <= IPROTO_DELETE) ||
- type == IPROTO_UPSERT;
+ type == IPROTO_UPSERT || type == IPROTO_NOP;
}
/**
--
2.11.0
More information about the Tarantool-patches
mailing list