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 DF6422B0B6 for ; Mon, 15 Apr 2019 11:19:37 -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 q-Kh86jMuol8 for ; Mon, 15 Apr 2019 11:19:37 -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 01F822B069 for ; Mon, 15 Apr 2019 11:19:36 -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 3/3] sql: make SQL_TARANTOOL_ERROR the only errcode of OP_Halt From: "n.pettik" In-Reply-To: <2b1c4f5e030ffa41069a3839f6ba39826ea739e1.1555072183.git.imeevma@gmail.com> Date: Mon, 15 Apr 2019 18:19:34 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <2b1c4f5e030ffa41069a3839f6ba39826ea739e1.1555072183.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 'make ... the only errcode of OP_Halt=E2=80=99 -> make =E2=80=A6 be the only ... > On 12 Apr 2019, at 15:34, imeevma@tarantool.org wrote: >=20 > After this patch, the only error code that the OP_Halt opcode > will work with is SQL_TARANTOOL_ERROR. So, why do we need it at all now? Let=E2=80=99s use simple flag is_aborted like in parser. >=20 > Part of #4074 > --- > src/box/sql/build.c | 20 -------------------- > src/box/sql/expr.c | 7 ++++--- > src/box/sql/fk_constraint.c | 7 +++---- > src/box/sql/insert.c | 29 ++++++++++++++--------------- > src/box/sql/sqlInt.h | 1 - > src/box/sql/vdbe.c | 23 ++++------------------- > 6 files changed, 25 insertions(+), 62 deletions(-) >=20 >=20 > diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c > index eb08f7e..ba41837 100644 > --- a/src/box/sql/expr.c > +++ b/src/box/sql/expr.c > @@ -4409,9 +4409,10 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, = int target) > ON_CONFLICT_ACTION_IGNORE, 0, > pExpr->u.zToken, 0); > } else { > - sqlHaltConstraint(pParse, = SQL_CONSTRAINT_TRIGGER, > - pExpr->on_conflict_action, > - pExpr->u.zToken, 0, 0); > + sqlVdbeAddOp4(v, OP_Halt, SQL_TARANTOOL_ERROR, > + pExpr->on_conflict_action, 0, > + pExpr->u.zToken, 0); > + sqlVdbeChangeP5(v, ER_SQL_EXECUTE); Are there any other options for P5 argument, except for ER_SQL_EXECUTE? If not so, let=E2=80=99s always assume it is ER_SQL_EXECUTE and avoid passing extra argument. >=20 > diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c > index 3d20aa9..a9c3f68 100644 > --- a/src/box/sql/vdbe.c > +++ b/src/box/sql/vdbe.c > @@ -1069,27 +1069,12 @@ case OP_Halt: { > p->errorAction =3D (u8)pOp->p2; > p->pc =3D pcx; > if (p->rc) { > - if (p->rc =3D=3D SQL_TARANTOOL_ERROR) { > - if (pOp->p4.z =3D=3D NULL) { > - assert(! diag_is_empty(diag_get())); > - } else { > - diag_set(ClientError, pOp->p5, = pOp->p4.z); > - } > - } else if (pOp->p5 !=3D 0) { > - static const char * const azType[] =3D { "NOT = NULL", "UNIQUE", "CHECK", > - "FOREIGN = KEY" }; > - testcase( pOp->p5=3D=3D1); > - testcase( pOp->p5=3D=3D2); > - testcase( pOp->p5=3D=3D3); > - testcase( pOp->p5=3D=3D4); > - sqlVdbeError(p, "%s constraint failed", = azType[pOp->p5-1]); > - if (pOp->p4.z) { > - p->zErrMsg =3D sqlMPrintf(db, "%z: %s", = p->zErrMsg, pOp->p4.z); > - } > + assert(p->rc =3D=3D SQL_TARANTOOL_ERROR); > + if (pOp->p4.z =3D=3D NULL) { > + assert(! diag_is_empty(diag_get())); > } else { > - sqlVdbeError(p, "%s", pOp->p4.z); > + diag_set(ClientError, pOp->p5, pOp->p4.z); > } diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index a9c3f688e..673d6a73f 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -1070,11 +1070,9 @@ case OP_Halt: { p->pc =3D pcx; if (p->rc) { assert(p->rc =3D=3D SQL_TARANTOOL_ERROR); - if (pOp->p4.z =3D=3D NULL) { - assert(! diag_is_empty(diag_get())); - } else { + if (pOp->p4.z !=3D NULL) diag_set(ClientError, pOp->p5, pOp->p4.z); - } + assert(! diag_is_empty(diag_get())); } rc =3D sqlVdbeHalt(p); assert(rc=3D=3DSQL_BUSY || rc=3D=3DSQL_OK || rc=3D=3DSQL_ERROR);