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 276452743C for ; Tue, 27 Aug 2019 12:40:52 -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 cJnm-OJPn0Kf for ; Tue, 27 Aug 2019 12:40:52 -0400 (EDT) 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 DD67F27002 for ; Tue, 27 Aug 2019 12:40:51 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: [tarantool-patches] Re: [PATCH] sql: Change token/opcode relation assertions to static From: "n.pettik" In-Reply-To: <20190823154958.20837-1-zavodchen@gmail.com> Date: Tue, 27 Aug 2019 19:40:50 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20190823154958.20837-1-zavodchen@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: Alexey Zavodchenkov > There are several token/opcode relative positions assertions in the = sql codebase > and those tokens/opcodes are defined before the source compilation. > So it is possible to change those assertions to static ones. >=20 > Closes: #4240 >=20 > Issue: https://github.com/tarantool/tarantool/issues/4240 > Commit in the fork: = https://github.com/Separador/tarantool/commit/d36d7c8080 Hello, Nit: please, put links to issue and branch below delimiter --- Unfortunately, I failed to apply your patch neither using git am nor git apply. Make sure that you are using git format-patch utility and don=E2=80=99t manually change patch context. > --- > src/box/sql/expr.c | 105 ++++++++++++++++++++++++++-------------- > src/box/sql/vdbe.c | 33 ++++++++----- > src/box/sql/whereexpr.c | 29 +++++++---- > 3 files changed, 111 insertions(+), 56 deletions(-) >=20 > diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c > index 1f9d91705..668562896 100644 > --- a/src/box/sql/expr.c > +++ b/src/box/sql/expr.c > @@ -3839,22 +3839,28 @@ sqlExprCodeTarget(Parse * pParse, Expr * = pExpr, int target) > ®Free2); > codeCompare(pParse, pLeft, = pExpr->pRight, op, > r1, r2, inReg, SQL_STOREP2); > - assert(TK_LT =3D=3D OP_Lt); > + static_assert(TK_LT =3D=3D OP_Lt, > + "inconsistent token/opcode = definition"); > testcase(op =3D=3D OP_Lt); > VdbeCoverageIf(v, op =3D=3D OP_Lt); > - assert(TK_LE =3D=3D OP_Le); > + static_assert(TK_LE =3D=3D OP_Le, > + "inconsistent token/opcode = definition=E2=80=9D); Nit: I=E2=80=99d group and move out of function all these assertion to = the one place. For instance, asserts in sqlExprCodeTarget() and sqlExprIfTrue() verify that token TK_XX corresponds to OP_Xx opcode. Hence let's move them, before definition of sqlExprCodeTarget(). The same applies for group of assertions in VDBE verifying relative = opcode =20 positions and in query planner (whereexpr.c) checking relative token = positions.