[Tarantool-patches] [PATCH 4/4] sql: provide a user friendly frontend for accessing session settings

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sun Apr 5 00:56:39 MSK 2020


Hi! Thanks for the patch!

> diff --git a/src/box/sql/build.c b/src/box/sql/build.c
> index a00da31f9..cdcf8b6d8 100644
> --- a/src/box/sql/build.c
> +++ b/src/box/sql/build.c
> @@ -3481,3 +3481,28 @@ sql_session_settings_init()
>  		setting->set = sql_session_setting_set;
>  	}
>  }
> +
> +void
> +sql_setting_set(struct Parse *parse_context, struct Token *name,
> +		struct Expr *expr)
> +{
> +	struct Vdbe *vdbe = sqlGetVdbe(parse_context);
> +	if (vdbe == NULL)
> +		goto abort;
> +	sqlVdbeCountChanges(vdbe);
> +	char *key = sql_name_from_token(parse_context->db, name);
> +	if (key == NULL)
> +		goto abort;
> +	int index = session_setting_find(key);

I agree with Nikita. Better make this call part of OP_SetSetting.

> +	if (index >= 0) {
> +		int target = ++parse_context->nMem;
> +		sqlExprCode(parse_context, expr, target);
> +		sqlVdbeAddOp2(vdbe, OP_SetSetting, index, target);
> +		return;
> +	}
> +	diag_set(ClientError, ER_SQL_PARSER_GENERIC,
> +		 tt_sprintf("Session setting %s doesn't exist", key));
> +abort:
> +	parse_context->is_aborted = true;
> +	return;
> +}

Talking of the syntax, I don't have a strong opinion here
regarding any particular option. I only want the new statement
be short, and not involving _session_settings manipulations.


More information about the Tarantool-patches mailing list