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 36F972446A for ; Mon, 15 Jul 2019 09:08:28 -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 WrnBbp0PIg-g for ; Mon, 15 Jul 2019 09:08:28 -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 825462445D for ; Mon, 15 Jul 2019 09:08:27 -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 v3 1/3] sql: add OP_SetDiag opcode in VDBE From: "n.pettik" In-Reply-To: <0a0f232c4c4c7068df8514230c149bc953a080a5.1562235700.git.imeevma@gmail.com> Date: Mon, 15 Jul 2019 16:08:24 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <4BC2F02A-F568-4061-A921-AFF7D01D8AC5@tarantool.org> References: <0a0f232c4c4c7068df8514230c149bc953a080a5.1562235700.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 >>>>> + */ >>>>> +case OP_Error: { /* jump */ >>>>> + box_error_set(__FILE__, __LINE__, pOp->p1, pOp->p4.z); >>>>=20 >>>> Why not simple diag_set() ? >>>>=20 >>> I did it like this because using diag_set() would be a bit >>> troublesome if we decided to use an argument of a different type >>> or more than one argument. >>=20 >> Do not understand what you mean. Could you provide >> some examples? >>=20 > Sorry, I can't. But I have beed said so by Vlad: >=20 > On 6/2/19 7:35 PM, Vladislav Shpilevoy wrote: >> There was a concrete reason, why it was possible - because different >> error codes have different arguments of various types, and the only = way >> to set an error at parsing stage is to allow to set arbitrary error >> message to any error code. Without '...', va_arg etc. Besides, we = could >> use it to set correct line number and function name in future. Now = you >> use diag_set, which restricts us. >>=20 >> So why do you need that patch? We will need to revert it when an = error >> appears requiring more than one argument, or an argument of not >> const char * type. That will definitely happen. >>=20 >=20 > It can be ween here: > = https://www.freelists.org/post/tarantool-patches/PATCH-v1-49-sql-rework-di= ag-set-in-OP-Halt,1 Ok, now it=E2=80=99s clear: it allows us to construct string containing error message during parsing stage, so that we avoid argument substitution in diag_set(). It is vital since "error codes have different arguments of various types=E2=80=9D. >>> Needed for #4183 >>>=20 >>> diff --git a/src/box/sql/build.c b/src/box/sql/build.c >>> index 292168f..aab60dd 100644 >>> --- a/src/box/sql/build.c >>> +++ b/src/box/sql/build.c >>> @@ -3277,15 +3277,15 @@ vdbe_emit_halt_with_presence_test(struct = Parse *parser, int space_id, >>> int cursor =3D parser->nTab++; >>> vdbe_emit_open_cursor(parser, cursor, index_id, = space_by_id(space_id)); >>> sqlVdbeChangeP5(v, OPFLAG_SYSTEMSP); >>> - int label =3D sqlVdbeCurrentAddr(v); >>> - sqlVdbeAddOp4Int(v, cond_opcode, cursor, label + 3, key_reg, >>> - key_len); >>> + int jmp =3D sqlVdbeAddOp4Int(v, cond_opcode, cursor, 0, key_reg, = key_len); >>> if (no_error) { >>> sqlVdbeAddOp0(v, OP_Halt); >>> } else { >>> - sqlVdbeAddOp4(v, OP_Halt, -1, 0, tarantool_error_code, error, >>> + sqlVdbeAddOp4(v, OP_SetDiag, tarantool_error_code, 0, 0, error, >>> P4_DYNAMIC); >>> + sqlVdbeAddOp1(v, OP_Halt, -1); >>> } >>> + sqlVdbeJumpHere(v, jmp); >>=20 >> Are these manipulations with labels related to patch? >> =E2=80=98label=E2=80=99 or =E2=80=98addr' are more appropriate names = IMHO. >>=20 > I think that these manipulations should be done, since in this > patch we should jump to different lengths depending on the value > of no_error. This will be even more severe after the next patch. Ok, now I see. This patch LGTM.