From: Chris Sosnin <k.sosnin@tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>,
tarantool-patches@dev.tarantool.org,
Nikita Pettik <korablev@tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH 4/4] sql: provide a user friendly frontend for accessing session settings
Date: Mon, 17 Feb 2020 14:46:07 +0300 [thread overview]
Message-ID: <DEE17776-4A55-43B9-8714-1B51F50BE112@tarantool.org> (raw)
In-Reply-To: <d01a2df7-249a-1bba-20a8-22e06998d5f0@tarantool.org>
[-- Attachment #1: Type: text/plain, Size: 3823 bytes --]
> 11 февр. 2020 г., в 01:09, Vladislav Shpilevoy <v.shpilevoy@tarantool.org> написал(а):
>
> Hi! Thanks for the fixes!
>
> On the branch you said this commit is 'Part of #4711'. Why
> not 'Closes #4711'? What else is left?
>
Replaced with ‘Closes’.
>> sql: provide a user friendly frontend for accessing session settings
>>
>> Currently if a user wants to change session setting with sql, he has
>> to execute non-obvious query, thus, we introduce a more native way to
>> do this.
>>
>> Part of #4711
>>
>> @TarantoolBot document
>> Title: API for accessing _session_settings space.
>> There are two ways of updating values of session settings:
>> via Lua and SQL.
>>
>> Lua:
>> box.session.settings is a table, which is accessible right after
>> session creation. The syntax is the following:
>
> Lets say it is available always. Because a user can't live without
> a session anyway. It always exists for a user.
Commited the following change:
which is accessible right after session creation —> which is always accessible
to user
>> `box.session.settings.<setting_name>:set(<new_value>)`.
>>
>> Example of usage:
>> ```
>> tarantool> box.session.settings.sql_default_engine
>> ---
>> - memtx
>> ...
>>
>> tarantool> box.session.settings.sql_default_engine:set('vinyl')
>> ---
>> ...
>>
>> ```
>>
>> The table itself represents the (unordered) result of select
>> from _session_settings space. Every setting is implemented as
>> a table, so there is no way to retrieve an actual value and use
>> it until :get() method is introduced.
>>
>> SQL:
>> Instead of typing long UPDATE query one can use the SET statement:
>> `box.execute([[SET "<setting_name>" = <new_value>]])`.
>> Note, that this query is case sensitive so the name must be quoted.
>>
>> Example:
>> ```
>> tarantool> box.execute([[set "sql_default_engine" = 'memtx']])
>> ---
>> - row_count: 1
>> ...
>>
>> tarantool> box.execute([[set "sql_defer_foreign_keys" = true]])
>> ---
>> - row_count: 1
>> ...
>>
>> ```
>
> I am not so sure about binary search anymore. I just found another
> probably much faster way - perfect hash function. There is a GNU
> tool 'gperf' to generate C code for a given keyset with hash
> calculation and search functions.
>
> I fed our settings to it and obtained not so scary result.
>
> File: test.gperf
>
> %%
> sql_default_engine
> sql_defer_foreign_keys
> sql_full_column_names
> sql_full_metadata
> sql_parser_debug
> sql_recursive_triggers
> sql_reverse_unordered_selects
> sql_select_debug
> sql_vdbe_debug
> %%
>
> Command: gperf test.gperf > test.c
>
> The test.c file is 122 lines long including some {}, useless
> checks, macros, and comments. It could easily be compacted a lot.
I like the idea of speeding search up, but it would make adding new settings
even more complicated (+regenerate file with gpref, +mannualy format it).
>
> This is probably overkill though. It needs to be completely
> regenerated each time when the keyset is changed, consumes more
> static memory.
I agree.
>
> The patchset LGTM. I propose to send it to Nikita on a second
> review.
Nikita, please do a second review.
branch: https://github.com/tarantool/tarantool/tree/ksosnin/gh-4712-search-settings <https://github.com/tarantool/tarantool/tree/ksosnin/gh-4712-search-settings>
issue #1: https://github.com/tarantool/tarantool/issues/4711 <https://github.com/tarantool/tarantool/issues/4711>
issue #2: https://github.com/tarantool/tarantool/issues/4712 <https://github.com/tarantool/tarantool/issues/4712>
[-- Attachment #2: Type: text/html, Size: 6686 bytes --]
next prev parent reply other threads:[~2020-02-17 11:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-30 11:10 [Tarantool-patches] [PATCH] " Chris Sosnin
2020-02-03 22:17 ` Vladislav Shpilevoy
2020-02-04 19:32 ` [Tarantool-patches] [PATCH 4/4] " Chris Sosnin
2020-02-06 22:16 ` Vladislav Shpilevoy
2020-02-07 9:40 ` Chris Sosnin
2020-02-10 22:09 ` Vladislav Shpilevoy
2020-02-17 11:46 ` Chris Sosnin [this message]
2020-02-17 11:56 ` Nikita Pettik
2020-02-17 12:12 [Tarantool-patches] [PATCH 0/4] box: session settings fixes Chris Sosnin
2020-02-17 12:12 ` [Tarantool-patches] [PATCH 4/4] sql: provide a user friendly frontend for accessing session settings Chris Sosnin
2020-03-16 17:02 ` Nikita Pettik
2020-03-16 22:53 ` Vladislav Shpilevoy
2020-03-17 17:26 ` Chris Sosnin
2020-03-17 20:12 ` Nikita Pettik
2020-03-17 21:00 ` Chris Sosnin
2020-03-18 10:00 ` Chris Sosnin
2020-03-30 9:13 [Tarantool-patches] [PATCH 0/4] session settings fixes Chris Sosnin
2020-03-30 9:13 ` [Tarantool-patches] [PATCH 4/4] sql: provide a user friendly frontend for accessing session settings Chris Sosnin
2020-04-03 15:19 ` Nikita Pettik
2020-04-04 21:56 ` Vladislav Shpilevoy
2020-04-10 15:40 ` Chris Sosnin
2020-04-11 17:18 ` Vladislav Shpilevoy
2020-04-13 7:50 ` Timur Safin
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=DEE17776-4A55-43B9-8714-1B51F50BE112@tarantool.org \
--to=k.sosnin@tarantool.org \
--cc=korablev@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 4/4] sql: provide a user friendly frontend for accessing session settings' \
/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