From: Leonid Vasiliev <lvasiliev@tarantool.org> To: v.shpilevoy@tarantool.org, alexander.turenko@tarantool.org Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH V5 3/6] session: add offset to SQL session settings array Date: Sat, 18 Apr 2020 18:29:38 +0300 [thread overview] Message-ID: <c87f12276f31a1f78c27e76f0bf0eb6baf90fddd.1587223627.git.lvasiliev@tarantool.org> (raw) In-Reply-To: <cover.1587223627.git.lvasiliev@tarantool.org> In-Reply-To: <cover.1587223627.git.lvasiliev@tarantool.org> From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Session settings are stored in a monolithic array. Submodules can define a range of settings in there. For example, SQL. It occupies settings from 0 to 8. There is a second array of only SQL settings in build.c, of the same size, and it uses the same indexes. But if something will be added before SQL settings, so as they won't start from 0, it will break the equal indexes assumption. SQL should normalize all setting identifiers by SESSION_SETTING_SQL_BEGIN. --- src/box/sql/build.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/box/sql/build.c b/src/box/sql/build.c index aecba41..b1f9fed 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -3367,7 +3367,8 @@ sql_session_setting_get(int id, const char **mp_pair, const char **mp_pair_end) assert(id >= SESSION_SETTING_SQL_BEGIN && id < SESSION_SETTING_SQL_END); struct session *session = current_session(); uint32_t flags = session->sql_flags; - struct sql_option_metadata *opt = &sql_session_opts[id]; + struct sql_option_metadata *opt = + &sql_session_opts[id - SESSION_SETTING_SQL_BEGIN]; uint32_t mask = opt->mask; const char *name = session_setting_strs[id]; size_t name_len = strlen(name); @@ -3404,7 +3405,8 @@ static int sql_set_boolean_option(int id, bool value) { struct session *session = current_session(); - struct sql_option_metadata *option = &sql_session_opts[id]; + struct sql_option_metadata *option = + &sql_session_opts[id - SESSION_SETTING_SQL_BEGIN]; assert(option->field_type == FIELD_TYPE_BOOLEAN); #ifdef NDEBUG if ((session->sql_flags & SQL_SqlTrace) == 0) { @@ -3431,7 +3433,8 @@ sql_set_boolean_option(int id, bool value) static int sql_set_string_option(int id, const char *value) { - assert(sql_session_opts[id].field_type = FIELD_TYPE_STRING); + assert(sql_session_opts[id - SESSION_SETTING_SQL_BEGIN].field_type = + FIELD_TYPE_STRING); assert(id == SESSION_SETTING_SQL_DEFAULT_ENGINE); (void)id; enum sql_storage_engine engine = STR2ENUM(sql_storage_engine, value); @@ -3448,7 +3451,8 @@ sql_session_setting_set(int id, const char *mp_value) { assert(id >= SESSION_SETTING_SQL_BEGIN && id < SESSION_SETTING_SQL_END); enum mp_type mtype = mp_typeof(*mp_value); - enum field_type stype = sql_session_opts[id].field_type; + enum field_type stype = + sql_session_opts[id - SESSION_SETTING_SQL_BEGIN].field_type; uint32_t len; const char *tmp; switch(stype) { @@ -3473,10 +3477,10 @@ sql_session_setting_set(int id, const char *mp_value) void sql_session_settings_init() { - for (int id = SESSION_SETTING_SQL_BEGIN; id < SESSION_SETTING_SQL_END; - ++id) { + for (int i = 0, id = SESSION_SETTING_SQL_BEGIN; + id < SESSION_SETTING_SQL_END; ++id, ++i) { struct session_setting *setting = &session_settings[id]; - setting->field_type = sql_session_opts[id].field_type; + setting->field_type = sql_session_opts[i].field_type; setting->get = sql_session_setting_get; setting->set = sql_session_setting_set; } -- 2.7.4
next prev parent reply other threads:[~2020-04-18 15:29 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-18 15:29 [Tarantool-patches] [PATCH V5 0/6] Extending error functionality Leonid Vasiliev 2020-04-18 15:29 ` [Tarantool-patches] [PATCH V5 1/6] error: add custom error type Leonid Vasiliev 2020-04-18 18:52 ` Vladislav Shpilevoy 2020-04-18 15:29 ` [Tarantool-patches] [PATCH V5 2/6] error: send custom type in IProto Leonid Vasiliev 2020-04-18 20:39 ` Vladislav Shpilevoy 2020-04-18 15:29 ` Leonid Vasiliev [this message] 2020-04-18 15:29 ` [Tarantool-patches] [PATCH V5 4/6] error: add session setting for error type marshaling Leonid Vasiliev 2020-04-18 20:40 ` Vladislav Shpilevoy 2020-04-18 15:29 ` [Tarantool-patches] [PATCH V5 5/6] error: update constructors of some errors Leonid Vasiliev 2020-04-18 20:39 ` Vladislav Shpilevoy 2020-04-18 15:29 ` [Tarantool-patches] [PATCH V5 6/6] error: add error MsgPack encoding Leonid Vasiliev 2020-04-18 20:39 ` Vladislav Shpilevoy 2020-04-18 21:14 ` [Tarantool-patches] [PATCH V5 5.5/6] box: move Lua MP_EXT decoder from tuple.c Vladislav Shpilevoy
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=c87f12276f31a1f78c27e76f0bf0eb6baf90fddd.1587223627.git.lvasiliev@tarantool.org \ --to=lvasiliev@tarantool.org \ --cc=alexander.turenko@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH V5 3/6] session: add offset to SQL session settings array' \ /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