From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp3.mail.ru (smtp3.mail.ru [94.100.179.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 4C4E746970E for ; Fri, 7 Feb 2020 01:14:56 +0300 (MSK) References: <238698a4-2d95-ead0-66b8-e3096d1906e9@tarantool.org> <20200204192956.61300-1-k.sosnin@tarantool.org> From: Vladislav Shpilevoy Message-ID: Date: Thu, 6 Feb 2020 23:14:54 +0100 MIME-Version: 1.0 In-Reply-To: <20200204192956.61300-1-k.sosnin@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH 1/4] box: replace session_settings modules with a single array List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chris Sosnin , tarantool-patches@dev.tarantool.org Hi! Thanks for the fixes! Now I noticed that struct session_setting_metadata is not really needed. Mask field is never used. I reverted it back to build.c, and added field type directly to struct session_setting. ================================================================================ commit 5b80dce870f045417e63458f6672a82ed5e29bfb Author: Vladislav Shpilevoy Date: Thu Feb 6 22:06:14 2020 +0100 Review fixes diff --git a/src/box/session_settings.h b/src/box/session_settings.h index 1f18f147b..de24e3c6f 100644 --- a/src/box/session_settings.h +++ b/src/box/session_settings.h @@ -62,20 +62,12 @@ enum { SESSION_SETTING_COUNT = SESSION_SETTING_SQL_END, }; -/** - * A structure that allows to establish a connection between - * parameter and its field type and mask, if it has one. -*/ -struct session_setting_metadata { - /** Setting's value type. */ - enum field_type field_type; - /** Stores setting's bit flags. */ - uint32_t mask; -}; - struct session_setting { - /** Setting's value type and the corresponding mask. */ - struct session_setting_metadata metadata; + /** + * Setting's value type. Used for error checking and + * reporting only. + */ + enum field_type field_type; /** * Get a MessagePack encoded pair [name, value] for a * setting having index @a id. Index is from the settings diff --git a/src/box/sql/build.c b/src/box/sql/build.c index 3da60df86..e5fde08cc 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -3310,13 +3310,23 @@ sql_fieldno_by_name(struct Parse *parse_context, struct Expr *field_name, return 0; } +/** + * A local structure that allows to establish a connection between + * parameter and its field type and mask, if it has one. + */ +struct sql_option_metadata +{ + uint32_t field_type; + uint32_t mask; +}; + /** * Variable that contains SQL session option field types and masks * if they have one or 0 if don't have. * * It is IMPORTANT that these options sorted by name. */ -static struct session_setting_metadata sql_session_opts[] = { +static struct sql_option_metadata sql_session_opts[] = { /** SESSION_SETTING_SQL_DEFAULT_ENGINE */ {FIELD_TYPE_STRING, 0}, /** SESSION_SETTING_SQL_DEFER_FOREIGN_KEYS */ @@ -3345,7 +3355,7 @@ 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 session_setting_metadata *opt = &sql_session_opts[id]; + struct sql_option_metadata *opt = &sql_session_opts[id]; uint32_t mask = opt->mask; const char *name = session_setting_strs[id]; size_t name_len = strlen(name); @@ -3382,7 +3392,7 @@ static int sql_set_boolean_option(int id, bool value) { struct session *session = current_session(); - struct session_setting_metadata *option = &sql_session_opts[id]; + struct sql_option_metadata *option = &sql_session_opts[id]; assert(option->field_type == FIELD_TYPE_BOOLEAN); #ifdef NDEBUG if ((session->sql_flags & SQL_SqlTrace) == 0) { @@ -3454,7 +3464,7 @@ sql_session_settings_init() for (int id = SESSION_SETTING_SQL_BEGIN; id < SESSION_SETTING_SQL_END; ++id) { struct session_setting *setting = &session_settings[id]; - setting->metadata = sql_session_opts[id]; + setting->field_type = sql_session_opts[id].field_type; setting->get = sql_session_setting_get; setting->set = sql_session_setting_set; }