[PATCH] Drop const qualifier of struct tuple

Vladimir Davydov vdavydov.dev at gmail.com
Fri Apr 5 14:31:06 MSK 2019


Using the const qualifier for complex structures like tuple is bad.
We already have to cast it to drop the const qualifier now and then,
e.g. to increment/decrement the reference counter.

We are planning to wrap struct tuple in a helper struct (aka entry) to
store it in vinyl containers along with a comparison hint (cache, memory
tree, etc). We will be passing this struct by value so we won't be able
to retain const qualifier, because in contrast to a const pointer, one
must initialize a const struct upon definition.

That said, it's time to drop const qualifier of struct tuple everywhere,
like we have already done in case of struct key_def and tuple_format.
---
https://github.com/tarantool/tarantool/commits/dv/drop-tuple-const-qualifier

 src/box/alter.cc                | 13 ++++---
 src/box/index.cc                |  4 +--
 src/box/index.h                 |  2 +-
 src/box/key_def.c               |  4 +--
 src/box/key_def.h               | 42 +++++++++++------------
 src/box/lua/call.c              |  2 +-
 src/box/lua/tuple.c             | 16 ++++-----
 src/box/lua/tuple.lua           | 10 +++---
 src/box/memtx_rtree.c           |  2 +-
 src/box/memtx_space.c           |  5 ++-
 src/box/memtx_space.h           |  5 ++-
 src/box/sql.c                   |  2 +-
 src/box/tuple.c                 | 22 ++++++------
 src/box/tuple.h                 | 76 +++++++++++++++++++----------------------
 src/box/tuple_bloom.c           |  4 +--
 src/box/tuple_bloom.h           |  4 +--
 src/box/tuple_compare.cc        | 73 ++++++++++++++++++---------------------
 src/box/tuple_convert.c         |  4 +--
 src/box/tuple_convert.h         |  4 +--
 src/box/tuple_extract_key.cc    |  8 ++---
 src/box/tuple_hash.cc           | 12 +++----
 src/box/vinyl.c                 | 25 +++++++-------
 src/box/vy_cache.c              | 23 ++++++-------
 src/box/vy_cache.h              | 24 ++++++-------
 src/box/vy_lsm.c                | 12 +++----
 src/box/vy_lsm.h                |  6 ++--
 src/box/vy_mem.c                | 46 ++++++++++++-------------
 src/box/vy_mem.h                | 30 ++++++++--------
 src/box/vy_range.c              |  4 +--
 src/box/vy_range.h              |  6 ++--
 src/box/vy_read_iterator.c      |  2 +-
 src/box/vy_read_set.h           |  4 +--
 src/box/vy_run.c                | 24 ++++++-------
 src/box/vy_run.h                |  7 ++--
 src/box/vy_stat.h               |  6 ++--
 src/box/vy_stmt.c               | 24 ++++++-------
 src/box/vy_stmt.h               | 56 +++++++++++++++---------------
 src/box/vy_tx.c                 | 21 +++++-------
 src/box/vy_tx.h                 | 17 ++++-----
 src/box/vy_upsert.c             |  2 +-
 src/box/vy_upsert.h             |  2 +-
 test/unit/luaT_tuple_new.c      |  4 +--
 test/unit/vy_iterators_helper.c |  4 +--
 test/unit/vy_iterators_helper.h |  4 +--
 test/unit/vy_mem.c              |  6 ++--
 45 files changed, 315 insertions(+), 358 deletions(-)

diff --git a/src/box/alter.cc b/src/box/alter.cc
index 2f783c8e..9279426d 100644
--- a/src/box/alter.cc
+++ b/src/box/alter.cc
@@ -140,7 +140,7 @@ index_def_check_sequence(struct index_def *index_def, const char *space_name)
  * Checks only types of fields and their count!
  */
 static void
-index_def_check_tuple(const struct tuple *tuple)
+index_def_check_tuple(struct tuple *tuple)
 {
 	const mp_type common_template[] =
 		{MP_UINT, MP_UINT, MP_STR, MP_STR, MP_MAP, MP_ARRAY};
@@ -2392,8 +2392,7 @@ on_replace_dd_user(struct trigger * /* trigger */, void *event)
  * @param[out] uid Owner identifier.
  */
 static inline void
-func_def_get_ids_from_tuple(const struct tuple *tuple, uint32_t *fid,
-			    uint32_t *uid)
+func_def_get_ids_from_tuple(struct tuple *tuple, uint32_t *fid, uint32_t *uid)
 {
 	*fid = tuple_field_u32_xc(tuple, BOX_FUNC_FIELD_ID);
 	*uid = tuple_field_u32_xc(tuple, BOX_FUNC_FIELD_UID);
@@ -2401,7 +2400,7 @@ func_def_get_ids_from_tuple(const struct tuple *tuple, uint32_t *fid,
 
 /** Create a function definition from tuple. */
 static struct func_def *
-func_def_new_from_tuple(const struct tuple *tuple)
+func_def_new_from_tuple(struct tuple *tuple)
 {
 	uint32_t len;
 	const char *name = tuple_field_str_xc(tuple, BOX_FUNC_FIELD_NAME,
@@ -2517,7 +2516,7 @@ on_replace_dd_func(struct trigger * /* trigger */, void *event)
 
 /** Create a collation identifier definition from tuple. */
 void
-coll_id_def_new_from_tuple(const struct tuple *tuple, struct coll_id_def *def)
+coll_id_def_new_from_tuple(struct tuple *tuple, struct coll_id_def *def)
 {
 	memset(def, 0, sizeof(*def));
 	uint32_t name_len, locale_len, type_len;
@@ -3593,7 +3592,7 @@ on_replace_dd_trigger(struct trigger * /* trigger */, void *event)
  * @retval Array of links.
  */
 static struct field_link *
-decode_fk_links(const struct tuple *tuple, uint32_t *out_count,
+decode_fk_links(struct tuple *tuple, uint32_t *out_count,
 		const char *constraint_name, uint32_t constraint_len,
 		uint32_t errcode)
 {
@@ -3638,7 +3637,7 @@ decode_fk_links(const struct tuple *tuple, uint32_t *out_count,
 
 /** Create an instance of foreign key def constraint from tuple. */
 static struct fk_constraint_def *
-fk_constraint_def_new_from_tuple(const struct tuple *tuple, uint32_t errcode)
+fk_constraint_def_new_from_tuple(struct tuple *tuple, uint32_t errcode)
 {
 	uint32_t name_len;
 	const char *name =
diff --git a/src/box/index.cc b/src/box/index.cc
index 1bfdc6eb..3c53ae81 100644
--- a/src/box/index.cc
+++ b/src/box/index.cc
@@ -147,8 +147,8 @@ exact_key_validate(struct key_def *key_def, const char *key,
 }
 
 char *
-box_tuple_extract_key(const box_tuple_t *tuple, uint32_t space_id,
-	uint32_t index_id, uint32_t *key_size)
+box_tuple_extract_key(box_tuple_t *tuple, uint32_t space_id, uint32_t index_id,
+		      uint32_t *key_size)
 {
 	struct space *space = space_cache_find(space_id);
 	if (space == NULL)
diff --git a/src/box/index.h b/src/box/index.h
index 0a1ac611..97d600c9 100644
--- a/src/box/index.h
+++ b/src/box/index.h
@@ -206,7 +206,7 @@ box_index_count(uint32_t space_id, uint32_t index_id, int type,
  * @retval     NULL Memory Allocation error
  */
 char *
-box_tuple_extract_key(const box_tuple_t *tuple, uint32_t space_id,
+box_tuple_extract_key(box_tuple_t *tuple, uint32_t space_id,
 		      uint32_t index_id, uint32_t *key_size);
 
 /** \endcond public */
diff --git a/src/box/key_def.c b/src/box/key_def.c
index 55dcf1eb..d07bbe8b 100644
--- a/src/box/key_def.c
+++ b/src/box/key_def.c
@@ -273,14 +273,14 @@ box_key_def_delete(box_key_def_t *key_def)
 }
 
 int
-box_tuple_compare(const box_tuple_t *tuple_a, const box_tuple_t *tuple_b,
+box_tuple_compare(box_tuple_t *tuple_a, box_tuple_t *tuple_b,
 		  box_key_def_t *key_def)
 {
 	return tuple_compare(tuple_a, tuple_b, key_def);
 }
 
 int
-box_tuple_compare_with_key(const box_tuple_t *tuple_a, const char *key_b,
+box_tuple_compare_with_key(box_tuple_t *tuple_a, const char *key_b,
 			   box_key_def_t *key_def)
 {
 	uint32_t part_count = mp_decode_array(&key_b);
diff --git a/src/box/key_def.h b/src/box/key_def.h
index 288cf727..50009dc0 100644
--- a/src/box/key_def.h
+++ b/src/box/key_def.h
@@ -150,29 +150,29 @@ key_part_is_nullable(const struct key_part *part)
 }
 
 /** @copydoc tuple_compare_with_key() */
-typedef int (*tuple_compare_with_key_t)(const struct tuple *tuple_a,
+typedef int (*tuple_compare_with_key_t)(struct tuple *tuple_a,
 					const char *key,
 					uint32_t part_count,
 					struct key_def *key_def);
 /** @copydoc tuple_compare_with_key_hinted() */
-typedef int (*tuple_compare_with_key_hinted_t)(const struct tuple *tuple,
+typedef int (*tuple_compare_with_key_hinted_t)(struct tuple *tuple,
 					       hint_t tuple_hint,
 					       const char *key,
 					       uint32_t part_count,
 					       hint_t key_hint,
 					       struct key_def *key_def);
 /** @copydoc tuple_compare() */
-typedef int (*tuple_compare_t)(const struct tuple *tuple_a,
-			       const struct tuple *tuple_b,
+typedef int (*tuple_compare_t)(struct tuple *tuple_a,
+			       struct tuple *tuple_b,
 			       struct key_def *key_def);
 /** @copydoc tuple_compare_hinted() */
-typedef int (*tuple_compare_hinted_t)(const struct tuple *tuple_a,
+typedef int (*tuple_compare_hinted_t)(struct tuple *tuple_a,
 				      hint_t tuple_a_hint,
-				      const struct tuple *tuple_b,
+				      struct tuple *tuple_b,
 				      hint_t tuple_b_hint,
 				      struct key_def *key_def);
 /** @copydoc tuple_extract_key() */
-typedef char *(*tuple_extract_key_t)(const struct tuple *tuple,
+typedef char *(*tuple_extract_key_t)(struct tuple *tuple,
 				     struct key_def *key_def,
 				     uint32_t *key_size);
 /** @copydoc tuple_extract_key_raw() */
@@ -181,13 +181,13 @@ typedef char *(*tuple_extract_key_raw_t)(const char *data,
 					 struct key_def *key_def,
 					 uint32_t *key_size);
 /** @copydoc tuple_hash() */
-typedef uint32_t (*tuple_hash_t)(const struct tuple *tuple,
+typedef uint32_t (*tuple_hash_t)(struct tuple *tuple,
 				 struct key_def *key_def);
 /** @copydoc key_hash() */
 typedef uint32_t (*key_hash_t)(const char *key,
 				struct key_def *key_def);
 /** @copydoc tuple_hint() */
-typedef hint_t (*tuple_hint_t)(const struct tuple *tuple,
+typedef hint_t (*tuple_hint_t)(struct tuple *tuple,
 			       struct key_def *key_def);
 /** @copydoc key_hint() */
 typedef hint_t (*key_hint_t)(const char *key, uint32_t part_count,
@@ -299,7 +299,7 @@ box_key_def_delete(box_key_def_t *key_def);
  * @retval >0 if key_fields(tuple_a) > key_fields(tuple_b)
  */
 int
-box_tuple_compare(const box_tuple_t *tuple_a, const box_tuple_t *tuple_b,
+box_tuple_compare(box_tuple_t *tuple_a, box_tuple_t *tuple_b,
 		  box_key_def_t *key_def);
 
 /**
@@ -314,7 +314,7 @@ box_tuple_compare(const box_tuple_t *tuple_a, const box_tuple_t *tuple_b,
  */
 
 int
-box_tuple_compare_with_key(const box_tuple_t *tuple_a, const char *key_b,
+box_tuple_compare_with_key(box_tuple_t *tuple_a, const char *key_b,
 			   box_key_def_t *key_def);
 
 /** \endcond public */
@@ -533,7 +533,7 @@ key_part_cmp(const struct key_part *parts1, uint32_t part_count1,
  * @retval Does the key contain NULL or not?
  */
 bool
-tuple_key_contains_null(const struct tuple *tuple, struct key_def *def);
+tuple_key_contains_null(struct tuple *tuple, struct key_def *def);
 
 /**
  * Extract key from tuple by given key definition and return
@@ -547,7 +547,7 @@ tuple_key_contains_null(const struct tuple *tuple, struct key_def *def);
  * @retval NULL     Memory allocation error
  */
 static inline char *
-tuple_extract_key(const struct tuple *tuple, struct key_def *key_def,
+tuple_extract_key(struct tuple *tuple, struct key_def *key_def,
 		  uint32_t *key_size)
 {
 	return key_def->tuple_extract_key(tuple, key_def, key_size);
@@ -599,7 +599,7 @@ key_compare(const char *key_a, const char *key_b, struct key_def *key_def);
  * @retval >0 if key_fields(tuple_a) > key_fields(tuple_b)
  */
 static inline int
-tuple_compare(const struct tuple *tuple_a, const struct tuple *tuple_b,
+tuple_compare(struct tuple *tuple_a, struct tuple *tuple_b,
 	      struct key_def *key_def)
 {
 	return key_def->tuple_compare(tuple_a, tuple_b, key_def);
@@ -617,8 +617,8 @@ tuple_compare(const struct tuple *tuple_a, const struct tuple *tuple_b,
  * @retval >0 if key_fields(tuple_a) > key_fields(tuple_b)
  */
 static inline int
-tuple_compare_hinted(const struct tuple *tuple_a, hint_t tuple_a_hint,
-		     const struct tuple *tuple_b, hint_t tuple_b_hint,
+tuple_compare_hinted(struct tuple *tuple_a, hint_t tuple_a_hint,
+		     struct tuple *tuple_b, hint_t tuple_b_hint,
 		     struct key_def *key_def)
 {
 	return key_def->tuple_compare_hinted(tuple_a, tuple_a_hint, tuple_b,
@@ -637,7 +637,7 @@ tuple_compare_hinted(const struct tuple *tuple_a, hint_t tuple_a_hint,
  * @retval >0 if key_fields(tuple) > parts(key)
  */
 static inline int
-tuple_compare_with_key(const struct tuple *tuple, const char *key,
+tuple_compare_with_key(struct tuple *tuple, const char *key,
 		       uint32_t part_count, struct key_def *key_def)
 {
 	return key_def->tuple_compare_with_key(tuple, key, part_count, key_def);
@@ -657,7 +657,7 @@ tuple_compare_with_key(const struct tuple *tuple, const char *key,
  * @retval >0 if key_fields(tuple) > parts(key)
  */
 static inline int
-tuple_compare_with_key_hinted(const struct tuple *tuple, hint_t tuple_hint,
+tuple_compare_with_key_hinted(struct tuple *tuple, hint_t tuple_hint,
 			      const char *key, uint32_t part_count,
 			      hint_t key_hint, struct key_def *key_def)
 {
@@ -692,7 +692,7 @@ tuple_hash_field(uint32_t *ph1, uint32_t *pcarry, const char **field,
  * This function updates @ph1 and @pcarry.
  */
 uint32_t
-tuple_hash_key_part(uint32_t *ph1, uint32_t *pcarry, const struct tuple *tuple,
+tuple_hash_key_part(uint32_t *ph1, uint32_t *pcarry, struct tuple *tuple,
 		    struct key_part *part);
 
 /**
@@ -702,7 +702,7 @@ tuple_hash_key_part(uint32_t *ph1, uint32_t *pcarry, const struct tuple *tuple,
  * @return - hash value
  */
 static inline uint32_t
-tuple_hash(const struct tuple *tuple, struct key_def *key_def)
+tuple_hash(struct tuple *tuple, struct key_def *key_def)
 {
 	return key_def->tuple_hash(tuple, key_def);
 }
@@ -726,7 +726,7 @@ key_hash(const char *key, struct key_def *key_def)
  * @return - hint value
  */
 static inline hint_t
-tuple_hint(const struct tuple *tuple, struct key_def *key_def)
+tuple_hint(struct tuple *tuple, struct key_def *key_def)
 {
 	return key_def->tuple_hint(tuple, key_def);
 }
diff --git a/src/box/lua/call.c b/src/box/lua/call.c
index 2049ee58..04020ef6 100644
--- a/src/box/lua/call.c
+++ b/src/box/lua/call.c
@@ -490,6 +490,6 @@ box_lua_call_init(struct lua_State *L)
 	assert(rc == 0);
 	(void) rc;
 	CTID_STRUCT_PORT_PTR = luaL_ctypeid(L, "struct port *");
-	assert(CTID_CONST_STRUCT_TUPLE_REF != 0);
+	assert(CTID_STRUCT_TUPLE_REF != 0);
 #endif
 }
diff --git a/src/box/lua/tuple.c b/src/box/lua/tuple.c
index c4c19bd1..183c3901 100644
--- a/src/box/lua/tuple.c
+++ b/src/box/lua/tuple.c
@@ -62,7 +62,7 @@ static struct luaL_serializer tuple_serializer;
 
 extern char tuple_lua[]; /* Lua source */
 
-uint32_t CTID_CONST_STRUCT_TUPLE_REF;
+uint32_t CTID_STRUCT_TUPLE_REF;
 
 static inline box_tuple_t *
 lua_checktuple(struct lua_State *L, int narg)
@@ -79,7 +79,7 @@ lua_checktuple(struct lua_State *L, int narg)
 box_tuple_t *
 luaT_istuple(struct lua_State *L, int narg)
 {
-	assert(CTID_CONST_STRUCT_TUPLE_REF != 0);
+	assert(CTID_STRUCT_TUPLE_REF != 0);
 	uint32_t ctypeid;
 	void *data;
 
@@ -87,7 +87,7 @@ luaT_istuple(struct lua_State *L, int narg)
 		return NULL;
 
 	data = luaL_checkcdata(L, narg, &ctypeid);
-	if (ctypeid != CTID_CONST_STRUCT_TUPLE_REF)
+	if (ctypeid != CTID_STRUCT_TUPLE_REF)
 		return NULL;
 
 	return *(struct tuple **) data;
@@ -320,7 +320,7 @@ lbox_tuple_to_map(struct lua_State *L)
 		names_only = lua_toboolean(L, -1);
 	}
 
-	const struct tuple *tuple = lua_checktuple(L, 1);
+	struct tuple *tuple = lua_checktuple(L, 1);
 	struct tuple_format *format = tuple_format(tuple);
 	const char *pos = tuple_data(tuple);
 	int field_count = (int)mp_decode_array(&pos);
@@ -517,9 +517,9 @@ lbox_tuple_to_string(struct lua_State *L)
 void
 luaT_pushtuple(struct lua_State *L, box_tuple_t *tuple)
 {
-	assert(CTID_CONST_STRUCT_TUPLE_REF != 0);
+	assert(CTID_STRUCT_TUPLE_REF != 0);
 	struct tuple **ptr = (struct tuple **)
-		luaL_pushcdata(L, CTID_CONST_STRUCT_TUPLE_REF);
+		luaL_pushcdata(L, CTID_STRUCT_TUPLE_REF);
 	*ptr = tuple;
 	/* The order is important - first reference tuple, next set gc */
 	box_tuple_ref(tuple);
@@ -577,6 +577,6 @@ box_lua_tuple_init(struct lua_State *L)
 	int rc = luaL_cdef(L, "struct tuple;");
 	assert(rc == 0);
 	(void) rc;
-	CTID_CONST_STRUCT_TUPLE_REF = luaL_ctypeid(L, "const struct tuple &");
-	assert(CTID_CONST_STRUCT_TUPLE_REF != 0);
+	CTID_STRUCT_TUPLE_REF = luaL_ctypeid(L, "struct tuple &");
+	assert(CTID_STRUCT_TUPLE_REF != 0);
 }
diff --git a/src/box/lua/tuple.lua b/src/box/lua/tuple.lua
index 63ea73e4..a25a2898 100644
--- a/src/box/lua/tuple.lua
+++ b/src/box/lua/tuple.lua
@@ -19,16 +19,16 @@ void
 box_tuple_unref(box_tuple_t *tuple);
 
 uint32_t
-box_tuple_field_count(const box_tuple_t *tuple);
+box_tuple_field_count(box_tuple_t *tuple);
 
 size_t
-box_tuple_bsize(const box_tuple_t *tuple);
+box_tuple_bsize(box_tuple_t *tuple);
 
 ssize_t
-box_tuple_to_buf(const box_tuple_t *tuple, char *buf, size_t size);
+box_tuple_to_buf(box_tuple_t *tuple, char *buf, size_t size);
 
 const char *
-box_tuple_field(const box_tuple_t *tuple, uint32_t i);
+box_tuple_field(box_tuple_t *tuple, uint32_t i);
 
 typedef struct tuple_iterator box_tuple_iterator_t;
 
@@ -62,7 +62,7 @@ box_tuple_upsert(box_tuple_t *tuple, const char *expr, const char *expr_end);
 local builtin = ffi.C
 
 local tuple_t = ffi.typeof('box_tuple_t')
-local const_tuple_ref_t = ffi.typeof('const box_tuple_t&')
+local const_tuple_ref_t = ffi.typeof('box_tuple_t&')
 
 local is_tuple = function(tuple)
     return tuple ~= nil and type(tuple) == 'cdata' and ffi.istype(const_tuple_ref_t, tuple)
diff --git a/src/box/memtx_rtree.c b/src/box/memtx_rtree.c
index 7d16b3e4..0a903517 100644
--- a/src/box/memtx_rtree.c
+++ b/src/box/memtx_rtree.c
@@ -116,7 +116,7 @@ mp_decode_rect_from_key(struct rtree_rect *rect, unsigned dimension,
 }
 
 static inline int
-extract_rectangle(struct rtree_rect *rect, const struct tuple *tuple,
+extract_rectangle(struct rtree_rect *rect, struct tuple *tuple,
 		  struct index_def *index_def)
 {
 	assert(index_def->key_def->part_count == 1);
diff --git a/src/box/memtx_space.c b/src/box/memtx_space.c
index d8529fe0..7bb46c76 100644
--- a/src/box/memtx_space.c
+++ b/src/box/memtx_space.c
@@ -59,9 +59,8 @@ memtx_space_bsize(struct space *space)
 /* {{{ DML */
 
 void
-memtx_space_update_bsize(struct space *space,
-			 const struct tuple *old_tuple,
-			 const struct tuple *new_tuple)
+memtx_space_update_bsize(struct space *space, struct tuple *old_tuple,
+			 struct tuple *new_tuple)
 {
 	struct memtx_space *memtx_space = (struct memtx_space *)space;
 	ssize_t old_bsize = old_tuple ? box_tuple_bsize(old_tuple) : 0;
diff --git a/src/box/memtx_space.h b/src/box/memtx_space.h
index 53253831..a14065ff 100644
--- a/src/box/memtx_space.h
+++ b/src/box/memtx_space.h
@@ -67,9 +67,8 @@ struct memtx_space {
  * @param new_tuple New tuple (inserted).
  */
 void
-memtx_space_update_bsize(struct space *space,
-			 const struct tuple *old_tuple,
-			 const struct tuple *new_tuple);
+memtx_space_update_bsize(struct space *space, struct tuple *old_tuple,
+			 struct tuple *new_tuple);
 
 int
 memtx_space_replace_no_keys(struct space *, struct tuple *, struct tuple *,
diff --git a/src/box/sql.c b/src/box/sql.c
index 855c2b74..996357b3 100644
--- a/src/box/sql.c
+++ b/src/box/sql.c
@@ -737,7 +737,7 @@ tarantoolsqlIdxKeyCompare(struct BtCursor *cursor,
 	assert(cursor->last_tuple != NULL);
 
 	struct key_def *key_def;
-	const struct tuple *tuple;
+	struct tuple *tuple;
 	const char *base;
 	struct tuple_format *format;
 	const uint32_t *field_map;
diff --git a/src/box/tuple.c b/src/box/tuple.c
index 7f06d405..9d176844 100644
--- a/src/box/tuple.c
+++ b/src/box/tuple.c
@@ -573,21 +573,21 @@ box_tuple_unref(box_tuple_t *tuple)
 }
 
 uint32_t
-box_tuple_field_count(const box_tuple_t *tuple)
+box_tuple_field_count(box_tuple_t *tuple)
 {
 	assert(tuple != NULL);
 	return tuple_field_count(tuple);
 }
 
 size_t
-box_tuple_bsize(const box_tuple_t *tuple)
+box_tuple_bsize(box_tuple_t *tuple)
 {
 	assert(tuple != NULL);
 	return tuple->bsize;
 }
 
 ssize_t
-tuple_to_buf(const struct tuple *tuple, char *buf, size_t size)
+tuple_to_buf(struct tuple *tuple, char *buf, size_t size)
 {
 	uint32_t bsize;
 	const char *data = tuple_data_range(tuple, &bsize);
@@ -598,21 +598,21 @@ tuple_to_buf(const struct tuple *tuple, char *buf, size_t size)
 }
 
 ssize_t
-box_tuple_to_buf(const box_tuple_t *tuple, char *buf, size_t size)
+box_tuple_to_buf(box_tuple_t *tuple, char *buf, size_t size)
 {
 	assert(tuple != NULL);
 	return tuple_to_buf(tuple, buf, size);
 }
 
 box_tuple_format_t *
-box_tuple_format(const box_tuple_t *tuple)
+box_tuple_format(box_tuple_t *tuple)
 {
 	assert(tuple != NULL);
 	return tuple_format(tuple);
 }
 
 const char *
-box_tuple_field(const box_tuple_t *tuple, uint32_t fieldno)
+box_tuple_field(box_tuple_t *tuple, uint32_t fieldno)
 {
 	assert(tuple != NULL);
 	return tuple_field(tuple, fieldno);
@@ -668,8 +668,7 @@ box_tuple_next(box_tuple_iterator_t *it)
 }
 
 box_tuple_t *
-box_tuple_update(const box_tuple_t *tuple, const char *expr,
-		 const char *expr_end)
+box_tuple_update(box_tuple_t *tuple, const char *expr, const char *expr_end)
 {
 	uint32_t new_size = 0, bsize;
 	const char *old_data = tuple_data_range(tuple, &bsize);
@@ -692,8 +691,7 @@ box_tuple_update(const box_tuple_t *tuple, const char *expr,
 }
 
 box_tuple_t *
-box_tuple_upsert(const box_tuple_t *tuple, const char *expr,
-		 const char *expr_end)
+box_tuple_upsert(box_tuple_t *tuple, const char *expr, const char *expr_end)
 {
 	uint32_t new_size = 0, bsize;
 	const char *old_data = tuple_data_range(tuple, &bsize);
@@ -728,7 +726,7 @@ box_tuple_new(box_tuple_format_t *format, const char *data, const char *end)
 /* }}} box_tuple_* */
 
 int
-tuple_snprint(char *buf, int size, const struct tuple *tuple)
+tuple_snprint(char *buf, int size, struct tuple *tuple)
 {
 	int total = 0;
 	if (tuple == NULL) {
@@ -740,7 +738,7 @@ tuple_snprint(char *buf, int size, const struct tuple *tuple)
 }
 
 const char *
-tuple_str(const struct tuple *tuple)
+tuple_str(struct tuple *tuple)
 {
 	char *buf = tt_static_buf();
 	if (tuple_snprint(buf, TT_STATIC_BUF_LEN, tuple) < 0)
diff --git a/src/box/tuple.h b/src/box/tuple.h
index 8b12fd5a..eed8e1a3 100644
--- a/src/box/tuple.h
+++ b/src/box/tuple.h
@@ -126,14 +126,14 @@ box_tuple_unref(box_tuple_t *tuple);
  * \param tuple a tuple
  */
 uint32_t
-box_tuple_field_count(const box_tuple_t *tuple);
+box_tuple_field_count(box_tuple_t *tuple);
 
 /**
  * Return the number of bytes used to store internal tuple data (MsgPack Array).
  * \param tuple a tuple
  */
 size_t
-box_tuple_bsize(const box_tuple_t *tuple);
+box_tuple_bsize(box_tuple_t *tuple);
 
 /**
  * Dump raw MsgPack data to the memory byffer \a buf of size \a size.
@@ -146,7 +146,7 @@ box_tuple_bsize(const box_tuple_t *tuple);
  * which would have been written if enough space had been available.
  */
 ssize_t
-box_tuple_to_buf(const box_tuple_t *tuple, char *buf, size_t size);
+box_tuple_to_buf(box_tuple_t *tuple, char *buf, size_t size);
 
 /**
  * Return the associated format.
@@ -154,7 +154,7 @@ box_tuple_to_buf(const box_tuple_t *tuple, char *buf, size_t size);
  * \return tuple_format
  */
 box_tuple_format_t *
-box_tuple_format(const box_tuple_t *tuple);
+box_tuple_format(box_tuple_t *tuple);
 
 /**
  * Return the raw tuple field in MsgPack format.
@@ -167,7 +167,7 @@ box_tuple_format(const box_tuple_t *tuple);
  * \retval msgpack otherwise
  */
 const char *
-box_tuple_field(const box_tuple_t *tuple, uint32_t fieldno);
+box_tuple_field(box_tuple_t *tuple, uint32_t fieldno);
 
 /**
  * Tuple iterator
@@ -277,12 +277,10 @@ box_tuple_t *
 box_tuple_new(box_tuple_format_t *format, const char *data, const char *end);
 
 box_tuple_t *
-box_tuple_update(const box_tuple_t *tuple, const char *expr, const
-		 char *expr_end);
+box_tuple_update(box_tuple_t *tuple, const char *expr, const char *expr_end);
 
 box_tuple_t *
-box_tuple_upsert(const box_tuple_t *tuple, const char *expr, const
-		 char *expr_end);
+box_tuple_upsert(box_tuple_t *tuple, const char *expr, const char *expr_end);
 
 /** \endcond public */
 
@@ -330,7 +328,7 @@ struct PACKED tuple
 
 /** Size of the tuple including size of struct tuple. */
 static inline size_t
-tuple_size(const struct tuple *tuple)
+tuple_size(struct tuple *tuple)
 {
 	/* data_offset includes sizeof(struct tuple). */
 	return tuple->data_offset + tuple->bsize;
@@ -342,7 +340,7 @@ tuple_size(const struct tuple *tuple)
  * @return MessagePack array.
  */
 static inline const char *
-tuple_data(const struct tuple *tuple)
+tuple_data(struct tuple *tuple)
 {
 	return (const char *) tuple + tuple->data_offset;
 }
@@ -351,7 +349,7 @@ tuple_data(const struct tuple *tuple)
  * Wrapper around tuple_data() which returns NULL if @tuple == NULL.
  */
 static inline const char *
-tuple_data_or_null(const struct tuple *tuple)
+tuple_data_or_null(struct tuple *tuple)
 {
 	return tuple != NULL ? tuple_data(tuple) : NULL;
 }
@@ -363,7 +361,7 @@ tuple_data_or_null(const struct tuple *tuple)
  * @return MessagePack array.
  */
 static inline const char *
-tuple_data_range(const struct tuple *tuple, uint32_t *p_size)
+tuple_data_range(struct tuple *tuple, uint32_t *p_size)
 {
 	*p_size = tuple->bsize;
 	return (const char *) tuple + tuple->data_offset;
@@ -385,7 +383,7 @@ tuple_data_range(const struct tuple *tuple, uint32_t *p_size)
  * @see mp_snprint
  */
 int
-tuple_snprint(char *buf, int size, const struct tuple *tuple);
+tuple_snprint(char *buf, int size, struct tuple *tuple);
 
 /**
  * Format a tuple into string using a static buffer.
@@ -394,7 +392,7 @@ tuple_snprint(char *buf, int size, const struct tuple *tuple);
  * @return formatted null-terminated string
  */
 const char *
-tuple_str(const struct tuple *tuple);
+tuple_str(struct tuple *tuple);
 
 /**
  * Format msgpack into string using a static buffer.
@@ -411,7 +409,7 @@ mp_str(const char *data);
  * @retval Tuple format instance.
  */
 static inline struct tuple_format *
-tuple_format(const struct tuple *tuple)
+tuple_format(struct tuple *tuple)
 {
 	struct tuple_format *format = tuple_format_by_id(tuple->format_id);
 	assert(tuple_format_id(format) == tuple->format_id);
@@ -483,7 +481,7 @@ tuple_validate(struct tuple_format *format, struct tuple *tuple)
  * @sa tuple_field_map_create()
  */
 static inline const uint32_t *
-tuple_field_map(const struct tuple *tuple)
+tuple_field_map(struct tuple *tuple)
 {
 	return (const uint32_t *) ((const char *) tuple + tuple->data_offset);
 }
@@ -494,7 +492,7 @@ tuple_field_map(const struct tuple *tuple)
  * @return the number of fields in tuple
  */
 static inline uint32_t
-tuple_field_count(const struct tuple *tuple)
+tuple_field_count(struct tuple *tuple)
 {
 	const char *data = tuple_data(tuple);
 	return mp_decode_array(&data);
@@ -607,7 +605,7 @@ tuple_field_raw(struct tuple_format *format, const char *tuple,
  * @retval NULL when fieldno is out of range
  */
 static inline const char *
-tuple_field(const struct tuple *tuple, uint32_t fieldno)
+tuple_field(struct tuple *tuple, uint32_t fieldno)
 {
 	return tuple_field_raw(tuple_format(tuple), tuple_data(tuple),
 			       tuple_field_map(tuple), fieldno);
@@ -666,7 +664,7 @@ tuple_field_raw_by_part(struct tuple_format *format, const char *data,
  * @retval Field data if the field exists or NULL.
  */
 static inline const char *
-tuple_field_by_part(const struct tuple *tuple, struct key_part *part)
+tuple_field_by_part(struct tuple *tuple, struct key_part *part)
 {
 	return tuple_field_raw_by_part(tuple_format(tuple), tuple_data(tuple),
 				       tuple_field_map(tuple), part);
@@ -801,8 +799,7 @@ mp_tuple_assert(const char *tuple, const char *tuple_end)
 }
 
 static inline const char *
-tuple_field_with_type(const struct tuple *tuple, uint32_t fieldno,
-		      enum mp_type type)
+tuple_field_with_type(struct tuple *tuple, uint32_t fieldno, enum mp_type type)
 {
 	const char *field = tuple_field(tuple, fieldno);
 	if (field == NULL) {
@@ -824,7 +821,7 @@ tuple_field_with_type(const struct tuple *tuple, uint32_t fieldno,
  * as bool.
  */
 static inline int
-tuple_field_bool(const struct tuple *tuple, uint32_t fieldno, bool *out)
+tuple_field_bool(struct tuple *tuple, uint32_t fieldno, bool *out)
 {
 	const char *field = tuple_field_with_type(tuple, fieldno, MP_BOOL);
 	if (field == NULL)
@@ -838,7 +835,7 @@ tuple_field_bool(const struct tuple *tuple, uint32_t fieldno, bool *out)
  * as int64_t.
  */
 static inline int
-tuple_field_i64(const struct tuple *tuple, uint32_t fieldno, int64_t *out)
+tuple_field_i64(struct tuple *tuple, uint32_t fieldno, int64_t *out)
 {
 	const char *field = tuple_field(tuple, fieldno);
 	if (field == NULL) {
@@ -871,7 +868,7 @@ tuple_field_i64(const struct tuple *tuple, uint32_t fieldno, int64_t *out)
  * as uint64_t.
  */
 static inline int
-tuple_field_u64(const struct tuple *tuple, uint32_t fieldno, uint64_t *out)
+tuple_field_u64(struct tuple *tuple, uint32_t fieldno, uint64_t *out)
 {
 	const char *field = tuple_field_with_type(tuple, fieldno, MP_UINT);
 	if (field == NULL)
@@ -885,7 +882,7 @@ tuple_field_u64(const struct tuple *tuple, uint32_t fieldno, uint64_t *out)
  * as uint32_t.
  */
 static inline int
-tuple_field_u32(const struct tuple *tuple, uint32_t fieldno, uint32_t *out)
+tuple_field_u32(struct tuple *tuple, uint32_t fieldno, uint32_t *out)
 {
 	const char *field = tuple_field_with_type(tuple, fieldno, MP_UINT);
 	if (field == NULL)
@@ -905,7 +902,7 @@ tuple_field_u32(const struct tuple *tuple, uint32_t fieldno, uint32_t *out)
  * as a string.
  */
 static inline const char *
-tuple_field_str(const struct tuple *tuple, uint32_t fieldno, uint32_t *len)
+tuple_field_str(struct tuple *tuple, uint32_t fieldno, uint32_t *len)
 {
 	const char *field = tuple_field_with_type(tuple, fieldno, MP_STR);
 	if (field == NULL)
@@ -918,7 +915,7 @@ tuple_field_str(const struct tuple *tuple, uint32_t fieldno, uint32_t *len)
  * as a NUL-terminated string - returns a string of up to 256 bytes.
  */
 static inline const char *
-tuple_field_cstr(const struct tuple *tuple, uint32_t fieldno)
+tuple_field_cstr(struct tuple *tuple, uint32_t fieldno)
 {
 	uint32_t len;
 	const char *str = tuple_field_str(tuple, fieldno, &len);
@@ -932,8 +929,7 @@ tuple_field_cstr(const struct tuple *tuple, uint32_t fieldno)
  * representation of UUID, and return a 16-byte representation.
  */
 static inline int
-tuple_field_uuid(const struct tuple *tuple, int fieldno,
-		 struct tt_uuid *out)
+tuple_field_uuid(struct tuple *tuple, int fieldno, struct tt_uuid *out)
 {
 	const char *value = tuple_field_cstr(tuple, fieldno);
 	if (tt_uuid_from_string(value, out) != 0) {
@@ -1012,7 +1008,7 @@ tuple_bless(struct tuple *tuple)
  * \copydoc box_tuple_to_buf()
  */
 ssize_t
-tuple_to_buf(const struct tuple *tuple, char *buf, size_t size);
+tuple_to_buf(struct tuple *tuple, char *buf, size_t size);
 
 #if defined(__cplusplus)
 } /* extern "C" */
@@ -1022,7 +1018,7 @@ tuple_to_buf(const struct tuple *tuple, char *buf, size_t size);
 
 /* @copydoc tuple_field_with_type() */
 static inline const char *
-tuple_field_with_type_xc(const struct tuple *tuple, uint32_t fieldno,
+tuple_field_with_type_xc(struct tuple *tuple, uint32_t fieldno,
 		         enum mp_type type)
 {
 	const char *out = tuple_field_with_type(tuple, fieldno, type);
@@ -1033,7 +1029,7 @@ tuple_field_with_type_xc(const struct tuple *tuple, uint32_t fieldno,
 
 /* @copydoc tuple_field_bool() */
 static inline bool
-tuple_field_bool_xc(const struct tuple *tuple, uint32_t fieldno)
+tuple_field_bool_xc(struct tuple *tuple, uint32_t fieldno)
 {
 	bool out;
 	if (tuple_field_bool(tuple, fieldno, &out) != 0)
@@ -1043,7 +1039,7 @@ tuple_field_bool_xc(const struct tuple *tuple, uint32_t fieldno)
 
 /* @copydoc tuple_field_i64() */
 static inline int64_t
-tuple_field_i64_xc(const struct tuple *tuple, uint32_t fieldno)
+tuple_field_i64_xc(struct tuple *tuple, uint32_t fieldno)
 {
 	int64_t out;
 	if (tuple_field_i64(tuple, fieldno, &out) != 0)
@@ -1053,7 +1049,7 @@ tuple_field_i64_xc(const struct tuple *tuple, uint32_t fieldno)
 
 /* @copydoc tuple_field_u64() */
 static inline uint64_t
-tuple_field_u64_xc(const struct tuple *tuple, uint32_t fieldno)
+tuple_field_u64_xc(struct tuple *tuple, uint32_t fieldno)
 {
 	uint64_t out;
 	if (tuple_field_u64(tuple, fieldno, &out) != 0)
@@ -1063,7 +1059,7 @@ tuple_field_u64_xc(const struct tuple *tuple, uint32_t fieldno)
 
 /* @copydoc tuple_field_u32() */
 static inline uint32_t
-tuple_field_u32_xc(const struct tuple *tuple, uint32_t fieldno)
+tuple_field_u32_xc(struct tuple *tuple, uint32_t fieldno)
 {
 	uint32_t out;
 	if (tuple_field_u32(tuple, fieldno, &out) != 0)
@@ -1073,8 +1069,7 @@ tuple_field_u32_xc(const struct tuple *tuple, uint32_t fieldno)
 
 /** @copydoc tuple_field_str() */
 static inline const char *
-tuple_field_str_xc(const struct tuple *tuple, uint32_t fieldno,
-			uint32_t *len)
+tuple_field_str_xc(struct tuple *tuple, uint32_t fieldno, uint32_t *len)
 {
 	const char *ret = tuple_field_str(tuple, fieldno, len);
 	if (ret == NULL)
@@ -1084,7 +1079,7 @@ tuple_field_str_xc(const struct tuple *tuple, uint32_t fieldno,
 
 /** @copydoc tuple_field_cstr() */
 static inline const char *
-tuple_field_cstr_xc(const struct tuple *tuple, uint32_t fieldno)
+tuple_field_cstr_xc(struct tuple *tuple, uint32_t fieldno)
 {
 	const char *out = tuple_field_cstr(tuple, fieldno);
 	if (out == NULL)
@@ -1094,8 +1089,7 @@ tuple_field_cstr_xc(const struct tuple *tuple, uint32_t fieldno)
 
 /** @copydoc tuple_field_uuid() */
 static inline void
-tuple_field_uuid_xc(const struct tuple *tuple, int fieldno,
-		    struct tt_uuid *out)
+tuple_field_uuid_xc(struct tuple *tuple, int fieldno, struct tt_uuid *out)
 {
 	if (tuple_field_uuid(tuple, fieldno, out) != 0)
 		diag_raise();
diff --git a/src/box/tuple_bloom.c b/src/box/tuple_bloom.c
index 8d918065..935df798 100644
--- a/src/box/tuple_bloom.c
+++ b/src/box/tuple_bloom.c
@@ -105,7 +105,7 @@ tuple_hash_array_add(struct tuple_hash_array *hash_arr, uint32_t hash)
 
 int
 tuple_bloom_builder_add(struct tuple_bloom_builder *builder,
-			const struct tuple *tuple, struct key_def *key_def)
+			struct tuple *tuple, struct key_def *key_def)
 {
 	assert(builder->part_count == key_def->part_count);
 
@@ -199,7 +199,7 @@ tuple_bloom_delete(struct tuple_bloom *bloom)
 
 bool
 tuple_bloom_maybe_has(const struct tuple_bloom *bloom,
-		      const struct tuple *tuple, struct key_def *key_def)
+		      struct tuple *tuple, struct key_def *key_def)
 {
 	if (bloom->is_legacy) {
 		return bloom_maybe_has(&bloom->parts[0],
diff --git a/src/box/tuple_bloom.h b/src/box/tuple_bloom.h
index 018727c6..5a630a49 100644
--- a/src/box/tuple_bloom.h
+++ b/src/box/tuple_bloom.h
@@ -133,7 +133,7 @@ tuple_bloom_builder_delete(struct tuple_bloom_builder *builder);
  */
 int
 tuple_bloom_builder_add(struct tuple_bloom_builder *builder,
-			const struct tuple *tuple, struct key_def *key_def);
+			struct tuple *tuple, struct key_def *key_def);
 
 /**
  * Add a key hash to a tuple bloom filter builder.
@@ -174,7 +174,7 @@ tuple_bloom_delete(struct tuple_bloom *bloom);
  */
 bool
 tuple_bloom_maybe_has(const struct tuple_bloom *bloom,
-		      const struct tuple *tuple, struct key_def *key_def);
+		      struct tuple *tuple, struct key_def *key_def);
 
 /**
  * Check if a tuple matching a key was stored in a tuple bloom filter.
diff --git a/src/box/tuple_compare.cc b/src/box/tuple_compare.cc
index 93756365..b80777c8 100644
--- a/src/box/tuple_compare.cc
+++ b/src/box/tuple_compare.cc
@@ -447,8 +447,8 @@ tuple_compare_field_with_type(const char *field_a, enum mp_type a_type,
 
 template<bool is_nullable, bool has_optional_parts, bool has_json_paths>
 static inline int
-tuple_compare_slowpath_hinted(const struct tuple *tuple_a, hint_t tuple_a_hint,
-			      const struct tuple *tuple_b, hint_t tuple_b_hint,
+tuple_compare_slowpath_hinted(struct tuple *tuple_a, hint_t tuple_a_hint,
+			      struct tuple *tuple_b, hint_t tuple_b_hint,
 			      struct key_def *key_def)
 {
 	assert(has_json_paths == key_def->has_json_paths);
@@ -582,7 +582,7 @@ tuple_compare_slowpath_hinted(const struct tuple *tuple_a, hint_t tuple_a_hint,
 
 template<bool is_nullable, bool has_optional_parts, bool has_json_paths>
 static inline int
-tuple_compare_slowpath(const struct tuple *tuple_a, const struct tuple *tuple_b,
+tuple_compare_slowpath(struct tuple *tuple_a, struct tuple *tuple_b,
 		       struct key_def *key_def)
 {
 	return tuple_compare_slowpath_hinted
@@ -592,7 +592,7 @@ tuple_compare_slowpath(const struct tuple *tuple_a, const struct tuple *tuple_b,
 
 template<bool is_nullable, bool has_optional_parts, bool has_json_paths>
 static inline int
-tuple_compare_with_key_slowpath_hinted(const struct tuple *tuple,
+tuple_compare_with_key_slowpath_hinted(struct tuple *tuple,
 		hint_t tuple_hint, const char *key, uint32_t part_count,
 		hint_t key_hint, struct key_def *key_def)
 {
@@ -680,7 +680,7 @@ tuple_compare_with_key_slowpath_hinted(const struct tuple *tuple,
 
 template<bool is_nullable, bool has_optional_parts, bool has_json_paths>
 static inline int
-tuple_compare_with_key_slowpath(const struct tuple *tuple, const char *key,
+tuple_compare_with_key_slowpath(struct tuple *tuple, const char *key,
 				uint32_t part_count, struct key_def *key_def)
 {
 	return tuple_compare_with_key_slowpath_hinted
@@ -746,7 +746,7 @@ key_compare_parts(const char *key_a, const char *key_b, uint32_t part_count,
 
 template<bool is_nullable, bool has_optional_parts>
 static inline int
-tuple_compare_with_key_sequential_hinted(const struct tuple *tuple,
+tuple_compare_with_key_sequential_hinted(struct tuple *tuple,
 		hint_t tuple_hint, const char *key, uint32_t part_count,
 		hint_t key_hint, struct key_def *key_def)
 {
@@ -791,7 +791,7 @@ tuple_compare_with_key_sequential_hinted(const struct tuple *tuple,
 
 template<bool is_nullable, bool has_optional_parts>
 static inline int
-tuple_compare_with_key_sequential(const struct tuple *tuple, const char *key,
+tuple_compare_with_key_sequential(struct tuple *tuple, const char *key,
 				  uint32_t part_count, struct key_def *key_def)
 {
 	return tuple_compare_with_key_sequential_hinted
@@ -819,8 +819,8 @@ key_compare(const char *key_a, const char *key_b, struct key_def *key_def)
 
 template <bool is_nullable, bool has_optional_parts>
 static int
-tuple_compare_sequential_hinted(const struct tuple *tuple_a, hint_t tuple_a_hint,
-				const struct tuple *tuple_b, hint_t tuple_b_hint,
+tuple_compare_sequential_hinted(struct tuple *tuple_a, hint_t tuple_a_hint,
+				struct tuple *tuple_b, hint_t tuple_b_hint,
 				struct key_def *key_def)
 {
 	assert(!has_optional_parts || is_nullable);
@@ -891,8 +891,8 @@ tuple_compare_sequential_hinted(const struct tuple *tuple_a, hint_t tuple_a_hint
 
 template <bool is_nullable, bool has_optional_parts>
 static int
-tuple_compare_sequential(const struct tuple *tuple_a,
-			 const struct tuple *tuple_b, struct key_def *key_def)
+tuple_compare_sequential(struct tuple *tuple_a, struct tuple *tuple_b,
+			 struct key_def *key_def)
 {
 	return tuple_compare_sequential_hinted
 		<is_nullable, has_optional_parts>
@@ -965,8 +965,8 @@ template <int IDX, int TYPE, int ...MORE_TYPES> struct FieldCompare { };
 template <int IDX, int TYPE, int IDX2, int TYPE2, int ...MORE_TYPES>
 struct FieldCompare<IDX, TYPE, IDX2, TYPE2, MORE_TYPES...>
 {
-	inline static int compare(const struct tuple *tuple_a,
-				  const struct tuple *tuple_b,
+	inline static int compare(struct tuple *tuple_a,
+				  struct tuple *tuple_b,
 				  struct tuple_format *format_a,
 				  struct tuple_format *format_b,
 				  const char *field_a,
@@ -997,8 +997,8 @@ struct FieldCompare<IDX, TYPE, IDX2, TYPE2, MORE_TYPES...>
 template <int IDX, int TYPE>
 struct FieldCompare<IDX, TYPE>
 {
-	inline static int compare(const struct tuple *,
-				  const struct tuple *,
+	inline static int compare(struct tuple *,
+				  struct tuple *,
 				  struct tuple_format *,
 				  struct tuple_format *,
 				  const char *field_a,
@@ -1014,8 +1014,7 @@ struct FieldCompare<IDX, TYPE>
 template <int IDX, int TYPE, int ...MORE_TYPES>
 struct TupleCompare
 {
-	static int compare(const struct tuple *tuple_a,
-			   const struct tuple *tuple_b,
+	static int compare(struct tuple *tuple_a, struct tuple *tuple_b,
 			   struct key_def *)
 	{
 		struct tuple_format *format_a = tuple_format(tuple_a);
@@ -1030,10 +1029,8 @@ struct TupleCompare
 				format_b, field_a, field_b);
 	}
 
-	static int compare_hinted(const struct tuple *tuple_a,
-				  hint_t tuple_a_hint,
-				  const struct tuple *tuple_b,
-				  hint_t tuple_b_hint,
+	static int compare_hinted(struct tuple *tuple_a, hint_t tuple_a_hint,
+				  struct tuple *tuple_b, hint_t tuple_b_hint,
 				  struct key_def *key_def)
 	{
 		int rc = hint_cmp(tuple_a_hint, tuple_b_hint);
@@ -1045,8 +1042,7 @@ struct TupleCompare
 
 template <int TYPE, int ...MORE_TYPES>
 struct TupleCompare<0, TYPE, MORE_TYPES...> {
-	static int compare(const struct tuple *tuple_a,
-			   const struct tuple *tuple_b,
+	static int compare(struct tuple *tuple_a, struct tuple *tuple_b,
 			   struct key_def *)
 	{
 		struct tuple_format *format_a = tuple_format(tuple_a);
@@ -1059,10 +1055,8 @@ struct TupleCompare<0, TYPE, MORE_TYPES...> {
 					format_a, format_b, field_a, field_b);
 	}
 
-	static int compare_hinted(const struct tuple *tuple_a,
-				  hint_t tuple_a_hint,
-				  const struct tuple *tuple_b,
-				  hint_t tuple_b_hint,
+	static int compare_hinted(struct tuple *tuple_a, hint_t tuple_a_hint,
+				  struct tuple *tuple_b, hint_t tuple_b_hint,
 				  struct key_def *key_def)
 	{
 		int rc = hint_cmp(tuple_a_hint, tuple_b_hint);
@@ -1175,9 +1169,9 @@ template <int FLD_ID, int IDX, int TYPE, int IDX2, int TYPE2, int ...MORE_TYPES>
 struct FieldCompareWithKey<FLD_ID, IDX, TYPE, IDX2, TYPE2, MORE_TYPES...>
 {
 	inline static int
-	compare(const struct tuple *tuple, const char *key,
-		uint32_t part_count, struct key_def *key_def,
-		struct tuple_format *format, const char *field)
+	compare(struct tuple *tuple, const char *key, uint32_t part_count,
+		struct key_def *key_def, struct tuple_format *format,
+		const char *field)
 	{
 		int r;
 		/* static if */
@@ -1201,7 +1195,7 @@ struct FieldCompareWithKey<FLD_ID, IDX, TYPE, IDX2, TYPE2, MORE_TYPES...>
 
 template <int FLD_ID, int IDX, int TYPE>
 struct FieldCompareWithKey<FLD_ID, IDX, TYPE> {
-	inline static int compare(const struct tuple *,
+	inline static int compare(struct tuple *,
 				  const char *key,
 				  uint32_t,
 				  struct key_def *,
@@ -1219,8 +1213,8 @@ template <int FLD_ID, int IDX, int TYPE, int ...MORE_TYPES>
 struct TupleCompareWithKey
 {
 	static int
-	compare(const struct tuple *tuple, const char *key,
-		uint32_t part_count, struct key_def *key_def)
+	compare(struct tuple *tuple, const char *key, uint32_t part_count,
+		struct key_def *key_def)
 	{
 		/* Part count can be 0 in wildcard searches. */
 		if (part_count == 0)
@@ -1235,7 +1229,7 @@ struct TupleCompareWithKey
 	}
 
 	static int
-	compare_hinted(const struct tuple *tuple, hint_t tuple_hint,
+	compare_hinted(struct tuple *tuple, hint_t tuple_hint,
 		       const char *key, uint32_t part_count, hint_t key_hint,
 		       struct key_def *key_def)
 	{
@@ -1249,10 +1243,9 @@ struct TupleCompareWithKey
 template <int TYPE, int ...MORE_TYPES>
 struct TupleCompareWithKey<0, 0, TYPE, MORE_TYPES...>
 {
-	static int compare(const struct tuple *tuple,
-				  const char *key,
-				  uint32_t part_count,
-				  struct key_def *key_def)
+	static int compare(struct tuple *tuple,
+			   const char *key, uint32_t part_count,
+			   struct key_def *key_def)
 	{
 		/* Part count can be 0 in wildcard searches. */
 		if (part_count == 0)
@@ -1266,7 +1259,7 @@ struct TupleCompareWithKey<0, 0, TYPE, MORE_TYPES...>
 	}
 
 	static int
-	compare_hinted(const struct tuple *tuple, hint_t tuple_hint,
+	compare_hinted(struct tuple *tuple, hint_t tuple_hint,
 		       const char *key, uint32_t part_count, hint_t key_hint,
 		       struct key_def *key_def)
 	{
@@ -1603,7 +1596,7 @@ key_hint(const char *key, uint32_t part_count, struct key_def *key_def)
 
 template <enum field_type type, bool is_nullable>
 static hint_t
-tuple_hint(const struct tuple *tuple, struct key_def *key_def)
+tuple_hint(struct tuple *tuple, struct key_def *key_def)
 {
 	const char *field = tuple_field_by_part(tuple, key_def->parts);
 	if (is_nullable && field == NULL)
diff --git a/src/box/tuple_convert.c b/src/box/tuple_convert.c
index 124d91d2..5cc268ae 100644
--- a/src/box/tuple_convert.c
+++ b/src/box/tuple_convert.c
@@ -38,7 +38,7 @@
 #include <trivia/util.h>
 
 int
-tuple_to_obuf(const struct tuple *tuple, struct obuf *buf)
+tuple_to_obuf(struct tuple *tuple, struct obuf *buf)
 {
 	uint32_t bsize;
 	const char *data = tuple_data_range(tuple, &bsize);
@@ -227,7 +227,7 @@ encode_node(yaml_emitter_t *emitter, const char **data)
 }
 
 char *
-tuple_to_yaml(const struct tuple *tuple)
+tuple_to_yaml(struct tuple *tuple)
 {
 	const char *data = tuple_data(tuple);
 	yaml_emitter_t emitter;
diff --git a/src/box/tuple_convert.h b/src/box/tuple_convert.h
index bfe3de3c..999fecac 100644
--- a/src/box/tuple_convert.h
+++ b/src/box/tuple_convert.h
@@ -41,7 +41,7 @@ struct tuple;
 
 /* Store tuple in the output buffer in iproto format. */
 int
-tuple_to_obuf(const struct tuple *tuple, struct obuf *buf);
+tuple_to_obuf(struct tuple *tuple, struct obuf *buf);
 
 /**
  * Convert tuple to yaml string
@@ -51,7 +51,7 @@ tuple_to_obuf(const struct tuple *tuple, struct obuf *buf);
  * \retval pointer to string allocated on fiber()->gc region
  */
 char *
-tuple_to_yaml(const struct tuple *tuple);
+tuple_to_yaml(struct tuple *tuple);
 
 #if defined(__cplusplus)
 } /* extern "C" */
diff --git a/src/box/tuple_extract_key.cc b/src/box/tuple_extract_key.cc
index 28ca80cf..3c49094b 100644
--- a/src/box/tuple_extract_key.cc
+++ b/src/box/tuple_extract_key.cc
@@ -86,7 +86,7 @@ tuple_extract_key_sequential_raw(const char *data, const char *data_end,
  */
 template <bool has_optional_parts>
 static inline char *
-tuple_extract_key_sequential(const struct tuple *tuple, struct key_def *key_def,
+tuple_extract_key_sequential(struct tuple *tuple, struct key_def *key_def,
 			     uint32_t *key_size)
 {
 	assert(key_def_is_sequential(key_def));
@@ -107,8 +107,8 @@ tuple_extract_key_sequential(const struct tuple *tuple, struct key_def *key_def,
 template <bool contains_sequential_parts, bool has_optional_parts,
 	  bool has_json_paths>
 static char *
-tuple_extract_key_slowpath(const struct tuple *tuple,
-			   struct key_def *key_def, uint32_t *key_size)
+tuple_extract_key_slowpath(struct tuple *tuple, struct key_def *key_def,
+			   uint32_t *key_size)
 {
 	assert(has_json_paths == key_def->has_json_paths);
 	assert(!has_optional_parts || key_def->is_nullable);
@@ -408,7 +408,7 @@ key_def_set_extract_func(struct key_def *key_def)
 }
 
 bool
-tuple_key_contains_null(const struct tuple *tuple, struct key_def *def)
+tuple_key_contains_null(struct tuple *tuple, struct key_def *def)
 {
 	struct tuple_format *format = tuple_format(tuple);
 	const char *data = tuple_data(tuple);
diff --git a/src/box/tuple_hash.cc b/src/box/tuple_hash.cc
index 9ee43550..85095eb8 100644
--- a/src/box/tuple_hash.cc
+++ b/src/box/tuple_hash.cc
@@ -153,8 +153,7 @@ struct TupleFieldHash<TYPE> {
 template <int TYPE, int ...MORE_TYPES>
 struct TupleHash
 {
-	static uint32_t hash(const struct tuple *tuple,
-			     struct key_def *key_def)
+	static uint32_t hash(struct tuple *tuple, struct key_def *key_def)
 	{
 		uint32_t h = HASH_SEED;
 		uint32_t carry = 0;
@@ -169,8 +168,7 @@ struct TupleHash
 
 template <>
 struct TupleHash<FIELD_TYPE_UNSIGNED> {
-	static uint32_t	hash(const struct tuple *tuple,
-			     struct key_def *key_def)
+	static uint32_t	hash(struct tuple *tuple, struct key_def *key_def)
 	{
 		const char *field =
 			tuple_field_by_part(tuple, key_def->parts);
@@ -217,7 +215,7 @@ static const hasher_signature hash_arr[] = {
 
 template <bool has_optional_parts, bool has_json_paths>
 uint32_t
-tuple_hash_slowpath(const struct tuple *tuple, struct key_def *key_def);
+tuple_hash_slowpath(struct tuple *tuple, struct key_def *key_def);
 
 uint32_t
 key_hash_slowpath(const char *key, struct key_def *key_def);
@@ -347,7 +345,7 @@ tuple_hash_null(uint32_t *ph1, uint32_t *pcarry)
 }
 
 uint32_t
-tuple_hash_key_part(uint32_t *ph1, uint32_t *pcarry, const struct tuple *tuple,
+tuple_hash_key_part(uint32_t *ph1, uint32_t *pcarry, struct tuple *tuple,
 		    struct key_part *part)
 {
 	const char *field = tuple_field_by_part(tuple, part);
@@ -358,7 +356,7 @@ tuple_hash_key_part(uint32_t *ph1, uint32_t *pcarry, const struct tuple *tuple,
 
 template <bool has_optional_parts, bool has_json_paths>
 uint32_t
-tuple_hash_slowpath(const struct tuple *tuple, struct key_def *key_def)
+tuple_hash_slowpath(struct tuple *tuple, struct key_def *key_def)
 {
 	assert(has_json_paths == key_def->has_json_paths);
 	assert(has_optional_parts == key_def->has_optional_parts);
diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index da891025..b8f94b26 100644
--- a/src/box/vinyl.c
+++ b/src/box/vinyl.c
@@ -1539,7 +1539,7 @@ vy_check_is_unique_primary(struct vy_tx *tx, const struct vy_read_view **rv,
 static int
 vy_check_is_unique_secondary(struct vy_tx *tx, const struct vy_read_view **rv,
 			     const char *space_name, const char *index_name,
-			     struct vy_lsm *lsm, const struct tuple *stmt)
+			     struct vy_lsm *lsm, struct tuple *stmt)
 {
 	assert(lsm->index_id > 0);
 	assert(vy_stmt_type(stmt) == IPROTO_INSERT ||
@@ -1771,7 +1771,7 @@ vy_delete(struct vy_env *env, struct vy_tx *tx, struct txn_stmt *stmt,
  */
 static inline int
 vy_check_update(struct space *space, const struct vy_lsm *pk,
-		const struct tuple *old_tuple, const struct tuple *new_tuple,
+		struct tuple *old_tuple, struct tuple *new_tuple,
 		uint64_t column_mask)
 {
 	if (!key_update_can_be_skipped(pk->key_def->column_mask, column_mask) &&
@@ -3557,13 +3557,13 @@ vy_squash_process(struct vy_squash *squash)
 	vy_mem_tree_iterator_prev(&mem->tree, &mem_itr);
 	uint8_t n_upserts = 0;
 	while (!vy_mem_tree_iterator_is_invalid(&mem_itr)) {
-		const struct tuple *mem_stmt;
+		struct tuple *mem_stmt;
 		mem_stmt = *vy_mem_tree_iterator_get_elem(&mem->tree, &mem_itr);
 		if (vy_stmt_compare(result, mem_stmt, lsm->cmp_def) != 0 ||
 		    vy_stmt_type(mem_stmt) != IPROTO_UPSERT)
 			break;
 		assert(vy_stmt_lsn(mem_stmt) >= MAX_LSN);
-		vy_stmt_set_n_upserts((struct tuple *)mem_stmt, n_upserts);
+		vy_stmt_set_n_upserts(mem_stmt, n_upserts);
 		if (n_upserts <= VY_UPSERT_THRESHOLD)
 			++n_upserts;
 		vy_mem_tree_iterator_prev(&mem->tree, &mem_itr);
@@ -3576,7 +3576,7 @@ vy_squash_process(struct vy_squash *squash)
 	 * and adjust the quota.
 	 */
 	size_t mem_used_before = lsregion_used(&env->mem_env.allocator);
-	const struct tuple *region_stmt = NULL;
+	struct tuple *region_stmt = NULL;
 	int rc = vy_lsm_set(lsm, mem, result, &region_stmt);
 	tuple_unref(result);
 	size_t mem_used_after = lsregion_used(&env->mem_env.allocator);
@@ -3998,13 +3998,13 @@ err:
  */
 static int
 vy_build_insert_stmt(struct vy_lsm *lsm, struct vy_mem *mem,
-		     const struct tuple *stmt, int64_t lsn)
+		     struct tuple *stmt, int64_t lsn)
 {
-	const struct tuple *region_stmt = vy_stmt_dup_lsregion(stmt,
+	struct tuple *region_stmt = vy_stmt_dup_lsregion(stmt,
 				&mem->env->allocator, mem->generation);
 	if (region_stmt == NULL)
 		return -1;
-	vy_stmt_set_lsn((struct tuple *)region_stmt, lsn);
+	vy_stmt_set_lsn(region_stmt, lsn);
 	if (vy_mem_insert(mem, region_stmt) != 0)
 		return -1;
 	vy_mem_commit_stmt(mem, region_stmt);
@@ -4086,7 +4086,7 @@ vy_build_insert_tuple(struct vy_env *env, struct vy_lsm *lsm,
  */
 static int
 vy_build_recover_stmt(struct vy_lsm *lsm, struct vy_lsm *pk,
-		      const struct tuple *mem_stmt)
+		      struct tuple *mem_stmt)
 {
 	int64_t lsn = vy_stmt_lsn(mem_stmt);
 	if (lsn <= lsm->dump_lsn)
@@ -4096,8 +4096,7 @@ vy_build_recover_stmt(struct vy_lsm *lsm, struct vy_lsm *pk,
 	const struct vy_read_view rv = { .vlsn = lsn - 1 };
 	const struct vy_read_view *p_rv = &rv;
 	struct tuple *old_tuple;
-	if (vy_point_lookup(pk, NULL, &p_rv, (struct tuple *)mem_stmt,
-			    &old_tuple) != 0)
+	if (vy_point_lookup(pk, NULL, &p_rv, mem_stmt, &old_tuple) != 0)
 		return -1;
 	/*
 	 * Create DELETE + INSERT statements corresponding to
@@ -4166,7 +4165,7 @@ vy_build_recover_mem(struct vy_lsm *lsm, struct vy_lsm *pk, struct vy_mem *mem)
 	struct vy_mem_tree_iterator itr;
 	itr = vy_mem_tree_iterator_last(&mem->tree);
 	while (!vy_mem_tree_iterator_is_invalid(&itr)) {
-		const struct tuple *mem_stmt;
+		struct tuple *mem_stmt;
 		mem_stmt = *vy_mem_tree_iterator_get_elem(&mem->tree, &itr);
 		if (vy_build_recover_stmt(lsm, pk, mem_stmt) != 0)
 			return -1;
@@ -4439,7 +4438,7 @@ vy_deferred_delete_on_replace(struct trigger *trigger, void *event)
 	/* Insert the deferred DELETE into secondary indexes. */
 	int rc = 0;
 	size_t mem_used_before = lsregion_used(&env->mem_env.allocator);
-	const struct tuple *region_stmt = NULL;
+	struct tuple *region_stmt = NULL;
 	for (uint32_t i = 1; i < space->index_count; i++) {
 		struct vy_lsm *lsm = vy_lsm(space->index[i]);
 		if (vy_is_committed_one(env, lsm))
diff --git a/src/box/vy_cache.c b/src/box/vy_cache.c
index e526ab1e..05c02cd1 100644
--- a/src/box/vy_cache.c
+++ b/src/box/vy_cache.c
@@ -228,7 +228,7 @@ vy_cache_env_set_quota(struct vy_cache_env *env, size_t quota)
 
 void
 vy_cache_add(struct vy_cache *cache, struct tuple *stmt,
-	     struct tuple *prev_stmt, const struct tuple *key,
+	     struct tuple *prev_stmt, struct tuple *key,
 	     enum iterator_type order)
 {
 	if (cache->env->mem_quota == 0) {
@@ -420,7 +420,7 @@ vy_cache_add(struct vy_cache *cache, struct tuple *stmt,
 }
 
 struct tuple *
-vy_cache_get(struct vy_cache *cache, const struct tuple *key)
+vy_cache_get(struct vy_cache *cache, struct tuple *key)
 {
 	struct vy_cache_entry **entry =
 		vy_cache_tree_find(&cache->cache_tree, key);
@@ -430,7 +430,7 @@ vy_cache_get(struct vy_cache *cache, const struct tuple *key)
 }
 
 void
-vy_cache_on_write(struct vy_cache *cache, const struct tuple *stmt,
+vy_cache_on_write(struct vy_cache *cache, struct tuple *stmt,
 		  struct tuple **deleted)
 {
 	vy_cache_gc(cache->env);
@@ -646,8 +646,7 @@ vy_cache_iterator_skip_to_read_view(struct vy_cache_iterator *itr, bool *stop)
  * and hence the caller doesn't need to scan mems and runs.
  */
 static bool
-vy_cache_iterator_seek(struct vy_cache_iterator *itr,
-		       const struct tuple *last_key)
+vy_cache_iterator_seek(struct vy_cache_iterator *itr, struct tuple *last_key)
 {
 	struct vy_cache_tree *tree = &itr->cache->cache_tree;
 
@@ -657,7 +656,7 @@ vy_cache_iterator_seek(struct vy_cache_iterator *itr,
 	}
 	itr->cache->stat.lookup++;
 
-	const struct tuple *key = itr->key;
+	struct tuple *key = itr->key;
 	enum iterator_type iterator_type = itr->iterator_type;
 	if (last_key != NULL) {
 		key = last_key;
@@ -726,8 +725,7 @@ vy_cache_iterator_next(struct vy_cache_iterator *itr,
 }
 
 NODISCARD int
-vy_cache_iterator_skip(struct vy_cache_iterator *itr,
-		       const struct tuple *last_stmt,
+vy_cache_iterator_skip(struct vy_cache_iterator *itr, struct tuple *last_stmt,
 		       struct vy_history *history, bool *stop)
 {
 	assert(!itr->search_started || itr->version == itr->cache->version);
@@ -759,8 +757,7 @@ vy_cache_iterator_skip(struct vy_cache_iterator *itr,
 }
 
 NODISCARD int
-vy_cache_iterator_restore(struct vy_cache_iterator *itr,
-			  const struct tuple *last_stmt,
+vy_cache_iterator_restore(struct vy_cache_iterator *itr, struct tuple *last_stmt,
 			  struct vy_history *history, bool *stop)
 {
 	if (!itr->search_started || itr->version == itr->cache->version)
@@ -787,7 +784,7 @@ vy_cache_iterator_restore(struct vy_cache_iterator *itr,
 		 * statement closiest to last_stmt.
 		 */
 		bool key_belongs = false;
-		const struct tuple *key = last_stmt;
+		struct tuple *key = last_stmt;
 		if (key == NULL) {
 			key = itr->key;
 			key_belongs = (itr->iterator_type == ITER_EQ ||
@@ -850,8 +847,8 @@ vy_cache_iterator_close(struct vy_cache_iterator *itr)
 
 void
 vy_cache_iterator_open(struct vy_cache_iterator *itr, struct vy_cache *cache,
-		       enum iterator_type iterator_type,
-		       const struct tuple *key, const struct vy_read_view **rv)
+		       enum iterator_type iterator_type, struct tuple *key,
+		       const struct vy_read_view **rv)
 {
 	itr->cache = cache;
 	itr->iterator_type = iterator_type;
diff --git a/src/box/vy_cache.h b/src/box/vy_cache.h
index a846622e..7eba6284 100644
--- a/src/box/vy_cache.h
+++ b/src/box/vy_cache.h
@@ -81,8 +81,8 @@ vy_cache_tree_cmp(struct vy_cache_entry *a,
  * Internal comparator (2) for BPS tree.
  */
 static inline int
-vy_cache_tree_key_cmp(struct vy_cache_entry *a,
-		      const struct tuple *b, struct key_def *cmp_def)
+vy_cache_tree_key_cmp(struct vy_cache_entry *a, struct tuple *b,
+		      struct key_def *cmp_def)
 {
 	return vy_stmt_compare(a->stmt, b, cmp_def);
 }
@@ -95,7 +95,7 @@ vy_cache_tree_key_cmp(struct vy_cache_entry *a,
 #define BPS_TREE_COMPARE(a, b, cmp_def) vy_cache_tree_cmp(a, b, cmp_def)
 #define BPS_TREE_COMPARE_KEY(a, b, cmp_def) vy_cache_tree_key_cmp(a, b, cmp_def)
 #define bps_tree_elem_t struct vy_cache_entry *
-#define bps_tree_key_t const struct tuple *
+#define bps_tree_key_t struct tuple *
 #define bps_tree_arg_t struct key_def *
 #define BPS_TREE_NO_DEBUG
 
@@ -202,7 +202,7 @@ vy_cache_destroy(struct vy_cache *cache);
  */
 void
 vy_cache_add(struct vy_cache *cache, struct tuple *stmt,
-	     struct tuple *prev_stmt, const struct tuple *key,
+	     struct tuple *prev_stmt, struct tuple *key,
 	     enum iterator_type order);
 
 /**
@@ -210,7 +210,7 @@ vy_cache_add(struct vy_cache *cache, struct tuple *stmt,
  * @return A tuple equal to key or NULL if not found.
  */
 struct tuple *
-vy_cache_get(struct vy_cache *cache, const struct tuple *key);
+vy_cache_get(struct vy_cache *cache, struct tuple *key);
 
 /**
  * Invalidate possibly cached value due to its overwriting
@@ -220,7 +220,7 @@ vy_cache_get(struct vy_cache *cache, const struct tuple *key);
  *             statement.
  */
 void
-vy_cache_on_write(struct vy_cache *cache, const struct tuple *stmt,
+vy_cache_on_write(struct vy_cache *cache, struct tuple *stmt,
 		  struct tuple **deleted);
 
 
@@ -238,7 +238,7 @@ struct vy_cache_iterator {
 	 */
 	enum iterator_type iterator_type;
 	/* Search key data in terms of vinyl, vy_stmt_compare argument */
-	const struct tuple *key;
+	struct tuple *key;
 	/* LSN visibility, iterator shows values with lsn <= vlsn */
 	const struct vy_read_view **read_view;
 
@@ -264,8 +264,8 @@ struct vy_cache_iterator {
  */
 void
 vy_cache_iterator_open(struct vy_cache_iterator *itr, struct vy_cache *cache,
-		       enum iterator_type iterator_type,
-		       const struct tuple *key, const struct vy_read_view **rv);
+		       enum iterator_type iterator_type, struct tuple *key,
+		       const struct vy_read_view **rv);
 
 /**
  * Advance a cache iterator to the next key.
@@ -285,8 +285,7 @@ vy_cache_iterator_next(struct vy_cache_iterator *itr,
  * Returns 0 on success, -1 on memory allocation error.
  */
 NODISCARD int
-vy_cache_iterator_skip(struct vy_cache_iterator *itr,
-		       const struct tuple *last_stmt,
+vy_cache_iterator_skip(struct vy_cache_iterator *itr, struct tuple *last_stmt,
 		       struct vy_history *history, bool *stop);
 
 /**
@@ -296,8 +295,7 @@ vy_cache_iterator_skip(struct vy_cache_iterator *itr,
  * allocation error.
  */
 NODISCARD int
-vy_cache_iterator_restore(struct vy_cache_iterator *itr,
-			  const struct tuple *last_stmt,
+vy_cache_iterator_restore(struct vy_cache_iterator *itr, struct tuple *last_stmt,
 			  struct vy_history *history, bool *stop);
 
 /**
diff --git a/src/box/vy_lsm.c b/src/box/vy_lsm.c
index 1e08c0e1..07c4a929 100644
--- a/src/box/vy_lsm.c
+++ b/src/box/vy_lsm.c
@@ -873,7 +873,7 @@ vy_lsm_delete_mem(struct vy_lsm *lsm, struct vy_mem *mem)
 
 int
 vy_lsm_set(struct vy_lsm *lsm, struct vy_mem *mem,
-	   const struct tuple *stmt, const struct tuple **region_stmt)
+	   struct tuple *stmt, struct tuple **region_stmt)
 {
 	uint32_t format_id = stmt->format_id;
 
@@ -922,7 +922,7 @@ vy_lsm_set(struct vy_lsm *lsm, struct vy_mem *mem,
  */
 static void
 vy_lsm_commit_upsert(struct vy_lsm *lsm, struct vy_mem *mem,
-		       const struct tuple *stmt)
+		     struct tuple *stmt)
 {
 	assert(vy_stmt_type(stmt) == IPROTO_UPSERT);
 	assert(vy_stmt_lsn(stmt) < MAX_LSN);
@@ -932,7 +932,7 @@ vy_lsm_commit_upsert(struct vy_lsm *lsm, struct vy_mem *mem,
 	 */
 	assert(lsm->index_id == 0);
 
-	const struct tuple *older;
+	struct tuple *older;
 	int64_t lsn = vy_stmt_lsn(stmt);
 	uint8_t n_upserts = vy_stmt_n_upserts(stmt);
 	/*
@@ -1015,7 +1015,7 @@ vy_lsm_commit_upsert(struct vy_lsm *lsm, struct vy_mem *mem,
 		assert(older == NULL || upserted_lsn != vy_stmt_lsn(older));
 		assert(vy_stmt_type(upserted) == IPROTO_REPLACE);
 
-		const struct tuple *region_stmt =
+		struct tuple *region_stmt =
 			vy_stmt_dup_lsregion(upserted, &mem->env->allocator,
 					     mem->generation);
 		if (region_stmt == NULL) {
@@ -1040,7 +1040,7 @@ vy_lsm_commit_upsert(struct vy_lsm *lsm, struct vy_mem *mem,
 
 void
 vy_lsm_commit_stmt(struct vy_lsm *lsm, struct vy_mem *mem,
-		     const struct tuple *stmt)
+		   struct tuple *stmt)
 {
 	vy_mem_commit_stmt(mem, stmt);
 
@@ -1057,7 +1057,7 @@ vy_lsm_commit_stmt(struct vy_lsm *lsm, struct vy_mem *mem,
 
 void
 vy_lsm_rollback_stmt(struct vy_lsm *lsm, struct vy_mem *mem,
-		       const struct tuple *stmt)
+		     struct tuple *stmt)
 {
 	vy_mem_rollback_stmt(mem, stmt);
 
diff --git a/src/box/vy_lsm.h b/src/box/vy_lsm.h
index c85bd2b3..b61a4a52 100644
--- a/src/box/vy_lsm.h
+++ b/src/box/vy_lsm.h
@@ -598,7 +598,7 @@ vy_lsm_force_compaction(struct vy_lsm *lsm);
  */
 int
 vy_lsm_set(struct vy_lsm *lsm, struct vy_mem *mem,
-	   const struct tuple *stmt, const struct tuple **region_stmt);
+	   struct tuple *stmt, struct tuple **region_stmt);
 
 /**
  * Confirm that the statement stays in the in-memory index of
@@ -610,7 +610,7 @@ vy_lsm_set(struct vy_lsm *lsm, struct vy_mem *mem,
  */
 void
 vy_lsm_commit_stmt(struct vy_lsm *lsm, struct vy_mem *mem,
-		   const struct tuple *stmt);
+		   struct tuple *stmt);
 
 /**
  * Erase a statement from the in-memory index of an LSM tree.
@@ -621,7 +621,7 @@ vy_lsm_commit_stmt(struct vy_lsm *lsm, struct vy_mem *mem,
  */
 void
 vy_lsm_rollback_stmt(struct vy_lsm *lsm, struct vy_mem *mem,
-		     const struct tuple *stmt);
+		     struct tuple *stmt);
 
 #if defined(__cplusplus)
 } /* extern "C" */
diff --git a/src/box/vy_mem.c b/src/box/vy_mem.c
index e3b40083..d6d8dce2 100644
--- a/src/box/vy_mem.c
+++ b/src/box/vy_mem.c
@@ -131,8 +131,8 @@ vy_mem_delete(struct vy_mem *index)
 	free(index);
 }
 
-const struct tuple *
-vy_mem_older_lsn(struct vy_mem *mem, const struct tuple *stmt)
+struct tuple *
+vy_mem_older_lsn(struct vy_mem *mem, struct tuple *stmt)
 {
 	struct tree_mem_key tree_key;
 	tree_key.stmt = stmt;
@@ -144,7 +144,7 @@ vy_mem_older_lsn(struct vy_mem *mem, const struct tuple *stmt)
 	if (vy_mem_tree_iterator_is_invalid(&itr))
 		return NULL;
 
-	const struct tuple *result;
+	struct tuple *result;
 	result = *vy_mem_tree_iterator_get_elem(&mem->tree, &itr);
 	if (vy_stmt_compare(result, stmt, mem->cmp_def) != 0)
 		return NULL;
@@ -152,7 +152,7 @@ vy_mem_older_lsn(struct vy_mem *mem, const struct tuple *stmt)
 }
 
 int
-vy_mem_insert_upsert(struct vy_mem *mem, const struct tuple *stmt)
+vy_mem_insert_upsert(struct vy_mem *mem, struct tuple *stmt)
 {
 	assert(vy_stmt_type(stmt) == IPROTO_UPSERT);
 	/* Check if the statement can be inserted in the vy_mem. */
@@ -160,7 +160,7 @@ vy_mem_insert_upsert(struct vy_mem *mem, const struct tuple *stmt)
 	/* The statement must be from a lsregion. */
 	assert(!vy_stmt_is_refable(stmt));
 	size_t size = tuple_size(stmt);
-	const struct tuple *replaced_stmt = NULL;
+	struct tuple *replaced_stmt = NULL;
 	struct vy_mem_tree_iterator inserted;
 	if (vy_mem_tree_insert_get_iterator(&mem->tree, stmt, &replaced_stmt,
 					    &inserted) != 0)
@@ -192,8 +192,8 @@ vy_mem_insert_upsert(struct vy_mem *mem, const struct tuple *stmt)
 	 * UPSERTs subsequence.
 	 */
 	vy_mem_tree_iterator_next(&mem->tree, &inserted);
-	const struct tuple **older = vy_mem_tree_iterator_get_elem(&mem->tree,
-								   &inserted);
+	struct tuple **older = vy_mem_tree_iterator_get_elem(&mem->tree,
+							     &inserted);
 	if (older == NULL || vy_stmt_type(*older) != IPROTO_UPSERT ||
 	    vy_stmt_compare(stmt, *older, mem->cmp_def) != 0)
 		return 0;
@@ -206,12 +206,12 @@ vy_mem_insert_upsert(struct vy_mem *mem, const struct tuple *stmt)
 		n_upserts++;
 	else
 		assert(n_upserts == VY_UPSERT_INF);
-	vy_stmt_set_n_upserts((struct tuple *)stmt, n_upserts);
+	vy_stmt_set_n_upserts(stmt, n_upserts);
 	return 0;
 }
 
 int
-vy_mem_insert(struct vy_mem *mem, const struct tuple *stmt)
+vy_mem_insert(struct vy_mem *mem, struct tuple *stmt)
 {
 	assert(vy_stmt_type(stmt) != IPROTO_UPSERT);
 	/* Check if the statement can be inserted in the vy_mem. */
@@ -220,7 +220,7 @@ vy_mem_insert(struct vy_mem *mem, const struct tuple *stmt)
 	/* The statement must be from a lsregion. */
 	assert(!vy_stmt_is_refable(stmt));
 	size_t size = tuple_size(stmt);
-	const struct tuple *replaced_stmt = NULL;
+	struct tuple *replaced_stmt = NULL;
 	if (vy_mem_tree_insert(&mem->tree, stmt, &replaced_stmt))
 		return -1;
 	if (replaced_stmt == NULL)
@@ -235,7 +235,7 @@ vy_mem_insert(struct vy_mem *mem, const struct tuple *stmt)
 }
 
 void
-vy_mem_commit_stmt(struct vy_mem *mem, const struct tuple *stmt)
+vy_mem_commit_stmt(struct vy_mem *mem, struct tuple *stmt)
 {
 	/* The statement must be from a lsregion. */
 	assert(!vy_stmt_is_refable(stmt));
@@ -257,7 +257,7 @@ vy_mem_commit_stmt(struct vy_mem *mem, const struct tuple *stmt)
 }
 
 void
-vy_mem_rollback_stmt(struct vy_mem *mem, const struct tuple *stmt)
+vy_mem_rollback_stmt(struct vy_mem *mem, struct tuple *stmt)
 {
 	/* This is the statement we've inserted before. */
 	assert(!vy_stmt_is_refable(stmt));
@@ -276,7 +276,7 @@ vy_mem_rollback_stmt(struct vy_mem *mem, const struct tuple *stmt)
 /**
  * Get a stmt by current position
  */
-static const struct tuple *
+static struct tuple *
 vy_mem_iterator_curr_stmt(struct vy_mem_iterator *itr)
 {
 	return *vy_mem_tree_iterator_get_elem(&itr->mem->tree, &itr->curr_pos);
@@ -337,7 +337,7 @@ vy_mem_iterator_find_lsn(struct vy_mem_iterator *itr)
 		/* No more statements. */
 		return 0;
 	}
-	const struct tuple *prev_stmt;
+	struct tuple *prev_stmt;
 	prev_stmt = *vy_mem_tree_iterator_get_elem(&itr->mem->tree, &prev_pos);
 	if (vy_stmt_lsn(prev_stmt) > (**itr->read_view).vlsn ||
 	    vy_stmt_compare(itr->curr_stmt, prev_stmt, cmp_def) != 0) {
@@ -382,14 +382,14 @@ vy_mem_iterator_find_lsn(struct vy_mem_iterator *itr)
  * @retval 1 Not found
  */
 static int
-vy_mem_iterator_seek(struct vy_mem_iterator *itr, const struct tuple *last_key)
+vy_mem_iterator_seek(struct vy_mem_iterator *itr, struct tuple *last_key)
 {
 	itr->stat->lookup++;
 	itr->search_started = true;
 	itr->version = itr->mem->version;
 	itr->curr_stmt = NULL;
 
-	const struct tuple *key = itr->key;
+	struct tuple *key = itr->key;
 	enum iterator_type iterator_type = itr->iterator_type;
 	if (last_key != NULL) {
 		key = last_key;
@@ -444,7 +444,7 @@ vy_mem_iterator_seek(struct vy_mem_iterator *itr, const struct tuple *last_key)
 void
 vy_mem_iterator_open(struct vy_mem_iterator *itr, struct vy_mem_iterator_stat *stat,
 		     struct vy_mem *mem, enum iterator_type iterator_type,
-		     const struct tuple *key, const struct vy_read_view **rv)
+		     struct tuple *key, const struct vy_read_view **rv)
 {
 	itr->stat = stat;
 
@@ -478,7 +478,7 @@ vy_mem_iterator_next_key(struct vy_mem_iterator *itr)
 	assert(itr->curr_stmt == vy_mem_iterator_curr_stmt(itr));
 	struct key_def *cmp_def = itr->mem->cmp_def;
 
-	const struct tuple *prev_stmt = itr->curr_stmt;
+	struct tuple *prev_stmt = itr->curr_stmt;
 	if (vy_mem_iterator_step(itr) != 0) {
 		itr->curr_stmt = NULL;
 		return 1;
@@ -522,7 +522,7 @@ next:
 	if (vy_mem_tree_iterator_is_invalid(&next_pos))
 		return 1; /* EOF */
 
-	const struct tuple *next_stmt;
+	struct tuple *next_stmt;
 	next_stmt = *vy_mem_tree_iterator_get_elem(&itr->mem->tree, &next_pos);
 	if (vy_stmt_compare(itr->curr_stmt, next_stmt, cmp_def) != 0)
 		return 1;
@@ -544,7 +544,7 @@ vy_mem_iterator_get_history(struct vy_mem_iterator *itr,
 			    struct vy_history *history)
 {
 	do {
-		struct tuple *stmt = (struct tuple *)itr->curr_stmt;
+		struct tuple *stmt = itr->curr_stmt;
 		vy_stmt_counter_acct_tuple(&itr->stat->get, stmt);
 		if (vy_history_append_stmt(history, stmt) != 0)
 			return -1;
@@ -565,8 +565,7 @@ vy_mem_iterator_next(struct vy_mem_iterator *itr,
 }
 
 NODISCARD int
-vy_mem_iterator_skip(struct vy_mem_iterator *itr,
-		     const struct tuple *last_stmt,
+vy_mem_iterator_skip(struct vy_mem_iterator *itr, struct tuple *last_stmt,
 		     struct vy_history *history)
 {
 	assert(!itr->search_started || itr->version == itr->mem->version);
@@ -588,8 +587,7 @@ vy_mem_iterator_skip(struct vy_mem_iterator *itr,
 }
 
 NODISCARD int
-vy_mem_iterator_restore(struct vy_mem_iterator *itr,
-			const struct tuple *last_stmt,
+vy_mem_iterator_restore(struct vy_mem_iterator *itr, struct tuple *last_stmt,
 			struct vy_history *history)
 {
 	if (!itr->search_started || itr->version == itr->mem->version)
diff --git a/src/box/vy_mem.h b/src/box/vy_mem.h
index 39f238b3..a68b8dc9 100644
--- a/src/box/vy_mem.h
+++ b/src/box/vy_mem.h
@@ -79,7 +79,7 @@ vy_mem_env_destroy(struct vy_mem_env *env);
 /** @cond false */
 
 struct tree_mem_key {
-	const struct tuple *stmt;
+	struct tuple *stmt;
 	int64_t lsn;
 };
 
@@ -87,7 +87,7 @@ struct tree_mem_key {
  * Internal. Extracted to speed up BPS tree.
  */
 static int
-vy_mem_tree_cmp(const struct tuple *a, const struct tuple *b,
+vy_mem_tree_cmp(struct tuple *a, struct tuple *b,
 		struct key_def *cmp_def)
 {
 	int res = vy_stmt_compare(a, b, cmp_def);
@@ -101,7 +101,7 @@ vy_mem_tree_cmp(const struct tuple *a, const struct tuple *b,
  * Internal. Extracted to speed up BPS tree.
  */
 static int
-vy_mem_tree_cmp_key(const struct tuple *a, struct tree_mem_key *key,
+vy_mem_tree_cmp_key(struct tuple *a, struct tree_mem_key *key,
 		    struct key_def *cmp_def)
 {
 	int res = vy_stmt_compare(a, key->stmt, cmp_def);
@@ -121,7 +121,7 @@ vy_mem_tree_cmp_key(const struct tuple *a, struct tree_mem_key *key,
 #define BPS_TREE_EXTENT_SIZE VY_MEM_TREE_EXTENT_SIZE
 #define BPS_TREE_COMPARE(a, b, cmp_def) vy_mem_tree_cmp(a, b, cmp_def)
 #define BPS_TREE_COMPARE_KEY(a, b, cmp_def) vy_mem_tree_cmp_key(a, b, cmp_def)
-#define bps_tree_elem_t const struct tuple *
+#define bps_tree_elem_t struct tuple *
 #define bps_tree_key_t struct tree_mem_key *
 #define bps_tree_arg_t struct key_def *
 #define BPS_TREE_NO_DEBUG
@@ -275,8 +275,8 @@ vy_mem_delete(struct vy_mem *index);
 /*
  * Return the older statement for the given one.
  */
-const struct tuple *
-vy_mem_older_lsn(struct vy_mem *mem, const struct tuple *stmt);
+struct tuple *
+vy_mem_older_lsn(struct vy_mem *mem, struct tuple *stmt);
 
 /**
  * Insert a statement into the in-memory level.
@@ -287,7 +287,7 @@ vy_mem_older_lsn(struct vy_mem *mem, const struct tuple *stmt);
  * @retval -1 Memory error.
  */
 int
-vy_mem_insert(struct vy_mem *mem, const struct tuple *stmt);
+vy_mem_insert(struct vy_mem *mem, struct tuple *stmt);
 
 /**
  * Insert an upsert statement into the mem.
@@ -299,7 +299,7 @@ vy_mem_insert(struct vy_mem *mem, const struct tuple *stmt);
  * @retval -1 Memory error.
  */
 int
-vy_mem_insert_upsert(struct vy_mem *mem, const struct tuple *stmt);
+vy_mem_insert_upsert(struct vy_mem *mem, struct tuple *stmt);
 
 /**
  * Confirm insertion of a statement into the in-memory level.
@@ -307,7 +307,7 @@ vy_mem_insert_upsert(struct vy_mem *mem, const struct tuple *stmt);
  * @param stmt       Vinyl statement.
  */
 void
-vy_mem_commit_stmt(struct vy_mem *mem, const struct tuple *stmt);
+vy_mem_commit_stmt(struct vy_mem *mem, struct tuple *stmt);
 
 /**
  * Remove a statement from the in-memory level.
@@ -315,7 +315,7 @@ vy_mem_commit_stmt(struct vy_mem *mem, const struct tuple *stmt);
  * @param stmt       Vinyl statement.
  */
 void
-vy_mem_rollback_stmt(struct vy_mem *mem, const struct tuple *stmt);
+vy_mem_rollback_stmt(struct vy_mem *mem, struct tuple *stmt);
 
 /**
  * Iterator for in-memory level.
@@ -345,7 +345,7 @@ struct vy_mem_iterator {
 	 */
 	enum iterator_type iterator_type;
 	/** Key to search. */
-	const struct tuple *key;
+	struct tuple *key;
 	/* LSN visibility, iterator shows values with lsn <= than that */
 	const struct vy_read_view **read_view;
 
@@ -358,7 +358,7 @@ struct vy_mem_iterator {
 	 * For example, cur_pos can be invalid but curr_stmt can point on a
 	 * valid statement.
 	 */
-	const struct tuple *curr_stmt;
+	struct tuple *curr_stmt;
 	/* data version from vy_mem */
 	uint32_t version;
 
@@ -372,7 +372,7 @@ struct vy_mem_iterator {
 void
 vy_mem_iterator_open(struct vy_mem_iterator *itr, struct vy_mem_iterator_stat *stat,
 		     struct vy_mem *mem, enum iterator_type iterator_type,
-		     const struct tuple *key, const struct vy_read_view **rv);
+		     struct tuple *key, const struct vy_read_view **rv);
 
 /**
  * Advance a mem iterator to the next key.
@@ -390,7 +390,7 @@ vy_mem_iterator_next(struct vy_mem_iterator *itr,
  */
 NODISCARD int
 vy_mem_iterator_skip(struct vy_mem_iterator *itr,
-		     const struct tuple *last_stmt,
+		     struct tuple *last_stmt,
 		     struct vy_history *history);
 
 /**
@@ -401,7 +401,7 @@ vy_mem_iterator_skip(struct vy_mem_iterator *itr,
  */
 NODISCARD int
 vy_mem_iterator_restore(struct vy_mem_iterator *itr,
-			const struct tuple *last_stmt,
+			struct tuple *last_stmt,
 			struct vy_history *history);
 
 /**
diff --git a/src/box/vy_range.c b/src/box/vy_range.c
index f76615c4..12573436 100644
--- a/src/box/vy_range.c
+++ b/src/box/vy_range.c
@@ -68,7 +68,7 @@ vy_range_tree_cmp(struct vy_range *range_a, struct vy_range *range_b)
 }
 
 int
-vy_range_tree_key_cmp(const struct tuple *stmt, struct vy_range *range)
+vy_range_tree_key_cmp(struct tuple *stmt, struct vy_range *range)
 {
 	/* Any key > -inf. */
 	if (range->begin == NULL)
@@ -79,7 +79,7 @@ vy_range_tree_key_cmp(const struct tuple *stmt, struct vy_range *range)
 struct vy_range *
 vy_range_tree_find_by_key(vy_range_tree_t *tree,
 			  enum iterator_type iterator_type,
-			  const struct tuple *key)
+			  struct tuple *key)
 {
 	if (vy_stmt_is_empty_key(key)) {
 		switch (iterator_type) {
diff --git a/src/box/vy_range.h b/src/box/vy_range.h
index 91f2682c..0f1a50fc 100644
--- a/src/box/vy_range.h
+++ b/src/box/vy_range.h
@@ -167,12 +167,12 @@ vy_range_is_scheduled(struct vy_range *range)
 int
 vy_range_tree_cmp(struct vy_range *range_a, struct vy_range *range_b);
 int
-vy_range_tree_key_cmp(const struct tuple *stmt, struct vy_range *range);
+vy_range_tree_key_cmp(struct tuple *stmt, struct vy_range *range);
 
 typedef rb_tree(struct vy_range) vy_range_tree_t;
 rb_gen_ext_key(MAYBE_UNUSED static inline, vy_range_tree_, vy_range_tree_t,
 	       struct vy_range, tree_node, vy_range_tree_cmp,
-	       const struct tuple *, vy_range_tree_key_cmp);
+	       struct tuple *, vy_range_tree_key_cmp);
 
 /**
  * Find the first range in which a given key should be looked up.
@@ -186,7 +186,7 @@ rb_gen_ext_key(MAYBE_UNUSED static inline, vy_range_tree_, vy_range_tree_t,
 struct vy_range *
 vy_range_tree_find_by_key(vy_range_tree_t *tree,
 			  enum iterator_type iterator_type,
-			  const struct tuple *key);
+			  struct tuple *key);
 
 /**
  * Allocate and initialize a range (either a new one or for
diff --git a/src/box/vy_read_iterator.c b/src/box/vy_read_iterator.c
index b5012748..4e4a3243 100644
--- a/src/box/vy_read_iterator.c
+++ b/src/box/vy_read_iterator.c
@@ -176,7 +176,7 @@ vy_read_iterator_range_is_done(struct vy_read_iterator *itr,
  */
 static inline int
 vy_read_iterator_cmp_stmt(struct vy_read_iterator *itr,
-			  const struct tuple *a, const struct tuple *b)
+			  struct tuple *a, struct tuple *b)
 {
 	if (a == NULL && b != NULL)
 		return 1;
diff --git a/src/box/vy_read_set.h b/src/box/vy_read_set.h
index 1b139ccf..b297a477 100644
--- a/src/box/vy_read_set.h
+++ b/src/box/vy_read_set.h
@@ -187,7 +187,7 @@ rb_gen_aug(MAYBE_UNUSED static inline, vy_lsm_read_set_, vy_lsm_read_set_t,
  */
 struct vy_tx_conflict_iterator {
 	/** The statement. */
-	const struct tuple *stmt;
+	struct tuple *stmt;
 	/**
 	 * Iterator over the interval tree checked
 	 * for intersections with the statement.
@@ -203,7 +203,7 @@ struct vy_tx_conflict_iterator {
 static inline void
 vy_tx_conflict_iterator_init(struct vy_tx_conflict_iterator *it,
 			     vy_lsm_read_set_t *read_set,
-			     const struct tuple *stmt)
+			     struct tuple *stmt)
 {
 	vy_lsm_read_set_walk_init(&it->tree_walk, read_set);
 	it->tree_dir = 0;
diff --git a/src/box/vy_run.c b/src/box/vy_run.c
index 818d0cf3..c0e63700 100644
--- a/src/box/vy_run.c
+++ b/src/box/vy_run.c
@@ -297,7 +297,7 @@ vy_run_bloom_size(struct vy_run *run)
  *  there no pages fulfilling the conditions.
  */
 static uint32_t
-vy_page_index_find_page(struct vy_run *run, const struct tuple *key,
+vy_page_index_find_page(struct vy_run *run, struct tuple *key,
 			struct key_def *cmp_def, enum iterator_type itype,
 			bool *equal_key)
 {
@@ -1037,7 +1037,7 @@ vy_run_iterator_read(struct vy_run_iterator *itr,
 static uint32_t
 vy_run_iterator_search_in_page(struct vy_run_iterator *itr,
 			       enum iterator_type iterator_type,
-			       const struct tuple *key,
+			       struct tuple *key,
 			       struct vy_page *page, bool *equal_key)
 {
 	uint32_t beg = 0;
@@ -1075,8 +1075,7 @@ vy_run_iterator_search_in_page(struct vy_run_iterator *itr,
  */
 static NODISCARD int
 vy_run_iterator_search(struct vy_run_iterator *itr,
-		       enum iterator_type iterator_type,
-		       const struct tuple *key,
+		       enum iterator_type iterator_type, struct tuple *key,
 		       struct vy_run_iterator_pos *pos, bool *equal_key)
 {
 	pos->page_no = vy_page_index_find_page(itr->slice->run, key,
@@ -1242,8 +1241,7 @@ vy_run_iterator_find_lsn(struct vy_run_iterator *itr, struct tuple **ret)
  */
 static NODISCARD int
 vy_run_iterator_do_seek(struct vy_run_iterator *itr,
-			enum iterator_type iterator_type,
-			const struct tuple *key)
+			enum iterator_type iterator_type, struct tuple *key)
 {
 	struct vy_run *run = itr->slice->run;
 	struct vy_run_iterator_pos end_pos = {run->info.page_count, 0};
@@ -1295,13 +1293,13 @@ vy_run_iterator_do_seek(struct vy_run_iterator *itr,
  * (pass NULL to start iteration).
  */
 static NODISCARD int
-vy_run_iterator_seek(struct vy_run_iterator *itr, const struct tuple *last_key,
+vy_run_iterator_seek(struct vy_run_iterator *itr, struct tuple *last_key,
 		     struct tuple **ret)
 {
 	struct key_def *cmp_def = itr->cmp_def;
 	struct vy_slice *slice = itr->slice;
 	struct tuple_bloom *bloom = slice->run->info.bloom;
-	const struct tuple *key = itr->key;
+	struct tuple *key = itr->key;
 	enum iterator_type iterator_type = itr->iterator_type;
 
 	*ret = NULL;
@@ -1424,7 +1422,7 @@ void
 vy_run_iterator_open(struct vy_run_iterator *itr,
 		     struct vy_run_iterator_stat *stat,
 		     struct vy_slice *slice, enum iterator_type iterator_type,
-		     const struct tuple *key, const struct vy_read_view **rv,
+		     struct tuple *key, const struct vy_read_view **rv,
 		     struct key_def *cmp_def, struct key_def *key_def,
 		     struct tuple_format *format)
 {
@@ -1560,8 +1558,7 @@ vy_run_iterator_next(struct vy_run_iterator *itr,
 }
 
 NODISCARD int
-vy_run_iterator_skip(struct vy_run_iterator *itr,
-		     const struct tuple *last_stmt,
+vy_run_iterator_skip(struct vy_run_iterator *itr, struct tuple *last_stmt,
 		     struct vy_history *history)
 {
 	/*
@@ -1744,7 +1741,7 @@ fail:
 
 /* dump statement to the run page buffers (stmt header and data) */
 static int
-vy_run_dump_stmt(const struct tuple *value, struct xlog *data_xlog,
+vy_run_dump_stmt(struct tuple *value, struct xlog *data_xlog,
 		 struct vy_page_info *info, struct key_def *key_def,
 		 bool is_primary)
 {
@@ -2130,8 +2127,7 @@ vy_run_writer_create_xlog(struct vy_run_writer *writer)
  * @retval  0 Success.
  */
 static int
-vy_run_writer_start_page(struct vy_run_writer *writer,
-			 const struct tuple *first_stmt)
+vy_run_writer_start_page(struct vy_run_writer *writer, struct tuple *first_stmt)
 {
 	struct vy_run *run = writer->run;
 	if (run->info.page_count >= writer->page_info_capacity &&
diff --git a/src/box/vy_run.h b/src/box/vy_run.h
index cbc51c50..ae007478 100644
--- a/src/box/vy_run.h
+++ b/src/box/vy_run.h
@@ -259,7 +259,7 @@ struct vy_run_iterator {
 	 */
 	enum iterator_type iterator_type;
 	/** Key to search. */
-	const struct tuple *key;
+	struct tuple *key;
 	/* LSN visibility, iterator shows values with lsn <= vlsn */
 	const struct vy_read_view **read_view;
 
@@ -517,7 +517,7 @@ void
 vy_run_iterator_open(struct vy_run_iterator *itr,
 		     struct vy_run_iterator_stat *stat,
 		     struct vy_slice *slice, enum iterator_type iterator_type,
-		     const struct tuple *key, const struct vy_read_view **rv,
+		     struct tuple *key, const struct vy_read_view **rv,
 		     struct key_def *cmp_def, struct key_def *key_def,
 		     struct tuple_format *format);
 
@@ -536,8 +536,7 @@ vy_run_iterator_next(struct vy_run_iterator *itr,
  * Returns 0 on success, -1 on memory allocation or IO error.
  */
 NODISCARD int
-vy_run_iterator_skip(struct vy_run_iterator *itr,
-		     const struct tuple *last_stmt,
+vy_run_iterator_skip(struct vy_run_iterator *itr, struct tuple *last_stmt,
 		     struct vy_history *history);
 
 /**
diff --git a/src/box/vy_stat.h b/src/box/vy_stat.h
index 3afdbb7f..b7f50d93 100644
--- a/src/box/vy_stat.h
+++ b/src/box/vy_stat.h
@@ -265,16 +265,14 @@ vy_disk_stmt_counter_reset(struct vy_disk_stmt_counter *c)
 }
 
 static inline void
-vy_stmt_counter_acct_tuple(struct vy_stmt_counter *c,
-			   const struct tuple *tuple)
+vy_stmt_counter_acct_tuple(struct vy_stmt_counter *c, struct tuple *tuple)
 {
 	c->rows++;
 	c->bytes += tuple_size(tuple);
 }
 
 static inline void
-vy_stmt_counter_unacct_tuple(struct vy_stmt_counter *c,
-			     const struct tuple *tuple)
+vy_stmt_counter_unacct_tuple(struct vy_stmt_counter *c, struct tuple *tuple)
 {
 	c->rows--;
 	c->bytes -= tuple_size(tuple);
diff --git a/src/box/vy_stmt.c b/src/box/vy_stmt.c
index add86622..7387d72b 100644
--- a/src/box/vy_stmt.c
+++ b/src/box/vy_stmt.c
@@ -59,7 +59,7 @@ enum vy_stmt_meta_key {
  * is written to disk.
  */
 static inline uint8_t
-vy_stmt_persistent_flags(const struct tuple *stmt, bool is_primary)
+vy_stmt_persistent_flags(struct tuple *stmt, bool is_primary)
 {
 	uint8_t mask = VY_STMT_FLAGS_ALL;
 
@@ -184,7 +184,7 @@ vy_stmt_alloc(struct tuple_format *format, uint32_t bsize)
 }
 
 struct tuple *
-vy_stmt_dup(const struct tuple *stmt)
+vy_stmt_dup(struct tuple *stmt)
 {
 	/*
 	 * We don't use tuple_new() to avoid the initializing of
@@ -202,7 +202,7 @@ vy_stmt_dup(const struct tuple *stmt)
 }
 
 struct tuple *
-vy_stmt_dup_lsregion(const struct tuple *stmt, struct lsregion *lsregion,
+vy_stmt_dup_lsregion(struct tuple *stmt, struct lsregion *lsregion,
 		     int64_t alloc_id)
 {
 	enum iproto_type type = vy_stmt_type(stmt);
@@ -378,7 +378,7 @@ vy_stmt_new_delete(struct tuple_format *format, const char *tuple_begin,
 }
 
 struct tuple *
-vy_stmt_replace_from_upsert(const struct tuple *upsert)
+vy_stmt_replace_from_upsert(struct tuple *upsert)
 {
 	assert(vy_stmt_type(upsert) == IPROTO_UPSERT);
 	/* Get statement size without UPSERT operations */
@@ -523,7 +523,7 @@ out:
 }
 
 struct tuple *
-vy_stmt_extract_key(const struct tuple *stmt, struct key_def *key_def,
+vy_stmt_extract_key(struct tuple *stmt, struct key_def *key_def,
 		    struct tuple_format *format)
 {
 	struct region *region = &fiber()->gc;
@@ -560,7 +560,7 @@ vy_stmt_extract_key_raw(const char *data, const char *data_end,
 
 int
 vy_stmt_bloom_builder_add(struct tuple_bloom_builder *builder,
-			  const struct tuple *stmt, struct key_def *key_def)
+			  struct tuple *stmt, struct key_def *key_def)
 {
 	if (vy_stmt_is_key(stmt)) {
 		const char *data = tuple_data(stmt);
@@ -574,7 +574,7 @@ vy_stmt_bloom_builder_add(struct tuple_bloom_builder *builder,
 
 bool
 vy_stmt_bloom_maybe_has(const struct tuple_bloom *bloom,
-			const struct tuple *stmt, struct key_def *key_def)
+			struct tuple *stmt, struct key_def *key_def)
 {
 	if (vy_stmt_is_key(stmt)) {
 		const char *data = tuple_data(stmt);
@@ -591,7 +591,7 @@ vy_stmt_bloom_maybe_has(const struct tuple_bloom *bloom,
  * Returns 0 on success, -1 on memory allocation error.
  */
 static int
-vy_stmt_meta_encode(const struct tuple *stmt, struct request *request,
+vy_stmt_meta_encode(struct tuple *stmt, struct request *request,
 		    bool is_primary)
 {
 	uint8_t flags = vy_stmt_persistent_flags(stmt, is_primary);
@@ -639,7 +639,7 @@ vy_stmt_meta_decode(struct request *request, struct tuple *stmt)
 }
 
 int
-vy_stmt_encode_primary(const struct tuple *value, struct key_def *key_def,
+vy_stmt_encode_primary(struct tuple *value, struct key_def *key_def,
 		       uint32_t space_id, struct xrow_header *xrow)
 {
 	memset(xrow, 0, sizeof(*xrow));
@@ -687,7 +687,7 @@ vy_stmt_encode_primary(const struct tuple *value, struct key_def *key_def,
 }
 
 int
-vy_stmt_encode_secondary(const struct tuple *value, struct key_def *cmp_def,
+vy_stmt_encode_secondary(struct tuple *value, struct key_def *cmp_def,
 			 struct xrow_header *xrow)
 {
 	memset(xrow, 0, sizeof(*xrow));
@@ -769,7 +769,7 @@ vy_stmt_decode(struct xrow_header *xrow, struct tuple_format *format)
 }
 
 int
-vy_stmt_snprint(char *buf, int size, const struct tuple *stmt)
+vy_stmt_snprint(char *buf, int size, struct tuple *stmt)
 {
 	int total = 0;
 	uint32_t mp_size;
@@ -795,7 +795,7 @@ vy_stmt_snprint(char *buf, int size, const struct tuple *stmt)
 }
 
 const char *
-vy_stmt_str(const struct tuple *stmt)
+vy_stmt_str(struct tuple *stmt)
 {
 	char *buf = tt_static_buf();
 	if (vy_stmt_snprint(buf, TT_STATIC_BUF_LEN, stmt) < 0)
diff --git a/src/box/vy_stmt.h b/src/box/vy_stmt.h
index 2da2593f..6069e093 100644
--- a/src/box/vy_stmt.h
+++ b/src/box/vy_stmt.h
@@ -182,9 +182,9 @@ struct vy_stmt {
 
 /** Get LSN of the vinyl statement. */
 static inline int64_t
-vy_stmt_lsn(const struct tuple *stmt)
+vy_stmt_lsn(struct tuple *stmt)
 {
-	return ((const struct vy_stmt *) stmt)->lsn;
+	return ((struct vy_stmt *) stmt)->lsn;
 }
 
 /** Set LSN of the vinyl statement. */
@@ -196,9 +196,9 @@ vy_stmt_set_lsn(struct tuple *stmt, int64_t lsn)
 
 /** Get type of the vinyl statement. */
 static inline enum iproto_type
-vy_stmt_type(const struct tuple *stmt)
+vy_stmt_type(struct tuple *stmt)
 {
-	return (enum iproto_type)((const struct vy_stmt *) stmt)->type;
+	return (enum iproto_type)((struct vy_stmt *) stmt)->type;
 }
 
 /** Set type of the vinyl statement. */
@@ -210,9 +210,9 @@ vy_stmt_set_type(struct tuple *stmt, enum iproto_type type)
 
 /** Get flags of the vinyl statement. */
 static inline uint8_t
-vy_stmt_flags(const struct tuple *stmt)
+vy_stmt_flags(struct tuple *stmt)
 {
-	return ((const struct vy_stmt *)stmt)->flags;
+	return ((struct vy_stmt *)stmt)->flags;
 }
 
 /** Set flags of the vinyl statement. */
@@ -227,7 +227,7 @@ vy_stmt_set_flags(struct tuple *stmt, uint8_t flags)
  * Only for UPSERT statements allocated on lsregion.
  */
 static inline uint8_t
-vy_stmt_n_upserts(const struct tuple *stmt)
+vy_stmt_n_upserts(struct tuple *stmt)
 {
 	assert(stmt->refs == 0);
 	assert(vy_stmt_type(stmt) == IPROTO_UPSERT);
@@ -256,7 +256,7 @@ vy_stmt_is_key_format(const struct tuple_format *format)
 
 /** Return true if the vinyl statement has key format. */
 static inline bool
-vy_stmt_is_key(const struct tuple *stmt)
+vy_stmt_is_key(struct tuple *stmt)
 {
 	return vy_stmt_is_key_format(tuple_format(stmt));
 }
@@ -269,7 +269,7 @@ vy_stmt_is_key(const struct tuple *stmt)
  * all key parts defined.
  */
 static inline uint32_t
-vy_stmt_key_part_count(const struct tuple *stmt, struct key_def *key_def)
+vy_stmt_key_part_count(struct tuple *stmt, struct key_def *key_def)
 {
 	if (vy_stmt_is_key(stmt)) {
 		uint32_t part_count = tuple_field_count(stmt);
@@ -284,7 +284,7 @@ vy_stmt_key_part_count(const struct tuple *stmt, struct key_def *key_def)
  * key parts, i.e. can be used for an exact match lookup.
  */
 static inline bool
-vy_stmt_is_full_key(const struct tuple *stmt, struct key_def *key_def)
+vy_stmt_is_full_key(struct tuple *stmt, struct key_def *key_def)
 {
 	return vy_stmt_key_part_count(stmt, key_def) == key_def->part_count;
 }
@@ -294,7 +294,7 @@ vy_stmt_is_full_key(const struct tuple *stmt, struct key_def *key_def)
  * (match all) key.
  */
 static inline bool
-vy_stmt_is_empty_key(const struct tuple *stmt)
+vy_stmt_is_empty_key(struct tuple *stmt)
 {
 	return tuple_field_count(stmt) == 0;
 }
@@ -306,7 +306,7 @@ vy_stmt_is_empty_key(const struct tuple *stmt)
  * @return new statement of the same type with the same data.
  */
 struct tuple *
-vy_stmt_dup(const struct tuple *stmt);
+vy_stmt_dup(struct tuple *stmt);
 
 struct lsregion;
 
@@ -320,7 +320,7 @@ struct lsregion;
  * @retval     NULL Memory error.
  */
 struct tuple *
-vy_stmt_dup_lsregion(const struct tuple *stmt, struct lsregion *lsregion,
+vy_stmt_dup_lsregion(struct tuple *stmt, struct lsregion *lsregion,
 		     int64_t alloc_id);
 
 /**
@@ -331,7 +331,7 @@ vy_stmt_dup_lsregion(const struct tuple *stmt, struct lsregion *lsregion,
  * @retval false otherwise
  */
 static inline bool
-vy_stmt_is_refable(const struct tuple *stmt)
+vy_stmt_is_refable(struct tuple *stmt)
 {
 	return stmt->refs > 0;
 }
@@ -367,8 +367,7 @@ vy_stmt_unref_if_possible(struct tuple *stmt)
  * formats (key or tuple).
  */
 static inline int
-vy_stmt_compare(const struct tuple *a, const struct tuple *b,
-		struct key_def *key_def)
+vy_stmt_compare(struct tuple *a, struct tuple *b, struct key_def *key_def)
 {
 	bool a_is_tuple = !vy_stmt_is_key(a);
 	bool b_is_tuple = !vy_stmt_is_key(b);
@@ -393,7 +392,7 @@ vy_stmt_compare(const struct tuple *a, const struct tuple *b,
  * (msgpack array).
  */
 static inline int
-vy_stmt_compare_with_raw_key(const struct tuple *stmt, const char *key,
+vy_stmt_compare_with_raw_key(struct tuple *stmt, const char *key,
 			     struct key_def *key_def)
 {
 	if (!vy_stmt_is_key(stmt)) {
@@ -447,8 +446,7 @@ vy_stmt_new_surrogate_delete_raw(struct tuple_format *format,
 
 /** @copydoc vy_stmt_new_surrogate_delete_raw. */
 static inline struct tuple *
-vy_stmt_new_surrogate_delete(struct tuple_format *format,
-			     const struct tuple *tuple)
+vy_stmt_new_surrogate_delete(struct tuple_format *format, struct tuple *tuple)
 {
 	uint32_t size;
 	const char *data = tuple_data_range(tuple, &size);
@@ -523,7 +521,7 @@ vy_stmt_new_upsert(struct tuple_format *format,
  * @retval     NULL Memory error.
  */
 struct tuple *
-vy_stmt_replace_from_upsert(const struct tuple *upsert);
+vy_stmt_replace_from_upsert(struct tuple *upsert);
 
 /**
  * Extract MessagePack data from the REPLACE/UPSERT statement.
@@ -533,7 +531,7 @@ vy_stmt_replace_from_upsert(const struct tuple *upsert);
  * @return MessagePack array of tuple fields.
  */
 static inline const char *
-vy_upsert_data_range(const struct tuple *tuple, uint32_t *p_size)
+vy_upsert_data_range(struct tuple *tuple, uint32_t *p_size)
 {
 	assert(vy_stmt_type(tuple) == IPROTO_UPSERT);
 	const char *mp = tuple_data(tuple);
@@ -553,7 +551,7 @@ vy_upsert_data_range(const struct tuple *tuple, uint32_t *p_size)
  * @retval Pointer on MessagePack array of update operations.
  */
 static inline const char *
-vy_stmt_upsert_ops(const struct tuple *tuple, uint32_t *mp_size)
+vy_stmt_upsert_ops(struct tuple *tuple, uint32_t *mp_size)
 {
 	assert(vy_stmt_type(tuple) == IPROTO_UPSERT);
 	const char *mp = tuple_data(tuple);
@@ -583,7 +581,7 @@ vy_key_from_msgpack(struct tuple_format *format, const char *key)
  * malloc().
  */
 struct tuple *
-vy_stmt_extract_key(const struct tuple *stmt, struct key_def *key_def,
+vy_stmt_extract_key(struct tuple *stmt, struct key_def *key_def,
 		    struct tuple_format *format);
 
 /**
@@ -602,7 +600,7 @@ vy_stmt_extract_key_raw(const char *data, const char *data_end,
  */
 int
 vy_stmt_bloom_builder_add(struct tuple_bloom_builder *builder,
-			  const struct tuple *stmt, struct key_def *key_def);
+			  struct tuple *stmt, struct key_def *key_def);
 
 /**
  * Check if a statement hash is present in a bloom filter.
@@ -610,7 +608,7 @@ vy_stmt_bloom_builder_add(struct tuple_bloom_builder *builder,
  */
 bool
 vy_stmt_bloom_maybe_has(const struct tuple_bloom *bloom,
-			const struct tuple *stmt, struct key_def *key_def);
+			struct tuple *stmt, struct key_def *key_def);
 
 /**
  * Encode vy_stmt for a primary key as xrow_header
@@ -625,7 +623,7 @@ vy_stmt_bloom_maybe_has(const struct tuple_bloom *bloom,
  * @retval -1 if error
  */
 int
-vy_stmt_encode_primary(const struct tuple *value, struct key_def *key_def,
+vy_stmt_encode_primary(struct tuple *value, struct key_def *key_def,
 		       uint32_t space_id, struct xrow_header *xrow);
 
 /**
@@ -639,7 +637,7 @@ vy_stmt_encode_primary(const struct tuple *value, struct key_def *key_def,
  * @retval -1 if error
  */
 int
-vy_stmt_encode_secondary(const struct tuple *value, struct key_def *cmp_def,
+vy_stmt_encode_secondary(struct tuple *value, struct key_def *cmp_def,
 			 struct xrow_header *xrow);
 
 /**
@@ -656,7 +654,7 @@ vy_stmt_decode(struct xrow_header *xrow, struct tuple_format *format);
  * Example: REPLACE([1, 2, "string"], lsn=48)
  */
 int
-vy_stmt_snprint(char *buf, int size, const struct tuple *stmt);
+vy_stmt_snprint(char *buf, int size, struct tuple *stmt);
 
 /*
  * Format a statement into string using a static buffer.
@@ -664,7 +662,7 @@ vy_stmt_snprint(char *buf, int size, const struct tuple *stmt);
  * \sa vy_stmt_snprint()
  */
 const char *
-vy_stmt_str(const struct tuple *stmt);
+vy_stmt_str(struct tuple *stmt);
 
 #if defined(__cplusplus)
 } /* extern "C" */
diff --git a/src/box/vy_tx.c b/src/box/vy_tx.c
index 05f757d8..8dc56bc9 100644
--- a/src/box/vy_tx.c
+++ b/src/box/vy_tx.c
@@ -491,7 +491,7 @@ vy_tx_write_prepare(struct txv *v)
  */
 static int
 vy_tx_write(struct vy_lsm *lsm, struct vy_mem *mem,
-	    struct tuple *stmt, const struct tuple **region_stmt)
+	    struct tuple *stmt, struct tuple **region_stmt)
 {
 	assert(vy_stmt_is_refable(stmt));
 	assert(*region_stmt == NULL || !vy_stmt_is_refable(*region_stmt));
@@ -681,7 +681,7 @@ vy_tx_prepare(struct vy_tx *tx)
 	 * Sic: the loop below must not yield after recovery.
 	 */
 	/* repsert - REPLACE/UPSERT */
-	const struct tuple *delete = NULL, *repsert = NULL;
+	struct tuple *delete = NULL, *repsert = NULL;
 	MAYBE_UNUSED uint32_t current_space_id = 0;
 	stailq_foreach_entry(v, &tx->log, next_in_log) {
 		struct vy_lsm *lsm = v->lsm;
@@ -765,7 +765,7 @@ vy_tx_prepare(struct vy_tx *tx)
 
 		/* In secondary indexes only REPLACE/DELETE can be written. */
 		vy_stmt_set_lsn(v->stmt, MAX_LSN + tx->psn);
-		const struct tuple **region_stmt =
+		struct tuple **region_stmt =
 			(type == IPROTO_DELETE) ? &delete : &repsert;
 		if (vy_tx_write(lsm, v->mem, v->stmt, region_stmt) != 0)
 			return -1;
@@ -796,7 +796,7 @@ vy_tx_commit(struct vy_tx *tx, int64_t lsn)
 	struct txv *v;
 	stailq_foreach_entry(v, &tx->log, next_in_log) {
 		if (v->region_stmt != NULL) {
-			vy_stmt_set_lsn((struct tuple *)v->region_stmt, lsn);
+			vy_stmt_set_lsn(v->region_stmt, lsn);
 			vy_lsm_commit_stmt(v->lsm, v->mem, v->region_stmt);
 		}
 		if (v->mem != NULL)
@@ -1142,8 +1142,7 @@ void
 vy_txw_iterator_open(struct vy_txw_iterator *itr,
 		     struct vy_txw_iterator_stat *stat,
 		     struct vy_tx *tx, struct vy_lsm *lsm,
-		     enum iterator_type iterator_type,
-		     const struct tuple *key)
+		     enum iterator_type iterator_type, struct tuple *key)
 {
 	itr->stat = stat;
 	itr->tx = tx;
@@ -1161,13 +1160,13 @@ vy_txw_iterator_open(struct vy_txw_iterator *itr,
  * given key (pass NULL to start iteration).
  */
 static void
-vy_txw_iterator_seek(struct vy_txw_iterator *itr, const struct tuple *last_key)
+vy_txw_iterator_seek(struct vy_txw_iterator *itr, struct tuple *last_key)
 {
 	itr->stat->lookup++;
 	itr->version = itr->tx->write_set_version;
 	itr->curr_txv = NULL;
 
-	const struct tuple *key = itr->key;
+	struct tuple *key = itr->key;
 	enum iterator_type iterator_type = itr->iterator_type;
 	if (last_key != NULL) {
 		key = last_key;
@@ -1254,8 +1253,7 @@ out:
 }
 
 NODISCARD int
-vy_txw_iterator_skip(struct vy_txw_iterator *itr,
-		     const struct tuple *last_stmt,
+vy_txw_iterator_skip(struct vy_txw_iterator *itr, struct tuple *last_stmt,
 		     struct vy_history *history)
 {
 	assert(!itr->search_started ||
@@ -1286,8 +1284,7 @@ vy_txw_iterator_skip(struct vy_txw_iterator *itr,
 }
 
 NODISCARD int
-vy_txw_iterator_restore(struct vy_txw_iterator *itr,
-			const struct tuple *last_stmt,
+vy_txw_iterator_restore(struct vy_txw_iterator *itr, struct tuple *last_stmt,
 			struct vy_history *history)
 {
 	if (!itr->search_started || itr->version == itr->tx->write_set_version)
diff --git a/src/box/vy_tx.h b/src/box/vy_tx.h
index 93e3a8cd..39dc306f 100644
--- a/src/box/vy_tx.h
+++ b/src/box/vy_tx.h
@@ -85,7 +85,7 @@ struct txv {
 	/** Statement of this operation. */
 	struct tuple *stmt;
 	/** Statement allocated on vy_mem->allocator. */
-	const struct tuple *region_stmt;
+	struct tuple *region_stmt;
 	/** Mask of columns modified by this operation. */
 	uint64_t column_mask;
 	/** Next in the transaction log. */
@@ -114,7 +114,7 @@ struct txv {
  */
 struct write_set_key {
 	struct vy_lsm *lsm;
-	const struct tuple *stmt;
+	struct tuple *stmt;
 };
 
 int
@@ -128,7 +128,7 @@ rb_gen_ext_key(MAYBE_UNUSED static inline, write_set_, write_set_t, struct txv,
 
 static inline struct txv *
 write_set_search_key(write_set_t *tree, struct vy_lsm *lsm,
-		     const struct tuple *stmt)
+		     struct tuple *stmt)
 {
 	struct write_set_key key = { .lsm = lsm, .stmt = stmt };
 	return write_set_search(tree, &key);
@@ -420,7 +420,7 @@ struct vy_txw_iterator {
 	 */
 	enum iterator_type iterator_type;
 	/** Search key. */
-	const struct tuple *key;
+	struct tuple *key;
 	/* Last seen value of the write set version. */
 	uint32_t version;
 	/* Current position in the write set. */
@@ -436,8 +436,7 @@ void
 vy_txw_iterator_open(struct vy_txw_iterator *itr,
 		     struct vy_txw_iterator_stat *stat,
 		     struct vy_tx *tx, struct vy_lsm *lsm,
-		     enum iterator_type iterator_type,
-		     const struct tuple *key);
+		     enum iterator_type iterator_type, struct tuple *key);
 
 /**
  * Advance a txw iterator to the next key.
@@ -454,8 +453,7 @@ vy_txw_iterator_next(struct vy_txw_iterator *itr,
  * Returns 0 on success, -1 on memory allocation error.
  */
 NODISCARD int
-vy_txw_iterator_skip(struct vy_txw_iterator *itr,
-		     const struct tuple *last_stmt,
+vy_txw_iterator_skip(struct vy_txw_iterator *itr, struct tuple *last_stmt,
 		     struct vy_history *history);
 
 /**
@@ -465,8 +463,7 @@ vy_txw_iterator_skip(struct vy_txw_iterator *itr,
  * allocation error.
  */
 int
-vy_txw_iterator_restore(struct vy_txw_iterator *itr,
-			const struct tuple *last_stmt,
+vy_txw_iterator_restore(struct vy_txw_iterator *itr, struct tuple *last_stmt,
 			struct vy_history *history);
 
 /**
diff --git a/src/box/vy_upsert.c b/src/box/vy_upsert.c
index 8cf0cc19..2c693706 100644
--- a/src/box/vy_upsert.c
+++ b/src/box/vy_upsert.c
@@ -87,7 +87,7 @@ vy_upsert_try_to_squash(struct tuple_format *format, struct region *region,
 }
 
 struct tuple *
-vy_apply_upsert(const struct tuple *new_stmt, const struct tuple *old_stmt,
+vy_apply_upsert(struct tuple *new_stmt, struct tuple *old_stmt,
 		struct key_def *cmp_def, bool suppress_error)
 {
 	/*
diff --git a/src/box/vy_upsert.h b/src/box/vy_upsert.h
index df3413d8..d546a2a2 100644
--- a/src/box/vy_upsert.h
+++ b/src/box/vy_upsert.h
@@ -63,7 +63,7 @@ struct tuple_format;
  * @retval not NULL Success.
  */
 struct tuple *
-vy_apply_upsert(const struct tuple *new_stmt, const struct tuple *old_stmt,
+vy_apply_upsert(struct tuple *new_stmt, struct tuple *old_stmt,
 		struct key_def *cmp_def, bool suppress_error);
 
 #if defined(__cplusplus)
diff --git a/test/unit/luaT_tuple_new.c b/test/unit/luaT_tuple_new.c
index 3486ed5d..0a16fa03 100644
--- a/test/unit/luaT_tuple_new.c
+++ b/test/unit/luaT_tuple_new.c
@@ -34,7 +34,7 @@ min_u32(uint32_t a, uint32_t b)
 }
 
 void
-check_tuple(const struct tuple *tuple, box_tuple_format_t *format,
+check_tuple(struct tuple *tuple, box_tuple_format_t *format,
 	    int retvals, const char *case_name)
 {
 	uint32_t size;
@@ -50,7 +50,7 @@ check_tuple(const struct tuple *tuple, box_tuple_format_t *format,
 }
 
 void
-check_error(struct lua_State *L, const struct tuple *tuple, int retvals,
+check_error(struct lua_State *L, struct tuple *tuple, int retvals,
 	    const char *case_name)
 {
 	const char *exp_err = "A tuple or a table expected, got number";
diff --git a/test/unit/vy_iterators_helper.c b/test/unit/vy_iterators_helper.c
index 173d58db..23702bcb 100644
--- a/test/unit/vy_iterators_helper.c
+++ b/test/unit/vy_iterators_helper.c
@@ -130,7 +130,7 @@ vy_new_simple_stmt(struct tuple_format *format,
 	return ret;
 }
 
-const struct tuple *
+struct tuple *
 vy_mem_insert_template(struct vy_mem *mem, const struct vy_stmt_template *templ)
 {
 	struct tuple *stmt = vy_new_simple_stmt(mem->format, templ);
@@ -226,7 +226,7 @@ destroy_test_cache(struct vy_cache *cache, struct key_def *def,
 }
 
 bool
-vy_stmt_are_same(const struct tuple *actual,
+vy_stmt_are_same(struct tuple *actual,
 		 const struct vy_stmt_template *expected,
 		 struct tuple_format *format)
 {
diff --git a/test/unit/vy_iterators_helper.h b/test/unit/vy_iterators_helper.h
index 49b4f4fd..3ee6cee6 100644
--- a/test/unit/vy_iterators_helper.h
+++ b/test/unit/vy_iterators_helper.h
@@ -111,7 +111,7 @@ vy_new_simple_stmt(struct tuple_format *format,
  *
  * @retval Lsregion allocated statement.
  */
-const struct tuple *
+struct tuple *
 vy_mem_insert_template(struct vy_mem *mem,
 		       const struct vy_stmt_template *templ);
 
@@ -202,7 +202,7 @@ destroy_test_cache(struct vy_cache *cache, struct key_def *def,
  * @retval stmt === template.
  */
 bool
-vy_stmt_are_same(const struct tuple *actual,
+vy_stmt_are_same(struct tuple *actual,
 		 const struct vy_stmt_template *expected,
 		 struct tuple_format *format);
 
diff --git a/test/unit/vy_mem.c b/test/unit/vy_mem.c
index 798c7a99..acd024dc 100644
--- a/test/unit/vy_mem.c
+++ b/test/unit/vy_mem.c
@@ -26,20 +26,20 @@ test_basic(void)
 	};
 
 	/* Check dump lsn */
-	const struct tuple *stmt = vy_mem_insert_template(mem, &stmts[0]);
+	struct tuple *stmt = vy_mem_insert_template(mem, &stmts[0]);
 	is(mem->dump_lsn, -1, "mem->dump_lsn after prepare");
 	vy_mem_commit_stmt(mem, stmt);
 	is(mem->dump_lsn, 100, "mem->dump_lsn after commit");
 
 	/* Check vy_mem_older_lsn */
-	const struct tuple *older = stmt;
+	struct tuple *older = stmt;
 	stmt = vy_mem_insert_template(mem, &stmts[1]);
 	is(vy_mem_older_lsn(mem, stmt), older, "vy_mem_older_lsn 1");
 	is(vy_mem_older_lsn(mem, older), NULL, "vy_mem_older_lsn 2");
 	vy_mem_commit_stmt(mem, stmt);
 
 	/* Check rollback  */
-	const struct tuple *olderolder = stmt;
+	struct tuple *olderolder = stmt;
 	older = vy_mem_insert_template(mem, &stmts[2]);
 	stmt = vy_mem_insert_template(mem, &stmts[3]);
 	is(vy_mem_older_lsn(mem, stmt), older, "vy_mem_rollback 1");
-- 
2.11.0




More information about the Tarantool-patches mailing list