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

Nikita Pettik korablev at tarantool.org
Fri Apr 3 18:19:36 MSK 2020


On 30 Mar 12:13, Chris Sosnin wrote:
> 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);
> +	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));

Mb it is worth moving this check to runtime? I.e. pass to OP_SetSetting
name of setting to be set. The less appeals to system spaces and
cache look ups are made, the better parsing process is organized.

The rest is ok.



More information about the Tarantool-patches mailing list