Tarantool development patches archive
 help / color / mirror / Atom feed
From: Nikita Pettik <korablev@tarantool.org>
To: imeevma@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v3 3/3] sql: do not change order of inserted values
Date: Thu, 16 Apr 2020 00:09:57 +0000	[thread overview]
Message-ID: <20200416000957.GB2581@tarantool.org> (raw)
In-Reply-To: <2542c80348de25f26cac73e101b394a1873156da.1586933931.git.imeevma@gmail.com>

On 15 Apr 10:09, imeevma@tarantool.org wrote:
> My answers and new patch below.
> 
> On 4/14/20 1:59 AM, Nikita Pettik wrote:
>  
> diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c
> index 43a0de5..787855e 100644
> --- a/src/box/sql/insert.c
> +++ b/src/box/sql/insert.c
> @@ -455,8 +455,31 @@ sqlInsert(Parse * pParse,	/* Parser context */
>  			reg_eph = ++pParse->nMem;
>  			regRec = sqlGetTempReg(pParse);
>  			regCopy = sqlGetTempRange(pParse, nColumn + 1);
> -			sqlVdbeAddOp2(v, OP_OpenTEphemeral, reg_eph,
> -					  nColumn + 1);
> +			/*
> +			 * This key_info is used to show that
> +			 * rowid should be the first part of PK in
> +			 * case we used AUTOINCREMENT feature.
> +			 * This way we will save initial order of
> +			 * the inserted values. The order is
> +			 * important if we use the AUTOINCREMENT
> +			 * feature, since changing the order can
> +			 * change the number inserted instead of
> +			 * NULL.
> +			 */
> +			if (space->sequence != NULL) {
> +				struct sql_key_info *key_info =
> +					sql_key_info_new(pParse->db,
> +							 nColumn + 1);
> +				key_info->parts[nColumn].type =
> +					FIELD_TYPE_UNSIGNED;
> +				key_info->is_pk_rowid = true;
> +				sqlVdbeAddOp4(v, OP_OpenTEphemeral, reg_eph,
> +					      nColumn + 1, 0, (char *)key_info,
> +					      P4_KEYINFO);
> +			} else {
> +				sqlVdbeAddOp2(v, OP_OpenTEphemeral, reg_eph,
> +					      nColumn + 1);
> +			}

You can remove 'else' branch and always add OP_OPenTEphemeral with
2 operands. Then inside 'if' branch invoke sqlVdbeChangeP4().
Otherwise LGTM.

  reply	other threads:[~2020-04-16  0:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15  7:09 [Tarantool-patches] [PATCH v3 0/3] sql: fix order of inserted rows imeevma
2020-04-15  7:09 ` [Tarantool-patches] [PATCH v3 1/3] box: extend ephemeral space format imeevma
2020-04-15  7:09 ` [Tarantool-patches] [PATCH v3 2/3] sql: specify field types in " imeevma
2020-04-15  7:09 ` [Tarantool-patches] [PATCH v3 3/3] sql: do not change order of inserted values imeevma
2020-04-16  0:09   ` Nikita Pettik [this message]
2020-04-16  8:33     ` Mergen Imeev
2020-04-16 13:29 ` [Tarantool-patches] [PATCH v3 0/3] sql: fix order of inserted rows Nikita Pettik

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=20200416000957.GB2581@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v3 3/3] sql: do not change order of inserted values' \
    /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