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 263CC2BBF9 for ; Wed, 15 May 2019 09:18:54 -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 w-3oH5RnLR0b for ; Wed, 15 May 2019 09:18:54 -0400 (EDT) Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 DABF82B604 for ; Wed, 15 May 2019 09:18:53 -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 04/12] sql: make SQL_TARANTOOL_ERROR the only errcode of OP_Halt From: "n.pettik" In-Reply-To: <15369cd674c3a454e66470edfa19f540c81b9dd0.1557056617.git.imeevma@gmail.com> Date: Wed, 15 May 2019 16:18:52 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <15369cd674c3a454e66470edfa19f540c81b9dd0.1557056617.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 5 May 2019, at 15:17, imeevma@tarantool.org wrote: >=20 > Currently, in OP_Halt, you can get a SQL error other than > SQL_TARANTOOL_ERROR, for example, the SQL_CONSTRAINT error. After > this patch, all errors going through OP_Halt will have SQL error > code SQL_TARANTOOL_ERROR and have diag set. >=20 > diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c > index 9f0d760..85cec85 100644 > --- a/src/box/sql/vdbe.c > +++ b/src/box/sql/vdbe.c > @@ -1031,25 +1031,10 @@ 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 NULL) > - diag_set(ClientError, pOp->p5, = pOp->p4.z); > - assert(! diag_is_empty(diag_get())); > - } 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); > - } > - } else { > - sqlVdbeError(p, "%s", pOp->p4.z); > - } > - sql_log(pOp->p1, "abort at %d in [%s]: %s", pcx, = p->zSql, p->zErrMsg); > + assert(p->rc =3D=3D SQL_TARANTOOL_ERROR); Still don=E2=80=99t understand why can=E2=80=99t we use only 0/-1 for = rc. > + 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); > --=20 > 2.7.4 >=20 >=20