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 A778324466 for ; Mon, 14 Jan 2019 09:06:00 -0500 (EST) 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 VVmL2VtyHcP8 for ; Mon, 14 Jan 2019 09:06:00 -0500 (EST) Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (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 6370323FE7 for ; Mon, 14 Jan 2019 09:06:00 -0500 (EST) Subject: [tarantool-patches] Re: [PATCH 4/6] sql: refactor getNewIid() function References: From: Vladislav Shpilevoy Message-ID: Date: Mon, 14 Jan 2019 17:05:50 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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, Nikita Pettik Thanks for the patch! See 1 comment below. On 09/01/2019 15:13, Nikita Pettik wrote: > This commit includes no functional changes. Lets simply rewrite > getNewIid() function according to Tarantool codestyle. > > Part of #3914 > --- > src/box/sql/build.c | 72 ++++++++++++++++++++++++++--------------------------- > 1 file changed, 35 insertions(+), 37 deletions(-) > > diff --git a/src/box/sql/build.c b/src/box/sql/build.c > index 9d31cb736..ca9d469fd 100644 > --- a/src/box/sql/build.c > +++ b/src/box/sql/build.c > - /* Fetch iid from the row and ++it. */ > - sqlite3VdbeJumpHere(v, iGotoInst); > - sqlite3VdbeAddOp3(v, OP_Column, iCursor, 1, iRes); > - sqlite3VdbeAddOp2(v, OP_AddImm, iRes, 1); > - return iRes; > + struct Vdbe *v = sqlite3GetVdbe(parse); > + int key_reg = ++parse->nMem; > + > + sqlite3VdbeAddOp2(v, OP_Integer, space_id, key_reg); > + int seek_adr = sqlite3VdbeAddOp4Int(v, OP_SeekLE, cursor, 0, > + key_reg, 1); > + sqlite3VdbeAddOp4Int(v, OP_IdxLT, cursor, 0, key_reg, 1); > + /* Jump over Halt block. */ > + int goto_succ_addr = sqlite3VdbeAddOp0(v, OP_Goto); > + /* Invalid space id handling block starts here. */ > + sqlite3VdbeJumpHere(v, seek_adr); > + sqlite3VdbeJumpHere(v, seek_adr + 1); > + sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_ERROR, ON_CONFLICT_ACTION_FAIL, 0, > + sqlite3MPrintf(parse->db, "Invalid space id: %d", > + space_id), P4_DYNAMIC); > + > + sqlite3VdbeJumpHere(v, goto_succ_addr); > + /* Fetch iid from the row and increment it. */ > + int iid_reg = ++parse->nMem; > + sqlite3VdbeAddOp3(v, OP_Column, cursor, 1, iid_reg); 1 -> BOX_INDEX_FIELD_ID. > + sqlite3VdbeAddOp2(v, OP_AddImm, iid_reg, 1); > + return iid_reg; > } >