From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp60.i.mail.ru (smtp60.i.mail.ru [217.69.128.40]) (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 C5C4C4696C3 for ; Fri, 3 Apr 2020 18:19:37 +0300 (MSK) Date: Fri, 3 Apr 2020 15:19:36 +0000 From: Nikita Pettik Message-ID: <20200403151936.GG2993@tarantool.org> References: <68bbb40b963e1c4ef4a1950a01e67453fc252347.1585559306.git.k.sosnin@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <68bbb40b963e1c4ef4a1950a01e67453fc252347.1585559306.git.k.sosnin@tarantool.org> 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 Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org 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.