From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 8D08227F8C for ; Fri, 22 Feb 2019 08:41:00 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cOjA_lZtj8LH for ; Fri, 22 Feb 2019 08:41:00 -0500 (EST) 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 turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 4731826311 for ; Fri, 22 Feb 2019 08:41:00 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: [tarantool-patches] Re: [PATCH 2/2] sql: compute resulting collation for concatenation From: "n.pettik" In-Reply-To: <57ca444c-96d3-bd85-9137-26d408200d1b@tarantool.org> Date: Fri, 22 Feb 2019 16:40:58 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <652a9e6a4514a03ef93133961b09c2f5d45721d8.1547644180.git.korablev@tarantool.org> <0c99e4e0-972a-2013-45b1-5c60747ee2ef@tarantool.org> <5AD6A399-D158-44CF-9180-F57185F2C376@tarantool.org> <57ca444c-96d3-bd85-9137-26d408200d1b@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: Vladislav Shpilevoy >>>> + bool is_rhs_forced; >>>> + uint32_t rhs_coll_id; >>>> + if (sql_expr_coll(parse, p->pRight, = &is_rhs_forced, >>>> + &rhs_coll_id) !=3D 0) >>>> + return -1; >>>> + if (is_lhs_forced && is_rhs_forced) { >>>> + if (lhs_coll_id !=3D rhs_coll_id) >>>> + return -1; >>>=20 >>> 5. Did you miss diag_set? >> No, I did it on purpose. Firstly, this function is recursive, >> so in case error occurred on bottom levels of recursion, >> diag would be reseted on each level above (and parser=E2=80=99s >> counter of errors would be incremented several times as >> well). No terrible consequences would take place in this case, >> but it looks like a bad pattern. Anyway, fixed it according to >> your suggestion. >=20 > Each ClientError is accounted in a global errors counter. It > means, that the same error should be set multiple times, otherwise > the statistics would be wrong. Instead of resetting diag each time > check if parser->nErr > 0, and if it is, then do nothing. > diag_is_empty() can not be used, because it happens sometimes, that > there are no errors, but diag is not cleared from a previous error. Hmm, Mergen is trying to remove nErr, if I=E2=80=99m not mistaken. So, soon I guess we will be able to use diag_is_empty(). Now I=E2=80=99ve implemented your suggestion. Diff: diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c index 680075792..0de9a46a5 100644 --- a/src/box/sql/expr.c +++ b/src/box/sql/expr.c @@ -246,10 +246,17 @@ sql_expr_coll(Parse *parse, Expr *p, bool = *is_explicit_coll, uint32_t *coll_id, return -1; if (is_lhs_forced && is_rhs_forced) { if (lhs_coll_id !=3D rhs_coll_id) { - diag_set(ClientError, - = ER_ILLEGAL_COLLATION_MIX); - parse->nErr++; - parse->rc =3D = SQL_TARANTOOL_ERROR; + /* + * Don't set the same error + * several times: this + * function is recursive. + */ + if (parse->nErr =3D=3D 0) { + diag_set(ClientError, + = ER_ILLEGAL_COLLATION_MIX); + parse->nErr++; + parse->rc =3D = SQL_TARANTOOL_ERROR; + } return -1; } }=