From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 B41014696C3 for ; Sun, 5 Apr 2020 00:56:41 +0300 (MSK) References: <68bbb40b963e1c4ef4a1950a01e67453fc252347.1585559306.git.k.sosnin@tarantool.org> From: Vladislav Shpilevoy Message-ID: <736e6bf5-aea4-ffe4-be7b-2dcc9539065a@tarantool.org> Date: Sat, 4 Apr 2020 23:56:39 +0200 MIME-Version: 1.0 In-Reply-To: <68bbb40b963e1c4ef4a1950a01e67453fc252347.1585559306.git.k.sosnin@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH 4/4] sql: provide a user friendly frontend for accessing session settings List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chris Sosnin , korablev@tarantool.org, tarantool-patches@dev.tarantool.org 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.