Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org, Nikita Pettik <korablev@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH 4/6] sql: refactor getNewIid() function
Date: Mon, 14 Jan 2019 17:05:50 +0300	[thread overview]
Message-ID: <bca77e9a-9237-2db8-e9e4-9ba8aa40f500@tarantool.org> (raw)
In-Reply-To: <c71afc87f58c0fbd08cfb1efc6c0403e04b5b0c4.1547035184.git.korablev@tarantool.org>

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;
>   }
>   

  reply	other threads:[~2019-01-14 14:06 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-09 12:13 [tarantool-patches] [PATCH 0/6] Introduce ALTER TABLE ADD CONSTRAINT UNIQUE/PK Nikita Pettik
2019-01-09 12:13 ` [tarantool-patches] [PATCH 1/6] sql: move constraint name to struct contraint_parse Nikita Pettik
2019-01-14 14:04   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-16 20:06     ` n.pettik
2019-01-16 20:54       ` Vladislav Shpilevoy
2019-01-17 10:56       ` Konstantin Osipov
2019-01-17 17:14         ` n.pettik
2019-01-09 12:13 ` [tarantool-patches] [PATCH 2/6] sql: rework ALTER TABLE grammar Nikita Pettik
2019-01-14 14:05   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-16 20:06     ` n.pettik
2019-01-16 20:54       ` Vladislav Shpilevoy
2019-01-17 11:51   ` Konstantin Osipov
2019-01-17 17:14     ` n.pettik
2019-01-18  1:42       ` Konstantin Osipov
2019-01-09 12:13 ` [tarantool-patches] [PATCH 3/6] sql: remove start token from sql_create_index args Nikita Pettik
2019-01-09 12:13 ` [tarantool-patches] [PATCH 4/6] sql: refactor getNewIid() function Nikita Pettik
2019-01-14 14:05   ` Vladislav Shpilevoy [this message]
2019-01-09 12:13 ` [tarantool-patches] [PATCH 5/6] sql: fix error message for improperly created index Nikita Pettik
2019-01-14 14:06   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-16 20:06     ` n.pettik
2019-01-09 12:13 ` [tarantool-patches] [PATCH 6/6] sql: introduce ALTER TABLE ADD CONSTRAINT UNIQUE/PRIMARY KEY Nikita Pettik
2019-01-14 14:06   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-16 20:06     ` n.pettik
2019-01-16 20:54       ` Vladislav Shpilevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bca77e9a-9237-2db8-e9e4-9ba8aa40f500@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH 4/6] sql: refactor getNewIid() function' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox