From: Mergen Imeev <imeevma@tarantool.org> To: "n.pettik" <korablev@tarantool.org> Cc: tarantool-patches@freelists.org Subject: [tarantool-patches] Re: [PATCH v4 4/4] sql: do not increase row-count if INSERT or REPLACE failed Date: Mon, 22 Jul 2019 14:26:47 +0300 [thread overview] Message-ID: <20190722112646.GA29744@tarantool.org> (raw) In-Reply-To: <6AE2D6A3-B992-4BBC-9BE7-6A064F316E66@tarantool.org> Hi! Thank you for review! Just before sending patch to Kirill, I discovered that the function sequence_get_value() returns only 0. Because of this, it makes no sense to check the result of the function. Since this function used a special argument to return a value, I deleted this argument and made the function now return this value. Diff below. On Mon, Jul 22, 2019 at 01:48:44PM +0300, n.pettik wrote: > I’ve force pushed a couple of cosmetic fixes. > Also added check of return value of > vdbe_add_new_autoinc_id() - it can fail due to OOM. > > Now LGTM. i> diff --git a/src/box/sequence.c b/src/box/sequence.c index 5996519..1aacc50 100644 --- a/src/box/sequence.c +++ b/src/box/sequence.c @@ -363,8 +363,8 @@ sequence_data_iterator_create(void) return &iter->base; } -int -sequence_get_value(struct sequence *seq, int64_t *out_value) +int64_t +sequence_get_value(struct sequence *seq) { uint32_t key = seq->def->id; uint32_t hash = sequence_hash(key); @@ -372,6 +372,5 @@ sequence_get_value(struct sequence *seq, int64_t *out_value) assert(pos != light_sequence_end); struct sequence_data data = light_sequence_get(&sequence_data_index, pos); - *out_value = data.value; - return 0; + return data.value; } diff --git a/src/box/sequence.h b/src/box/sequence.h index b56236e..976020a 100644 --- a/src/box/sequence.h +++ b/src/box/sequence.h @@ -171,11 +171,10 @@ sequence_data_iterator_create(void); * Get last element of given sequence. * * @param seq sequence to get value from. - * @param[out] out_value last element of sequence. - * @retval 0 on success, -1 on error. + * @retval last element of sequence. */ -int -sequence_get_value(struct sequence *seq, int64_t *out_value); +int64_t +sequence_get_value(struct sequence *seq); #if defined(__cplusplus) } /* extern "C" */ diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index f771843..431b4d9 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -4224,9 +4224,7 @@ case OP_IdxInsert: { } if (rc == 0 && pOp->p3 > 0 && ((aMem[pOp->p3].flags) & MEM_Null) != 0) { assert(space->sequence != NULL); - int64_t value; - if (sequence_get_value(space->sequence, &value) != 0) - goto abort_due_to_error; + int64_t value = sequence_get_value(space->sequence); if (vdbe_add_new_autoinc_id(p, value) != 0) goto abort_due_to_error; }
next prev parent reply other threads:[~2019-07-22 11:27 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-07-17 9:54 [tarantool-patches] [PATCH v4 0/4] sql: do not show IDs generated by trigger imeevma 2019-07-17 9:54 ` [tarantool-patches] [PATCH v4 1/4] sql: remove unnecessary AUTOINCREMENT ID generation imeevma 2019-07-17 9:54 ` [tarantool-patches] [PATCH v4 2/4] sql: skip autoinc IDs generated inside SQL trigger imeevma 2019-07-17 16:58 ` [tarantool-patches] " n.pettik 2019-07-19 9:33 ` Mergen Imeev 2019-07-17 9:54 ` [tarantool-patches] [PATCH v4 3/4] sql: remove VDBE from TXN imeevma 2019-07-17 9:54 ` [tarantool-patches] [PATCH v4 4/4] sql: do not increase row-count if INSERT or REPLACE failed imeevma 2019-07-17 16:57 ` [tarantool-patches] " n.pettik 2019-07-17 18:08 ` [tarantool-patches] " Мерген Имеев 2019-07-19 9:36 ` Mergen Imeev 2019-07-22 10:48 ` n.pettik 2019-07-22 11:26 ` Mergen Imeev [this message] 2019-07-24 13:55 ` [tarantool-patches] Re: [PATCH v4 0/4] sql: do not show IDs generated by trigger Kirill Yukhin
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=20190722112646.GA29744@tarantool.org \ --to=imeevma@tarantool.org \ --cc=korablev@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='[tarantool-patches] Re: [PATCH v4 4/4] sql: do not increase row-count if INSERT or REPLACE failed' \ /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