From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp36.i.mail.ru (smtp36.i.mail.ru [94.100.177.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id C51FE46970E for ; Sat, 1 Feb 2020 20:40:17 +0300 (MSK) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3594.4.19\)) From: Roman Khabibov In-Reply-To: <20200128174449.GB1049@tarantool.org> Date: Sat, 1 Feb 2020 20:40:16 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <0d014c80710b24bcfc6380957fcc90b955536599.1579874461.git.roman.habibov@tarantool.org> <20200128174449.GB1049@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH 1/2] sql: refactor index drop code List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nikita Pettik Cc: tarantool-patches@dev.tarantool.org > On Jan 28, 2020, at 20:44, Nikita Pettik = wrote: >=20 > On 24 Jan 17:21, Roman Khabibov wrote: >> Wrap index drop opcode emitting into single function. >>=20 >> Part of #4120 >> --- >> src/box/sql/build.c | 52 = ++++++++++++++++++++++++--------------------- >> 1 file changed, 28 insertions(+), 24 deletions(-) >>=20 >> diff --git a/src/box/sql/build.c b/src/box/sql/build.c >> index bc50ecbfa..58a6a8a6b 100644 >> --- a/src/box/sql/build.c >> +++ b/src/box/sql/build.c >> @@ -1469,6 +1469,26 @@ vdbe_emit_stat_space_clear(struct Parse = *parse, const char *stat_table_name, >> sql_table_delete_from(parse, src_list, where); >> } >>=20 >> +/** >> + * Generate VDBE program to remove entry with @a index_id and @a >> + * space_id from _index space. >=20 > Is @a common shortcat for @param? If so, please share a link to docs, > since I've managed to find only this: > ''' > \a > Displays the argument in italics. Use this command to emphasize words. > Use this command to refer to member arguments in the running text. > ''' >=20 >> + * Note: index_id_reg have to be allocated immediately after >> + * space_id_reg. >> + */ >=20 > Nit: have -> has. >=20 > Please, add an assertion verifing that. >=20 >> +static void >> +vdbe_emit_index_drop(struct Parse *parse_context, uint32_t index_id, >> + uint32_t index_id_reg, uint32_t space_id_reg) >=20 > I'd also consider moving storing of index_id to register out of > this function. Then you'll need only space_id_reg to process > deletion. I decided to drop this patch, because the function will be too small and it will not reduce the code. So, IMO, it is pointless then. >> +{ >> + struct Vdbe *v =3D sqlGetVdbe(parse_context); >> + assert(v !=3D NULL); >> + int record_reg =3D ++parse_context->nMem; >> + sqlVdbeAddOp2(v, OP_Integer, index_id, index_id_reg); >> + sqlVdbeAddOp3(v, OP_MakeRecord, space_id_reg, 2, record_reg); >> + sqlVdbeAddOp2(v, OP_SDelete, BOX_INDEX_ID, record_reg); >> + VdbeComment((v, "Remove index iid =3D %u", index_id)); >> +} >> + >> /** >> * Generate VDBE program to remove entry from _fk_constraint space. >> *