From: Timur Safin <tsafin@tarantool.org>
To: v.shpilevoy@tarantool.org, alexander.turenko@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH 2.X v4 2/4] module api: export box_key_def_dup
Date: Wed, 14 Oct 2020 02:01:10 +0300 [thread overview]
Message-ID: <6a3dae58a89d0afa8c61bec92b613e267251440b.1602629628.git.tsafin@tarantool.org> (raw)
In-Reply-To: <cover.1602629628.git.tsafin@tarantool.org>
Exporting `box_key_def_dup` as accessor to the internal `key_def_dup`
Part of #5384
---
src/box/key_def.c | 6 ++++++
src/box/key_def.h | 10 ++++++++++
src/exports.h | 1 +
test/app-tap/module_api.c | 29 +++++++++++++++++++++++++++++
test/app-tap/module_api.test.lua | 2 +-
5 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/src/box/key_def.c b/src/box/key_def.c
index af4e8f4cd..322a62046 100644
--- a/src/box/key_def.c
+++ b/src/box/key_def.c
@@ -507,6 +507,12 @@ box_key_def_new_v2(box_key_part_def_t *parts, uint32_t part_count)
return key_def;
}
+box_key_def_t *
+box_key_def_dup(const box_key_def_t *key_def)
+{
+ return key_def_dup(key_def);
+}
+
void
box_key_def_delete(box_key_def_t *key_def)
{
diff --git a/src/box/key_def.h b/src/box/key_def.h
index 9222c9240..dccad78db 100644
--- a/src/box/key_def.h
+++ b/src/box/key_def.h
@@ -437,6 +437,16 @@ box_key_part_def_create(box_key_part_def_t *part);
API_EXPORT box_key_def_t *
box_key_def_new_v2(box_key_part_def_t *parts, uint32_t part_count);
+/**
+ * Duplicate key_def.
+ * @param key_def Original key_def.
+ *
+ * @retval not NULL Duplicate of src.
+ * @retval NULL Memory error.
+ */
+API_EXPORT box_key_def_t *
+box_key_def_dup(const box_key_def_t *key_def);
+
/**
* Delete key definition
*
diff --git a/src/exports.h b/src/exports.h
index 051818ef7..ff0660e24 100644
--- a/src/exports.h
+++ b/src/exports.h
@@ -31,6 +31,7 @@ EXPORT(box_iterator_free)
EXPORT(box_iterator_next)
EXPORT(box_key_def_delete)
EXPORT(box_key_def_dump_parts)
+EXPORT(box_key_def_dup)
EXPORT(box_key_def_extract_key)
EXPORT(box_key_def_merge)
EXPORT(box_key_def_new)
diff --git a/test/app-tap/module_api.c b/test/app-tap/module_api.c
index 361b75873..17048081f 100644
--- a/test/app-tap/module_api.c
+++ b/test/app-tap/module_api.c
@@ -810,6 +810,34 @@ test_key_def_validate_tuple(struct lua_State *L)
return 1;
}
+static int
+test_key_def_dup(lua_State *L)
+{
+ box_key_def_t *key_def = NULL;
+ box_key_part_def_t part;
+ box_key_part_def_t *dump = NULL;
+ uint32_t dump_part_count = 0;
+
+ key_part_def_set_nondefault(&part);
+ key_def = box_key_def_new_v2(&part, 1);
+ assert(key_def != NULL);
+ box_key_def_t *key_def_dup = box_key_def_dup(key_def);
+ assert(key_def_dup != NULL);
+
+ dump = box_key_def_dump_parts(key_def_dup, &dump_part_count);
+ assert(dump != NULL);
+ assert(dump_part_count == 1);
+
+ key_part_def_check_equal(&part, &dump[0]);
+ key_part_def_check_zeros(&dump[0]);
+
+ box_key_def_delete(key_def_dup);
+ box_key_def_delete(key_def);
+
+ lua_pushboolean(L, 1);
+ return 1;
+}
+
/* }}} key_def api v2 */
static int
@@ -1238,6 +1266,7 @@ luaopen_module_api(lua_State *L)
{"test_key_def_validate_tuple", test_key_def_validate_tuple},
{"tuple_validate_def", test_tuple_validate_default},
{"tuple_validate_fmt", test_tuple_validate_formatted},
+ {"test_key_def_dup", test_key_def_dup},
{NULL, NULL}
};
luaL_register(L, "module_api", lib);
diff --git a/test/app-tap/module_api.test.lua b/test/app-tap/module_api.test.lua
index d250580cf..ab5c89c8c 100755
--- a/test/app-tap/module_api.test.lua
+++ b/test/app-tap/module_api.test.lua
@@ -198,7 +198,7 @@ local function test_iscdata(test, module)
end
local test = require('tap').test("module_api", function(test)
- test:plan(32)
+ test:plan(33)
local status, module = pcall(require, 'module_api')
test:is(status, true, "module")
test:ok(status, "module is loaded")
--
2.20.1
next prev parent reply other threads:[~2020-10-13 23:01 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-13 23:01 [Tarantool-patches] [PATCH 2.X v4 0/4] module api: extend for external merger Lua module Timur Safin
2020-10-13 23:01 ` [Tarantool-patches] [PATCH 2.X v4 1/4] module api: export box_tuple_validate Timur Safin
2020-10-15 21:38 ` Alexander Turenko
2020-10-15 21:47 ` Timur Safin
2020-10-15 22:03 ` Vladislav Shpilevoy
2020-10-13 23:01 ` Timur Safin [this message]
2020-10-13 23:01 ` [Tarantool-patches] [PATCH 2.X v4 3/4] module api: introduced luaT_toibuf instead of luaL_checkibuf Timur Safin
2020-10-14 3:50 ` Alexander Turenko
2020-10-15 21:07 ` Timur Safin
2020-10-15 22:04 ` Vladislav Shpilevoy
2020-10-13 23:01 ` [Tarantool-patches] [PATCH 2.X v4 4/4] module api: box_ibuf_* wrappers Timur Safin
2020-10-14 3:31 ` Alexander Turenko
2020-10-15 21:35 ` Timur Safin
2020-10-15 21:42 ` Alexander Turenko
2020-10-15 21:44 ` Timur Safin
2020-10-15 21:52 ` Alexander Turenko
2020-10-15 22:07 ` Vladislav Shpilevoy
2020-10-15 22:20 ` Alexander Turenko
2020-10-15 22:27 ` Timur Safin
2020-10-15 22:47 ` Alexander Turenko
2020-10-15 22:37 ` Alexander Turenko
2020-10-15 22:48 ` Alexander Turenko
2020-10-15 22:39 ` [Tarantool-patches] [PATCH 2.X v4.1] " Timur Safin
2020-10-16 6:10 ` [Tarantool-patches] [PATCH 2.X v4 0/4] module api: extend for external merger Lua module Alexander Turenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6a3dae58a89d0afa8c61bec92b613e267251440b.1602629628.git.tsafin@tarantool.org \
--to=tsafin@tarantool.org \
--cc=alexander.turenko@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 2.X v4 2/4] module api: export box_key_def_dup' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox