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 A87982D9F2 for ; Sun, 19 May 2019 10:38:20 -0400 (EDT) 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 PN-qtzMTFkHr for ; Sun, 19 May 2019 10:38:20 -0400 (EDT) Received: from smtp43.i.mail.ru (smtp43.i.mail.ru [94.100.177.103]) (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 E90EA2D935 for ; Sun, 19 May 2019 10:38:19 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: [tarantool-patches] Re: [PATCH v1 1/1] sql: rework SQL errors of type "expected column count" From: "n.pettik" In-Reply-To: <461ca6b5a31331d36ef7d23872613f0b1c0de9d0.1558176783.git.imeevma@gmail.com> Date: Sun, 19 May 2019 17:38:16 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <70E77545-041F-418E-828C-335A449EF4A6@tarantool.org> References: <461ca6b5a31331d36ef7d23872613f0b1c0de9d0.1558176783.git.imeevma@gmail.com> 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: Imeev Mergen > On 18 May 2019, at 13:53, imeevma@tarantool.org wrote: >=20 > This patch reworks SQL errors of type "expected column count=E2=80=9D. Please, provide decent description of the patch. > diff --git a/src/box/errcode.h b/src/box/errcode.h > index 9c15f33..789556a 100644 > --- a/src/box/errcode.h > +++ b/src/box/errcode.h > @@ -247,6 +247,7 @@ struct errcode_record { > /*192 */_(ER_INDEX_DEF_UNSUPPORTED, "%s are prohibited in an = index definition") \ > /*193 */_(ER_CK_DEF_UNSUPPORTED, "%s are prohibited in a = CHECK constraint definition") \ > /*194 */_(ER_MULTIKEY_INDEX_MISMATCH, "Field %s is used as = multikey in one index and as single key in another") \ > + /*195 */_(ER_SQL_COLUMN_COUNT, "Left value column count = %u does not match the expected column count (%u)") \ -> ER_SQL_ROW_EXPRESSION I would re-phrase message to smth like this: =E2=80=9CMisuse of row expression: left side of row value has %u = entries, but right side - %u=E2=80=9D =E2=80=9CUnequal number of entries in row expression: left side has %u, = but right side - %u=E2=80=9D > /* > * !IMPORTANT! Please follow instructions at start of the file > diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c > index ba7eea5..8cf4d2e 100644 > --- a/src/box/sql/expr.c > +++ b/src/box/sql/expr.c > @@ -2958,28 +2958,22 @@ sqlCodeSubselect(Parse * pParse, /* = Parsing context */ > * Expr pIn is an IN(...) expression. This function checks that the > * sub-select on the RHS of the IN() operator has the same number of > * columns as the vector on the LHS. Or, if the RHS of the IN() is not > - * a sub-query, that the LHS is a vector of size 1. > + * a sub-query, that the LHS must be a vector of size 1. What is the point of changing this comment? > */ > int > sqlExprCheckIN(Parse * pParse, Expr * pIn) > { > int nVector =3D sqlExprVectorSize(pIn->pLeft); > - const char *err; > if ((pIn->flags & EP_xIsSelect)) { > if (nVector !=3D pIn->x.pSelect->pEList->nExpr) { > - err =3D "sub-select returns %d columns - = expected %d"; > int expr_count =3D = pIn->x.pSelect->pEList->nExpr; > - diag_set(ClientError, ER_SQL_PARSER_GENERIC, > - tt_sprintf(err, expr_count, nVector)); > + diag_set(ClientError, ER_SQL_COLUMN_COUNT, = nVector, > + expr_count); > pParse->is_aborted =3D true; > return 1; > } > } else if (nVector !=3D 1) { > - assert((pIn->pLeft->flags & EP_xIsSelect) !=3D 0); > - int expr_count =3D pIn->pLeft->x.pSelect->pEList->nExpr; > - err =3D tt_sprintf("sub-select returns %d columns - = expected 1", > - expr_count); > - diag_set(ClientError, ER_SQL_PARSER_GENERIC, err); > + diag_set(ClientError, ER_SQL_COLUMN_COUNT, nVector, 1); > pParse->is_aborted =3D true; > return 1; > } >=20