[Tarantool-patches] [PATCH 2/3] box: introduce _session_settings system space
imeevma at tarantool.org
imeevma at tarantool.org
Thu Dec 19 11:32:58 MSK 2019
This patch creates _session_settings system space. This space is
used to view and change session settings. There are no settings at
the moment, some will be added in the next patch.
Part of #4511
---
src/box/CMakeLists.txt | 1 +
src/box/bootstrap.snap | Bin 5921 -> 5975 bytes
src/box/lua/space.cc | 2 +
src/box/lua/upgrade.lua | 15 +
src/box/schema_def.h | 8 +
src/box/session_settings.c | 409 +++++++++++++++++++++
src/box/session_settings.h | 61 +++
src/box/virtual_engine.c | 52 ++-
test/app-tap/tarantoolctl.test.lua | 4 +-
test/box-py/bootstrap.result | 3 +
test/box/access_sysview.result | 6 +-
test/box/alter.result | 5 +-
...h-4511-access-settings-from-any-frontend.result | 108 +++++-
...4511-access-settings-from-any-frontend.test.lua | 37 ++
test/wal_off/alter.result | 2 +-
15 files changed, 697 insertions(+), 16 deletions(-)
create mode 100644 src/box/session_settings.c
create mode 100644 src/box/session_settings.h
diff --git a/src/box/CMakeLists.txt b/src/box/CMakeLists.txt
index c011bfc..2cb81e8 100644
--- a/src/box/CMakeLists.txt
+++ b/src/box/CMakeLists.txt
@@ -79,6 +79,7 @@ add_library(box STATIC
sysview.c
blackhole.c
virtual_engine.c
+ session_settings.c
vinyl.c
vy_stmt.c
vy_mem.c
diff --git a/src/box/bootstrap.snap b/src/box/bootstrap.snap
index 7ff3aa5984dbe41a6d4fef7a9ff427336691784f..c573eecd01cf7c7ada949571750f5ba7f30a0e58 100644
GIT binary patch
literal 5975
zcmV-d7pUk{PC-x#FfK7O3RY!ub7^mGIv_GGGcGVKGB+_TXEtUxFgamj3Q2BrbYX5|
zWjY`-FgP?}HfCfkVliSjEi^JPHZ5XiVPh>}W-~ZuIW#jeW;109RzqxWV{1AfdwmKD
z)w&D1%@*GP&H{cG{G|W at 0000ewJ-euP_?!I`p{@ENf2nO>HuFnz!wkj#k+nW%pPgt
zBZ0)WtpN`tMI1&W;^gZsQ&N;l)}E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D6*40c`X|c=@V>OB`acl+2X$i$
z&aqBzwTrgqf at r}4?-ceIZj$#d*+`f<z-c`-X@@ee;=@%VK2r~E4#(RaV?SwTOC~uR
zxDrK0(B^~+P@>{Q)6z7fP<raLf1_#dCBDZA#fufhD4!d!LA>w|u%NiDJuD(3Aut_J
zB$WeI>SgZg_EAl=Nm-}NBCzS>52hp25`1v8 at LMMC%)UO%)66y%8ajuLUw+}_jf<6q
zzd_dT1Aj!lt%J$X*O}?#X!1F)`68aJ4C{SKDw5L(4!~DT*gxt5|NG9g^nrTv+{i1W
ze=F+NYQ21UXnfT4$3=S2V+>lm-=xj&*WjC~dt-)QzF1hL9)OM!yUG(CT~#(6AI`}7
zu7#Ysy4LY87mqe3*1v)k$a47X81nU`ycYhO+>vqUJz2JOnJsmEd-Li_;8z;kk=FEi
zn>npn1}!y4!}lJIpv6bE(y&;?h-lUY+_$w0F8j&^#N|}j9$G+#`Q*^%EollIMyvcx
z<H3Ai_E^fMKZn3!%LXZ_PbTB!)Gxn^K66K?<3-vP5>Fsb{Sz&g=2w3S4GVr9Psih$
z3FamP^mw at yI(_O<fB_8lNQ>IiCtrXkAw(`#dl^D$1)JlpsectmRh{e-kev$J2sah?
z)n5`R{HaC<U^~v83zZ3>h(hNf{wCJqZztG>>B{wJTQtJj+DhM4MK)XcaIO#bTuJI9
R`4aDV?4_>I=7?&J{|DXTQmz01
diff --git a/src/box/lua/space.cc b/src/box/lua/space.cc
index f6e96f0..01b58af 100644
--- a/src/box/lua/space.cc
+++ b/src/box/lua/space.cc
@@ -653,6 +653,8 @@ box_lua_space_init(struct lua_State *L)
lua_setfield(L, -2, "SPACE_SEQUENCE_ID");
lua_pushnumber(L, BOX_FUNC_INDEX_ID);
lua_setfield(L, -2, "FUNC_INDEX_ID");
+ lua_pushnumber(L, BOX_SESSION_SETTINGS_ID);
+ lua_setfield(L, -2, "SESSION_SETTINGS_ID");
lua_pushnumber(L, BOX_SYSTEM_ID_MIN);
lua_setfield(L, -2, "SYSTEM_ID_MIN");
lua_pushnumber(L, BOX_SYSTEM_ID_MAX);
diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua
index 07f1e03..4dfd571 100644
--- a/src/box/lua/upgrade.lua
+++ b/src/box/lua/upgrade.lua
@@ -951,8 +951,23 @@ local function drop_func_collation()
_func.index.name:alter({parts = {{'name', 'string'}}})
end
+local function create_session_settings_space()
+ local _space = box.space[box.schema.SPACE_ID]
+ local _index = box.space[box.schema.INDEX_ID]
+ local format = {}
+ format[1] = {name='name', type='string'}
+ format[2] = {name='value', type='any'}
+ log.info("create space _session_settings")
+ _space:insert{box.schema.SESSION_SETTINGS_ID, ADMIN, '_session_settings',
+ 'virtual', 2, {temporary = true}, format}
+ log.info("create index _session_settings:primary")
+ _index:insert{box.schema.SESSION_SETTINGS_ID, 0, 'primary', 'tree',
+ {unique = true}, {{0, 'string'}}}
+end
+
local function upgrade_to_2_3_1()
drop_func_collation()
+ create_session_settings_space()
end
--------------------------------------------------------------------------------
diff --git a/src/box/schema_def.h b/src/box/schema_def.h
index ba870ff..f86cd42 100644
--- a/src/box/schema_def.h
+++ b/src/box/schema_def.h
@@ -114,6 +114,8 @@ enum {
BOX_CK_CONSTRAINT_ID = 364,
/** Space id of _func_index. */
BOX_FUNC_INDEX_ID = 372,
+ /** Space id of _session_settings. */
+ BOX_SESSION_SETTINGS_ID = 380,
/** End of the reserved range of system spaces. */
BOX_SYSTEM_ID_MAX = 511,
BOX_ID_NIL = 2147483647
@@ -277,6 +279,12 @@ enum {
BOX_FUNC_INDEX_FUNCTION_ID = 2,
};
+/** _session_settings fields. */
+enum {
+ BOX_SESSION_SETTINGS_FIELD_NAME = 0,
+ BOX_SESSION_SETTINGS_FIELD_VALUE = 1,
+};
+
/*
* Different objects which can be subject to access
* control.
diff --git a/src/box/session_settings.c b/src/box/session_settings.c
new file mode 100644
index 0000000..b5b5db8
--- /dev/null
+++ b/src/box/session_settings.c
@@ -0,0 +1,409 @@
+/*
+ * Copyright 2010-2019, Tarantool AUTHORS, please see AUTHORS file.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include "session_settings.h"
+#include "xrow_update.h"
+#include "virtual_engine.h"
+#include "session.h"
+#include "schema.h"
+#include "tuple.h"
+#include "xrow.h"
+#include "sql.h"
+
+struct session_settings_modules
+ session_settings_modules[SESSION_SETTING_MODULE_max] = {};
+
+struct session_settings_index {
+ /** Base index. Must be the first member. */
+ struct index base;
+ /** Format to create tuples on the fly. */
+ struct tuple_format *format;
+};
+
+struct session_settings_iterator {
+ /** Base iterator. Must be the first member. */
+ struct iterator base;
+ /** Format of the tuples this iterator returns. */
+ struct tuple_format *format;
+ /** ID of current module in global list of the modules. */
+ int module_id;
+ /** ID of the setting in current module. */
+ int current_id;
+ /** Decoded key. */
+ char *key;
+ /** Type of iterator. */
+ enum iterator_type iterator_type;
+};
+
+static void
+session_settings_iterator_free(struct iterator *ptr)
+{
+ struct session_settings_iterator *it =
+ (struct session_settings_iterator *)ptr;
+ free(it->key);
+ free(it);
+}
+
+static int
+session_settings_iterator_next(struct iterator *iterator, struct tuple **result)
+{
+ struct session_settings_iterator *it =
+ (struct session_settings_iterator *)iterator;
+ if (it->module_id >= SESSION_SETTING_MODULE_max || it->module_id < 0) {
+ *result = NULL;
+ return 0;
+ }
+
+ struct tuple *ret = NULL;
+ int i = it->module_id;
+ int j = it->current_id;
+ enum iterator_type type = it->iterator_type;
+ struct tuple_format *format = it->format;
+ struct session_settings_modules *module;
+ const char *key = it->key;
+
+ if (!iterator_type_is_reverse(type)) {
+ for (; i < SESSION_SETTING_MODULE_max; ++i) {
+ module = &session_settings_modules[i];
+ if (module->get(format, j, key, type, &j, &ret) != 0)
+ return -1;
+ if (ret != NULL)
+ break;
+ j = 0;
+ }
+ *result = ret;
+ if (i == SESSION_SETTING_MODULE_max) {
+ it->module_id = SESSION_SETTING_MODULE_max;
+ it->current_id = 0;
+ return 0;
+ }
+ ++j;
+ if (j >= (int)module->size) {
+ ++i;
+ j = 0;
+ }
+ it->module_id = i;
+ it->current_id = j;
+ return 0;
+ }
+
+ for (; i >= 0; --i) {
+ module = &session_settings_modules[i];
+ if (module->get(format, j, key, type, &j, &ret) != 0)
+ return -1;
+ if (ret != NULL)
+ break;
+ if (i > 0)
+ j = session_settings_modules[i - 1].size - 1;
+ }
+ *result = ret;
+ if (i < 0) {
+ it->module_id = -1;
+ it->current_id = 0;
+ return 0;
+ }
+ --j;
+ if (j < 0) {
+ --i;
+ if (i >= 0)
+ j = module[i].size - 1;
+ }
+ it->module_id = i;
+ it->current_id = j;
+ return 0;
+}
+
+static void
+session_settings_index_destroy(struct index *index)
+{
+ free(index);
+}
+
+static struct iterator *
+session_settings_index_create_iterator(struct index *base,
+ enum iterator_type type, const char *key,
+ uint32_t part_count)
+{
+ struct session_settings_index *index =
+ (struct session_settings_index *)base;
+ char *decoded_key = NULL;
+ if (part_count > 0) {
+ assert(part_count == 1);
+ assert(mp_typeof(*key) == MP_STR);
+ uint32_t len;
+ const char *name = mp_decode_str(&key, &len);
+ decoded_key = (char *)malloc(len + 1);
+ if (decoded_key == NULL) {
+ diag_set(OutOfMemory, len + 1, "malloc", "decoded_key");
+ return NULL;
+ }
+ memcpy(decoded_key, name, len);
+ decoded_key[len] = '\0';
+ }
+ struct session_settings_iterator *it =
+ (struct session_settings_iterator *)malloc(sizeof(*it));
+ if (it == NULL) {
+ diag_set(OutOfMemory, sizeof(*it), "malloc", "it");
+ free(decoded_key);
+ return NULL;
+ }
+ iterator_create(&it->base, base);
+ it->base.next = session_settings_iterator_next;
+ it->base.free = session_settings_iterator_free;
+ it->key = decoded_key;
+ it->iterator_type = type;
+ it->format = index->format;
+ it->module_id = iterator_type_is_reverse(type) ?
+ SESSION_SETTING_MODULE_max - 1 : 0;
+ it->current_id = iterator_type_is_reverse(type) ?
+ session_settings_modules[it->module_id].size - 1 : 0;
+ return (struct iterator *)it;
+}
+
+static int
+session_settings_index_get(struct index *base, const char *key,
+ uint32_t part_count, struct tuple **result)
+{
+ struct session_settings_index *index =
+ (struct session_settings_index *)base;
+ assert(part_count == 1);
+ (void)part_count;
+ uint32_t len;
+ const char *tmp = mp_decode_str(&key, &len);
+ const char *decoded_key = tt_cstr(tmp, len);
+ struct tuple *ret = NULL;
+ struct tuple_format *format = index->format;
+ for (int i = 0; i < SESSION_SETTING_MODULE_max; ++i) {
+ if (session_settings_modules[i].get(format, 0, decoded_key,
+ ITER_EQ, NULL, &ret) != 0)
+ return -1;
+ if (ret != NULL)
+ break;
+ }
+ *result = ret;
+ return 0;
+}
+
+static const struct index_vtab session_settings_index_vtab = {
+ /* .destroy = */ session_settings_index_destroy,
+ /* .commit_create = */ generic_index_commit_create,
+ /* .abort_create = */ generic_index_abort_create,
+ /* .commit_modify = */ generic_index_commit_modify,
+ /* .commit_drop = */ generic_index_commit_drop,
+ /* .update_def = */ generic_index_update_def,
+ /* .depends_on_pk = */ generic_index_depends_on_pk,
+ /* .def_change_requires_rebuild = */
+ generic_index_def_change_requires_rebuild,
+ /* .size = */ generic_index_size,
+ /* .bsize = */ generic_index_bsize,
+ /* .min = */ generic_index_min,
+ /* .max = */ generic_index_max,
+ /* .random = */ generic_index_random,
+ /* .count = */ generic_index_count,
+ /* .get = */ session_settings_index_get,
+ /* .replace = */ generic_index_replace,
+ /* .create_iterator = */ session_settings_index_create_iterator,
+ /* .create_snapshot_iterator = */
+ generic_index_create_snapshot_iterator,
+ /* .stat = */ generic_index_stat,
+ /* .compact = */ generic_index_compact,
+ /* .reset_stat = */ generic_index_reset_stat,
+ /* .begin_build = */ generic_index_begin_build,
+ /* .reserve = */ generic_index_reserve,
+ /* .build_next = */ generic_index_build_next,
+ /* .end_build = */ generic_index_end_build,
+};
+
+static void
+session_settings_space_destroy(struct space *space)
+{
+ free(space);
+}
+
+static int
+session_settings_space_execute_replace(struct space *space, struct txn *txn,
+ struct request *request,
+ struct tuple **result)
+{
+ (void)space;
+ (void)txn;
+ (void)request;
+ (void)result;
+ diag_set(ClientError, ER_UNSUPPORTED, "Session_settings space",
+ "replace()");
+ return -1;
+}
+
+static int
+session_settings_space_execute_delete(struct space *space, struct txn *txn,
+ struct request *request,
+ struct tuple **result)
+{
+ (void)space;
+ (void)txn;
+ (void)request;
+ (void)result;
+ diag_set(ClientError, ER_UNSUPPORTED, "Session_settings space",
+ "delete()");
+ return -1;
+}
+
+static int
+session_settings_space_execute_update(struct space *space, struct txn *txn,
+ struct request *request,
+ struct tuple **result)
+{
+ (void)txn;
+ const char *data = request->key;
+ uint32_t key_len = mp_decode_array(&data);
+ if (key_len == 0) {
+ diag_set(ClientError, ER_EXACT_MATCH, 1, 0);
+ return -1;
+ }
+ if (key_len > 1 || mp_typeof(*data) != MP_STR) {
+ diag_set(ClientError, ER_KEY_PART_TYPE, 0, "string");
+ return -1;
+ }
+ uint32_t len;
+ const char *tmp = mp_decode_str(&data, &len);
+ const char *decoded_key = tt_cstr(tmp, len);
+
+ int id;
+ struct tuple *old_tuple = NULL;
+ struct tuple_format *format = space->format;
+ struct session_settings_modules *module = NULL;
+ for (int i = 0; i < SESSION_SETTING_MODULE_max; ++i) {
+ module = &session_settings_modules[i];
+ if (module->get(format, 0, decoded_key, ITER_EQ, &id,
+ &old_tuple) != 0)
+ return -1;
+ if (old_tuple != NULL)
+ break;
+ }
+ if (old_tuple == NULL)
+ return 0;
+
+ uint32_t new_size = 0, bsize;
+ const char *old_data = tuple_data_range(old_tuple, &bsize);
+ const char *new_data =
+ xrow_update_execute(request->tuple,request->tuple_end,
+ old_data, old_data + bsize, format->dict,
+ &new_size, request->index_base, NULL);
+ if (new_data == NULL)
+ return -1;
+
+ uint32_t array_len = mp_decode_array(&new_data);
+ if (array_len != 2)
+ if (format->exact_field_count != array_len) {
+ diag_set(ClientError, ER_EXACT_FIELD_COUNT,
+ array_len, format->exact_field_count);
+ return -1;
+ }
+
+ if (mp_typeof(*new_data) != MP_STR) {
+ diag_set(ClientError, ER_CANT_UPDATE_PRIMARY_KEY,
+ space_index(space, 0)->def->name, space_name(space));
+ return -1;
+ }
+
+ const char *value = new_data;
+ mp_next(&value);
+ mp_decode_array(&old_data);
+ uint32_t size_a = mp_sizeof_str(len);
+ uint32_t size_b = value - new_data;
+ if (size_a != size_b || memcmp(old_data, new_data, size_a) != 0) {
+ diag_set(ClientError, ER_CANT_UPDATE_PRIMARY_KEY,
+ space_index(space, 0)->def->name, space_name(space));
+ return -1;
+ }
+
+ return module->set(format, id, value, result);
+}
+
+static int
+session_settings_space_execute_upsert(struct space *space, struct txn *txn,
+ struct request *request)
+{
+ (void)space;
+ (void)txn;
+ (void)request;
+ diag_set(ClientError, ER_UNSUPPORTED, "Session_settings space",
+ "upsert()");
+ return -1;
+}
+
+static struct index *
+session_settings_space_create_index(struct space *space, struct index_def *def)
+{
+ assert(space->def->id == BOX_SESSION_SETTINGS_ID);
+ if (def->iid != 0) {
+ diag_set(ClientError, ER_UNSUPPORTED, "Session_settings space",
+ "create_index()");
+ return NULL;
+ }
+
+ struct session_settings_index *index =
+ (struct session_settings_index *)calloc(1, sizeof(*index));
+ if (index == NULL) {
+ diag_set(OutOfMemory, sizeof(*index), "calloc", "index");
+ return NULL;
+ }
+ if (index_create(&index->base, space->engine,
+ &session_settings_index_vtab, def) != 0) {
+ free(index);
+ return NULL;
+ }
+
+ index->format = space->format;
+ return &index->base;
+}
+
+const struct space_vtab session_settings_space_vtab = {
+ /* .destroy = */ session_settings_space_destroy,
+ /* .bsize = */ generic_space_bsize,
+ /* .execute_replace = */ session_settings_space_execute_replace,
+ /* .execute_delete = */ session_settings_space_execute_delete,
+ /* .execute_update = */ session_settings_space_execute_update,
+ /* .execute_upsert = */ session_settings_space_execute_upsert,
+ /* .ephemeral_replace = */ generic_space_ephemeral_replace,
+ /* .ephemeral_delete = */ generic_space_ephemeral_delete,
+ /* .ephemeral_rowid_next = */ generic_space_ephemeral_rowid_next,
+ /* .init_system_space = */ generic_init_system_space,
+ /* .init_ephemeral_space = */ generic_init_ephemeral_space,
+ /* .check_index_def = */ generic_space_check_index_def,
+ /* .create_index = */ session_settings_space_create_index,
+ /* .add_primary_key = */ generic_space_add_primary_key,
+ /* .drop_primary_key = */ generic_space_drop_primary_key,
+ /* .check_format = */ generic_space_check_format,
+ /* .build_index = */ generic_space_build_index,
+ /* .swap_index = */ generic_space_swap_index,
+ /* .prepare_alter = */ generic_space_prepare_alter,
+ /* .invalidate = */ generic_space_invalidate,
+};
diff --git a/src/box/session_settings.h b/src/box/session_settings.h
new file mode 100644
index 0000000..e7ecbdb
--- /dev/null
+++ b/src/box/session_settings.h
@@ -0,0 +1,61 @@
+#pragma once
+/*
+ * Copyright 2010-2019, Tarantool AUTHORS, please see AUTHORS file.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include <stddef.h>
+#include <stdint.h>
+#include "iterator_type.h"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif /* defined(__cplusplus) */
+
+enum session_setting_module {
+ SESSION_SETTING_MODULE_max
+};
+
+struct tuple;
+struct tuple_format;
+
+struct session_settings_modules {
+ enum session_setting_module id;
+ uint32_t size;
+ int (*get)(struct tuple_format *format, int id, const char *key,
+ enum iterator_type type, int *end_id, struct tuple **result);
+ int (*set)(struct tuple_format *format, int id, const char *value,
+ struct tuple **result);
+};
+
+extern struct session_settings_modules session_settings_modules[];
+extern const struct space_vtab session_settings_space_vtab;
+
+#if defined(__cplusplus)
+} /* extern "C" */
+#endif /* defined(__plusplus) */
diff --git a/src/box/virtual_engine.c b/src/box/virtual_engine.c
index 45993b9..8680747 100644
--- a/src/box/virtual_engine.c
+++ b/src/box/virtual_engine.c
@@ -28,6 +28,7 @@
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+#include "session_settings.h"
#include "virtual_engine.h"
#include "schema.h"
#include "tuple.h"
@@ -42,13 +43,50 @@ static struct space *
virtual_engine_create_space(struct engine *engine, struct space_def *def,
struct rlist *key_list)
{
- (void)engine;
- (void)def;
- (void)key_list;
- /* There are currently no spaces with this engine. */
- diag_set(ClientError, ER_UNSUPPORTED, "Tarantool",
- "spaces with this engine.");
- return NULL;
+ /*
+ * At the moment the only space that have this engine is
+ * _session_sessings.
+ */
+ if (def->id != BOX_SESSION_SETTINGS_ID) {
+ diag_set(ClientError, ER_UNSUPPORTED, "Tarantool",
+ "non-system space with this engine.");
+ return NULL;
+ }
+ const struct space_vtab *space_vtab = &session_settings_space_vtab;
+
+ struct space *space = (struct space *)calloc(1, sizeof(*space));
+ if (space == NULL) {
+ diag_set(OutOfMemory, sizeof(*space), "calloc", "space");
+ return NULL;
+ }
+ int key_count = 0;
+ struct key_def **keys = index_def_to_key_def(key_list, &key_count);
+ if (keys == NULL) {
+ free(space);
+ return NULL;
+ }
+ struct tuple_format *format =
+ tuple_format_new(&tuple_format_runtime->vtab, NULL, keys,
+ key_count, def->fields, def->field_count,
+ def->exact_field_count, def->dict,
+ def->opts.is_temporary,
+ def->opts.is_ephemeral);
+ if (format == NULL) {
+ free(space);
+ return NULL;
+ }
+ tuple_format_ref(format);
+ int rc = space_create(space, engine, space_vtab, def, key_list, format);
+ /*
+ * Format is now referenced by the space if space has beed
+ * created.
+ */
+ tuple_format_unref(format);
+ if (rc != 0) {
+ free(space);
+ return NULL;
+ }
+ return space;
}
static const struct engine_vtab virtual_engine_vtab = {
diff --git a/test/app-tap/tarantoolctl.test.lua b/test/app-tap/tarantoolctl.test.lua
index 7a07860..4d70595 100755
--- a/test/app-tap/tarantoolctl.test.lua
+++ b/test/app-tap/tarantoolctl.test.lua
@@ -415,8 +415,8 @@ do
check_ctlcat_xlog(test_i, dir, "--from=3 --to=6 --format=json --show-system --replica 1", "\n", 3)
check_ctlcat_xlog(test_i, dir, "--from=3 --to=6 --format=json --show-system --replica 1 --replica 2", "\n", 3)
check_ctlcat_xlog(test_i, dir, "--from=3 --to=6 --format=json --show-system --replica 2", "\n", 0)
- check_ctlcat_snap(test_i, dir, "--space=280", "---\n", 24)
- check_ctlcat_snap(test_i, dir, "--space=288", "---\n", 52)
+ check_ctlcat_snap(test_i, dir, "--space=280", "---\n", 25)
+ check_ctlcat_snap(test_i, dir, "--space=288", "---\n", 53)
end)
end)
diff --git a/test/box-py/bootstrap.result b/test/box-py/bootstrap.result
index 938a763..f2ad75e 100644
--- a/test/box-py/bootstrap.result
+++ b/test/box-py/bootstrap.result
@@ -96,6 +96,8 @@ box.space._space:select{}
'type': 'boolean'}]]
- [372, 1, '_func_index', 'memtx', 0, {}, [{'name': 'space_id', 'type': 'unsigned'},
{'name': 'index_id', 'type': 'unsigned'}, {'name': 'func_id', 'type': 'unsigned'}]]
+ - [380, 1, '_session_settings', 'virtual', 2, {'temporary': true}, [{'name': 'name',
+ 'type': 'string'}, {'name': 'value', 'type': 'any'}]]
...
box.space._index:select{}
---
@@ -153,6 +155,7 @@ box.space._index:select{}
- [364, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned'], [1, 'string']]]
- [372, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned'], [1, 'unsigned']]]
- [372, 1, 'fid', 'tree', {'unique': false}, [[2, 'unsigned']]]
+ - [380, 0, 'primary', 'tree', {'unique': true}, [[0, 'string']]]
...
box.space._user:select{}
---
diff --git a/test/box/access_sysview.result b/test/box/access_sysview.result
index 1f33dec..799d19f 100644
--- a/test/box/access_sysview.result
+++ b/test/box/access_sysview.result
@@ -246,11 +246,11 @@ box.session.su('guest')
...
#box.space._vspace:select{}
---
-- 25
+- 26
...
#box.space._vindex:select{}
---
-- 53
+- 54
...
#box.space._vuser:select{}
---
@@ -282,7 +282,7 @@ box.session.su('guest')
...
#box.space._vindex:select{}
---
-- 53
+- 54
...
#box.space._vuser:select{}
---
diff --git a/test/box/alter.result b/test/box/alter.result
index 9a2f991..f150faa 100644
--- a/test/box/alter.result
+++ b/test/box/alter.result
@@ -92,7 +92,7 @@ space = box.space[t[1]]
...
space.id
---
-- 373
+- 381
...
space.field_count
---
@@ -137,7 +137,7 @@ space_deleted
...
space:replace{0}
---
-- error: Space '373' does not exist
+- error: Space '381' does not exist
...
_index:insert{_space.id, 0, 'primary', 'tree', {unique=true}, {{0, 'unsigned'}}}
---
@@ -220,6 +220,7 @@ _index:select{}
- [364, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned'], [1, 'string']]]
- [372, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned'], [1, 'unsigned']]]
- [372, 1, 'fid', 'tree', {'unique': false}, [[2, 'unsigned']]]
+ - [380, 0, 'primary', 'tree', {'unique': true}, [[0, 'string']]]
...
-- modify indexes of a system space
_index:delete{_index.id, 0}
diff --git a/test/box/gh-4511-access-settings-from-any-frontend.result b/test/box/gh-4511-access-settings-from-any-frontend.result
index 9874616..75d53cf 100644
--- a/test/box/gh-4511-access-settings-from-any-frontend.result
+++ b/test/box/gh-4511-access-settings-from-any-frontend.result
@@ -6,5 +6,111 @@ test_run = require('test_run').new()
-- User cannot create spaces with this engine.
s = box.schema.space.create('test', {engine = 'virtual'})
| ---
- | - error: Tarantool does not support spaces with this engine.
+ | - error: Tarantool does not support non-system space with this engine.
+ | ...
+
+-- Check _session_settings space.
+s = box.space._session_settings
+ | ---
+ | ...
+s:format()
+ | ---
+ | - [{'name': 'name', 'type': 'string'}, {'name': 'value', 'type': 'any'}]
+ | ...
+
+-- Make sure that we cannot drop space.
+s:drop()
+ | ---
+ | - error: Can't drop the primary key in a system space, space '_session_settings'
+ | ...
+
+--
+-- Make sure, that session_settings space doesn't support
+-- create_index(), insert(), replace() and delete() methods.
+--
+s:create_index('a')
+ | ---
+ | - error: Session_settings space does not support create_index()
+ | ...
+s:insert({'a', 1})
+ | ---
+ | - error: Session_settings space does not support replace()
+ | ...
+s:delete({'b'})
+ | ---
+ | - error: Session_settings space does not support delete()
+ | ...
+s:replace({'sql_defer_foreign_keys', true})
+ | ---
+ | - error: Session_settings space does not support replace()
+ | ...
+
+-- Check get() and select(). They should return nothing for now.
+s:get({'a'})
+ | ---
+ | ...
+s:select()
+ | ---
+ | - []
+ | ...
+s:select({}, {iterator='EQ'})
+ | ---
+ | - []
+ | ...
+s:select({}, {iterator='ALL'})
+ | ---
+ | - []
+ | ...
+s:select({}, {iterator='GE'})
+ | ---
+ | - []
+ | ...
+s:select({}, {iterator='GT'})
+ | ---
+ | - []
+ | ...
+s:select({}, {iterator='REQ'})
+ | ---
+ | - []
+ | ...
+s:select({}, {iterator='LE'})
+ | ---
+ | - []
+ | ...
+s:select({}, {iterator='LT'})
+ | ---
+ | - []
+ | ...
+s:select({'a'}, {iterator='EQ'})
+ | ---
+ | - []
+ | ...
+s:select({'a'}, {iterator='ALL'})
+ | ---
+ | - []
+ | ...
+s:select({'a'}, {iterator='GE'})
+ | ---
+ | - []
+ | ...
+s:select({'a'}, {iterator='GT'})
+ | ---
+ | - []
+ | ...
+s:select({'a'}, {iterator='REQ'})
+ | ---
+ | - []
+ | ...
+s:select({'a'}, {iterator='LE'})
+ | ---
+ | - []
+ | ...
+s:select({'a'}, {iterator='LT'})
+ | ---
+ | - []
+ | ...
+
+-- Currently there is nothing to update, but update() should work.
+s:update('some_option', {{'=', 'value', true}})
+ | ---
| ...
diff --git a/test/box/gh-4511-access-settings-from-any-frontend.test.lua b/test/box/gh-4511-access-settings-from-any-frontend.test.lua
index 611caef..3304454 100644
--- a/test/box/gh-4511-access-settings-from-any-frontend.test.lua
+++ b/test/box/gh-4511-access-settings-from-any-frontend.test.lua
@@ -2,3 +2,40 @@ test_run = require('test_run').new()
-- User cannot create spaces with this engine.
s = box.schema.space.create('test', {engine = 'virtual'})
+
+-- Check _session_settings space.
+s = box.space._session_settings
+s:format()
+
+-- Make sure that we cannot drop space.
+s:drop()
+
+--
+-- Make sure, that session_settings space doesn't support
+-- create_index(), insert(), replace() and delete() methods.
+--
+s:create_index('a')
+s:insert({'a', 1})
+s:delete({'b'})
+s:replace({'sql_defer_foreign_keys', true})
+
+-- Check get() and select(). They should return nothing for now.
+s:get({'a'})
+s:select()
+s:select({}, {iterator='EQ'})
+s:select({}, {iterator='ALL'})
+s:select({}, {iterator='GE'})
+s:select({}, {iterator='GT'})
+s:select({}, {iterator='REQ'})
+s:select({}, {iterator='LE'})
+s:select({}, {iterator='LT'})
+s:select({'a'}, {iterator='EQ'})
+s:select({'a'}, {iterator='ALL'})
+s:select({'a'}, {iterator='GE'})
+s:select({'a'}, {iterator='GT'})
+s:select({'a'}, {iterator='REQ'})
+s:select({'a'}, {iterator='LE'})
+s:select({'a'}, {iterator='LT'})
+
+-- Currently there is nothing to update, but update() should work.
+s:update('some_option', {{'=', 'value', true}})
diff --git a/test/wal_off/alter.result b/test/wal_off/alter.result
index 62cb11d..97f7e6f 100644
--- a/test/wal_off/alter.result
+++ b/test/wal_off/alter.result
@@ -28,7 +28,7 @@ end;
...
#spaces;
---
-- 65502
+- 65501
...
-- cleanup
for k, v in pairs(spaces) do
--
2.7.4
More information about the Tarantool-patches
mailing list