Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Ostanevich <sergos@tarantool.org>
To: Ilya Kosarev <i.kosarev@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v5 4/8] refactoring: set diagnostics if sequence_by_id fails
Date: Wed, 27 Nov 2019 16:40:56 +0300	[thread overview]
Message-ID: <20191127134056.GD1718@tarantool.org> (raw)
In-Reply-To: <1673b241d9ca3f1f3396c158d298845907fb5392.1574390065.git.i.kosarev@tarantool.org>

Hi!

LGTM. 

Please, create a follow-up tracker to review all sequence_by_id() uses:
for example, in on_drop_sequence_data_rollback() this can lead to a
coredump inside the sequence_set() in release build. 

Regards,
Sergos

On 22 Nov 05:46, Ilya Kosarev wrote:
> In refactoring: use non _xc version of functions in triggers
> (b75d5f85338158eb1734ca8832d3c4b8ac0b4086) sequence_cache_find was
> replaced by sequence_by_id. It led to the loss of diagnostics in case
> of sequence_by_id failure. Now it is fixed.
> 
> Part of #4247
> ---
>  src/box/alter.cc | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/box/alter.cc b/src/box/alter.cc
> index aaaf53493..2628e1401 100644
> --- a/src/box/alter.cc
> +++ b/src/box/alter.cc
> @@ -4365,8 +4365,10 @@ on_replace_dd_sequence_data(struct trigger * /* trigger */, void *event)
>  			    &id) != 0)
>  		return -1;
>  	struct sequence *seq = sequence_by_id(id);
> -	if (seq == NULL)
> +	if (seq == NULL) {
> +		diag_set(ClientError, ER_NO_SUCH_SEQUENCE, int2str(id));
>  		return -1;
> +	}
>  	if (new_tuple != NULL) {			/* INSERT, UPDATE */
>  		int64_t value;
>  		if (tuple_field_i64(new_tuple, BOX_SEQUENCE_DATA_FIELD_VALUE,
> @@ -4520,8 +4522,10 @@ on_replace_dd_space_sequence(struct trigger * /* trigger */, void *event)
>  	if (space == NULL)
>  		return -1;
>  	struct sequence *seq = sequence_by_id(sequence_id);
> -	if (seq == NULL)
> +	if (seq == NULL) {
> +		diag_set(ClientError, ER_NO_SUCH_SEQUENCE, int2str(sequence_id));
>  		return -1;
> +	}
>  
>  	enum priv_type priv_type = stmt->new_tuple ? PRIV_C : PRIV_D;
>  	if (stmt->new_tuple && stmt->old_tuple)
> -- 
> 2.17.1
> 

  reply	other threads:[~2019-11-27 13:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-22  2:46 [Tarantool-patches] [PATCH v5 0/8] refactoring: remove exceptions from triggers follow-ups Ilya Kosarev
2019-11-22  2:46 ` [Tarantool-patches] [PATCH v5 1/8] refactoring: wrap new operator calls in triggers Ilya Kosarev
2019-11-26 15:07   ` Sergey Ostanevich
2019-11-22  2:46 ` [Tarantool-patches] [PATCH v5 2/8] refactoring: specify struct name in allocation diagnostics Ilya Kosarev
2019-11-27 13:25   ` Sergey Ostanevich
2019-11-22  2:46 ` [Tarantool-patches] [PATCH v5 3/8] refactoring: recombine error conditions in triggers Ilya Kosarev
2019-11-27 13:28   ` Sergey Ostanevich
2019-11-22  2:46 ` [Tarantool-patches] [PATCH v5 4/8] refactoring: set diagnostics if sequence_by_id fails Ilya Kosarev
2019-11-27 13:40   ` Sergey Ostanevich [this message]
2019-11-22  2:46 ` [Tarantool-patches] [PATCH v5 5/8] refactoring: clear triggers from fresh exceptions Ilya Kosarev
2019-11-27 14:59   ` Sergey Ostanevich
2019-11-22  2:46 ` [Tarantool-patches] [PATCH v5 6/8] refactoring: update comment for index_def_check_tuple Ilya Kosarev
2019-11-27 14:59   ` Sergey Ostanevich
2019-11-22  2:46 ` [Tarantool-patches] [PATCH v5 7/8] refactoring: remove redundant line in txn_alter_trigger_new Ilya Kosarev
2019-11-27 15:00   ` Sergey Ostanevich
2019-11-22  2:46 ` [Tarantool-patches] [PATCH v5 8/8] refactoring: remove try..catch wrapper around trigger->run Ilya Kosarev
2019-11-27 15:01   ` Sergey Ostanevich
2019-12-02  7:41 ` [Tarantool-patches] [PATCH v5 0/8] refactoring: remove exceptions from triggers follow-ups 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=20191127134056.GD1718@tarantool.org \
    --to=sergos@tarantool.org \
    --cc=i.kosarev@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v5 4/8] refactoring: set diagnostics if sequence_by_id fails' \
    /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