Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH 0/4] session settings fixes
@ 2020-03-30  9:13 Chris Sosnin
  2020-03-30  9:13 ` [Tarantool-patches] [PATCH 1/4] box: replace session_settings modules with a single array Chris Sosnin
                   ` (6 more replies)
  0 siblings, 7 replies; 33+ messages in thread
From: Chris Sosnin @ 2020-03-30  9:13 UTC (permalink / raw)
  To: v.shpilevoy, korablev, tarantool-patches

issue #1:https://github.com/tarantool/tarantool/issues/4711
issue #2:https://github.com/tarantool/tarantool/issues/4712
branch:https://github.com/tarantool/tarantool/tree/ksosnin/gh-4712-session-settings-v2

Chris Sosnin (4):
  box: replace session_settings modules with a single array
  box: add binary search for _session_settings space
  box: provide a user friendly frontend for accessing session settings
  sql: provide a user friendly frontend for accessing session settings

 extra/mkkeywordhash.c                         |   1 +
 src/box/lua/session.c                         | 111 +++++++++
 src/box/session.cc                            |   1 +
 src/box/session.h                             |   2 +
 src/box/session_settings.c                    | 214 +++++++++++-------
 src/box/session_settings.h                    |  53 +++--
 src/box/sql.c                                 |   5 -
 src/box/sql/build.c                           | 104 ++++-----
 src/box/sql/parse.y                           |   5 +
 src/box/sql/sqlInt.h                          |  11 +
 src/box/sql/vdbe.c                            |  50 ++++
 ...rontend.result => session_settings.result} | 147 ++++++++++--
 ...end.test.lua => session_settings.test.lua} |  61 ++++-
 13 files changed, 589 insertions(+), 176 deletions(-)
 rename test/box/{gh-4511-access-settings-from-any-frontend.result => session_settings.result} (71%)
 rename test/box/{gh-4511-access-settings-from-any-frontend.test.lua => session_settings.test.lua} (64%)

-- 
2.21.1 (Apple Git-122.3)

^ permalink raw reply	[flat|nested] 33+ messages in thread
* [Tarantool-patches] [PATCH 0/4] box: session settings fixes
@ 2020-02-17 12:12 Chris Sosnin
  2020-02-17 12:12 ` [Tarantool-patches] [PATCH 4/4] sql: provide a user friendly frontend for accessing session settings Chris Sosnin
  0 siblings, 1 reply; 33+ messages in thread
From: Chris Sosnin @ 2020-02-17 12:12 UTC (permalink / raw)
  To: korablev, tarantool-patches

The first patch just merges all modules into one array, so the
binary search will work once for all settings.

The second patch is implementation of the binary search.

The last two patches add frontend for accessing session settings:
Lua table and SQL statement respectively.

branch: https://github.com/tarantool/tarantool/tree/ksosnin/gh-4712-search-settings
issue #1: https://github.com/tarantool/tarantool/issues/4711
issue #2: https://github.com/tarantool/tarantool/issues/4712

Chris Sosnin (4):
  box: replace session_settings modules with a single array
  box: add binary search for _session_settings space
  box: provide a user friendly frontend for accessing session settings
  sql: provide a user friendly frontend for accessing session settings

 src/box/lua/session.c                         |  92 ++++++++
 src/box/session.cc                            |   1 +
 src/box/session.h                             |   2 +
 src/box/session_settings.c                    | 214 +++++++++++-------
 src/box/session_settings.h                    |  53 +++--
 src/box/sql.c                                 |   5 -
 src/box/sql/build.c                           | 104 ++++-----
 src/box/sql/parse.y                           |   5 +
 src/box/sql/sqlInt.h                          |  11 +
 src/box/sql/vdbe.c                            |  50 ++++
 ...rontend.result => session_settings.result} | 149 ++++++++++--
 ...end.test.lua => session_settings.test.lua} |  61 ++++-
 12 files changed, 571 insertions(+), 176 deletions(-)
 rename test/box/{gh-4511-access-settings-from-any-frontend.result => session_settings.result} (71%)
 rename test/box/{gh-4511-access-settings-from-any-frontend.test.lua => session_settings.test.lua} (65%)

-- 
2.21.1 (Apple Git-122.3)

^ permalink raw reply	[flat|nested] 33+ messages in thread
* Re: [Tarantool-patches] [PATCH] sql: provide a user friendly frontend for accessing session settings
@ 2020-02-03 22:17 Vladislav Shpilevoy
  2020-02-04 19:32 ` [Tarantool-patches] [PATCH 4/4] " Chris Sosnin
  0 siblings, 1 reply; 33+ messages in thread
From: Vladislav Shpilevoy @ 2020-02-03 22:17 UTC (permalink / raw)
  To: Chris Sosnin, tarantool-patches

Thanks for the patch!

See 4 comments below.

On 30/01/2020 12:10, Chris Sosnin wrote:
> 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
> ---
> This patch is a follow-up for session settings patchset.
> 
> issue:https://github.com/tarantool/tarantool/issues/4711
> branch:https://github.com/tarantool/tarantool/tree/ksosnin/gh-4712-search-settings
> 
>  src/box/sql/build.c                           | 31 ++++++++++++
>  src/box/sql/parse.y                           |  5 ++
>  src/box/sql/sqlInt.h                          | 11 +++++
>  src/box/sql/vdbe.c                            | 45 +++++++++++++++++
>  ...1-access-settings-from-any-frontend.result | 49 +++++++++++++++++++
>  ...access-settings-from-any-frontend.test.lua | 13 +++++
>  6 files changed, 154 insertions(+)
> 
> diff --git a/src/box/sql/build.c b/src/box/sql/build.c
> index 7dcf7b858..cb7733cfc 100644
> --- a/src/box/sql/build.c
> +++ b/src/box/sql/build.c
> @@ -3474,3 +3474,34 @@ sql_session_settings_init()
>  		setting->set = sql_session_setting_set;
>  	}
>  }
> +
> +void
> +sql_set_setting(struct Parse *parse_context, struct Token *name,
> +		struct Expr *value)
> +{
> +	struct Vdbe *vdbe = sqlGetVdbe(parse_context);
> +	assert(vdbe != NULL);
> +	sqlVdbeCountChanges(vdbe);
> +	char *key = sql_name_from_token(sql_get(), name);
> +	if (key == NULL)
> +		goto abort;
> +	int low = 0, high = session_setting_MAX - 1;
> +	while (low <= high) {
> +		int index = (high + low) / 2;
> +		int cmp = strcasecmp(session_settings[index].name, key);

1. All other places in SQL are case sensitive. I don't think this
place should be an exception.

> +		if (cmp == 0) {
> +			sqlVdbeAddOp4(vdbe, OP_Set, index, 0, 0,
> +				      (const char *)value, P4_PTR);

2. 1) struct Expr is a parsing stage object, it should not exist during
execution, 2) it is generally a bad practice to save an object by a
pointer, because that makes VDBE harder to serialize in future, when we
will expropriate VDBE generation into a library. You should encode
the expression as a set of VDBE operations storing result into a register,
from where SET would read it. Ideally, it would support '?' parameters.
See sqlExprCode().

> +			return;
> +		}
> +		if (cmp < 0)
> +			low = index + 1;
> +		else
> +			high = index - 1;
> +	}

3. Well, why not to expose session_settings_set_forward() into
session_settings.h header and use it here?

> +	diag_set(ClientError, ER_SQL_PARSER_GENERIC,
> +		 tt_sprintf("Session setting %s doesn't exist", key));
> +abort:
> +	parse_context->is_aborted = true;
> +	return;
> +}
> 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 1c3ca7661..0597365a1 100644
> --- a/test/box/gh-4511-access-settings-from-any-frontend.result
> +++ b/test/box/gh-4511-access-settings-from-any-frontend.result
> @@ -343,6 +343,39 @@ settings.sql_defer_foreign_keys
>   | - false
>   | ...
>  
> +box.execute([[set sql_default_engine = 'vinyl']])
> + | ---
> + | - row_count: 1
> + | ...
> +assert(s:get('sql_default_engine').value == 'vinyl')

4. Please, avoid calling assert. Because in case it will fail,
you won't get the real value, and it will be harder to debug.
Especially if that test will become flaky some day. Assert is ok,
if you know for sure what the other value is, or when there is a
function/cycle, which can't print directly to the output.

> + | ---
> + | - true
> + | ...
> +box.execute([[set sql_default_engine = 'memtx']])
> + | ---
> + | - row_count: 1
> + | ...
> +assert(s:get('sql_default_engine').value == 'memtx')
> + | ---
> + | - true
> + | ...
> +box.execute([[set sql_defer_foreign_keys = true]])
> + | ---
> + | - row_count: 1
> + | ...
> +assert(s:get('sql_defer_foreign_keys').value == true)
> + | ---
> + | - true
> + | ...
> +box.execute([[set sql_defer_foreign_keys = false]])
> + | ---
> + | - row_count: 1
> + | ...
> +assert(s:get('sql_defer_foreign_keys').value == false)
> + | ---
> + | - true
> + | ...
> +

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2020-04-13 14:18 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30  9:13 [Tarantool-patches] [PATCH 0/4] session settings fixes Chris Sosnin
2020-03-30  9:13 ` [Tarantool-patches] [PATCH 1/4] box: replace session_settings modules with a single array Chris Sosnin
2020-04-03 13:32   ` Nikita Pettik
2020-03-30  9:13 ` [Tarantool-patches] [PATCH 2/4] box: add binary search for _session_settings space Chris Sosnin
2020-04-03 14:00   ` Nikita Pettik
2020-04-13 13:40     ` Kirill Yukhin
2020-03-30  9:13 ` [Tarantool-patches] [PATCH 3/4] box: provide a user friendly frontend for accessing session settings Chris Sosnin
2020-04-03 14:47   ` Nikita Pettik
2020-03-30  9:13 ` [Tarantool-patches] [PATCH 4/4] sql: " 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
2020-04-02  9:14 ` [Tarantool-patches] [PATCH 0/4] session settings fixes Timur Safin
2020-04-02 10:18   ` Chris Sosnin
2020-04-03 12:47   ` Nikita Pettik
2020-04-03 13:09 ` Nikita Pettik
2020-04-03 14:02   ` Chris Sosnin
2020-04-13 14:18 ` Kirill Yukhin
  -- strict thread matches above, loose matches on Subject: below --
2020-02-17 12:12 [Tarantool-patches] [PATCH 0/4] box: " 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-02-03 22:17 [Tarantool-patches] [PATCH] " 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
2020-02-17 11:56           ` Nikita Pettik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox