Tarantool development patches archive
 help / color / mirror / Atom feed
From: "Sergey Ostanevich" <sergos@tarantool.org>
To: tarantool-patches <tarantool-patches@freelists.org>
Cc: tarantool-patches <tarantool-patches@dev.tarantool.org>
Subject: Re: [Tarantool-patches] [tarantool-patches] [PATCH v4 07/20] refactoring: remove exceptions from index_def_new_from_tuple
Date: Thu, 31 Oct 2019 08:02:05 +0300	[thread overview]
Message-ID: <1572498125.840239809@f466.i.mail.ru> (raw)
In-Reply-To: <1572432429.539435313@f146.i.mail.ru>

[-- Attachment #1: Type: text/plain, Size: 3034 bytes --]


Hi!

Thanks for explanation! 
The patch is still LGTM.

Sergos 



Sent from Mail.ru app for iOS


Wednesday, 30 October 2019, 20:08 +0300 from Ilya Kosarev  <i.kosarev@tarantool.org>:
>Hi!
>
>Thanks for your review.
>We are using diag_raise here as far as index_def_check_sequence is already refactored and we need to process the error it returns, while sequence_field_from_tuple itself is not being refactored in this patch, so we can't return an error here, only raise an exception.
>
>Sincerely,
>Ilya Kosarev
>
>>Среда, 30 октября 2019, 11:59 +03:00 от Sergey Ostanevich < sergos@tarantool.org >:
>>
>>Hi!
>>
>>LGTM, just a few nits in comments below
>>
>>> index 8d565e189..10a5f8d64 100644
>>> --- a/src/box/alter.cc
>>> +++ b/src/box/alter.cc
>>> @@ -118,10 +118,10 @@ access_check_ddl(const char *name, uint32_t object_id, uint32_t owner_uid,
>>>  }
>>> 
>>>  /**
>>> - * Throw an exception if the given index definition
>>> + * Return an error if the given index definition
>>>   * is incompatible with a sequence.
>>>   */
>>> -static void
>>> +static int
>>>  index_def_check_sequence(struct index_def *index_def, uint32_t sequence_fieldno,
>>>  			 const char *sequence_path, uint32_t sequence_path_len,
>>>  			 const char *space_name)
>>> @@ -142,24 +142,27 @@ index_def_check_sequence(struct index_def *index_def, uint32_t sequence_fieldno,
>>>  		}
>>>  	}
>>>  	if (sequence_part == NULL) {
>>> -		tnt_raise(ClientError, ER_MODIFY_INDEX, index_def->name,
>>> -			  space_name, "sequence field must be a part of "
>>> -			  "the index");
>>> +		diag_set(ClientError, ER_MODIFY_INDEX, index_def->name,
>>> +			 space_name, "sequence field must be a part of "
>>> +				     "the index");
>>> +		return -1;
>>>  	}
>>>  	enum field_type type = sequence_part->type;
>>>  	if (type != FIELD_TYPE_UNSIGNED && type != FIELD_TYPE_INTEGER) {
>>> -		tnt_raise(ClientError, ER_MODIFY_INDEX, index_def->name,
>>> -			  space_name, "sequence cannot be used with "
>>> -			  "a non-integer key");
>>> +		diag_set(ClientError, ER_MODIFY_INDEX, index_def->name,
>>> +			 space_name, "sequence cannot be used with "
>>> +				     "a non-integer key");
>>> +		return -1;
>>>  	}
>>> +	return 0;
>>>  }
>>> 
>>>  /**
>>>   * Support function for index_def_new_from_tuple(..)
>>> - * Checks tuple (of _index space) and throws a nice error if it is invalid
>>> + * Checks tuple (of _index space) and sets a nice diag if it is invalid
>>Should be 'Return an error', same as for the case above.
>>
>>> @@ -4066,8 +4099,9 @@ sequence_field_from_tuple(struct space *space, struct tuple *tuple,
>>>  		if (path_len == 0)
>>>  			path_raw = NULL;
>>>  	}
>>> -	index_def_check_sequence(pk->def, fieldno, path_raw, path_len,
>>> -				 space_name(space));
>>> +	if (index_def_check_sequence(pk->def, fieldno, path_raw, path_len,
>>> +				 space_name(space)) != 0)
>>> +		diag_raise();
>>
>>I wonder why we leave some diag_raise() and not diag_set() plus return
>>-1 or NULL?
>>
>>
>>regards,
>>Sergos
>>
>
>
>-- 
>Ilya Kosarev

[-- Attachment #2: Type: text/html, Size: 8664 bytes --]

  reply	other threads:[~2019-10-31  5:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1569253692.git.i.kosarev@tarantool.org>
     [not found] ` <15e506eb070ddbb0bbb0c0f4388958738f1fbc9a.1569253692.git.i.kosarev@tarantool.org>
     [not found]   ` <20191030085942.GA35607@tarantool.org>
2019-10-30 10:47     ` Ilya Kosarev
2019-10-31  5:02       ` Sergey Ostanevich [this message]
     [not found] ` <09dd946a8304f3865ada1638f610a4f9ba2fd3eb.1569253692.git.i.kosarev@tarantool.org>
     [not found]   ` <20191030103454.GB35607@tarantool.org>
2019-10-30 11:02     ` [Tarantool-patches] [tarantool-patches] [PATCH v4 08/20] refactoring: remove exceptions from func_def_new_from_tuple Ilya Kosarev
2019-11-11 14:36       ` Sergey Ostanevich
     [not found] ` <c7b7c7fd16803e60296be60c3e545dbf2ab61ae8.1569253692.git.i.kosarev@tarantool.org>
     [not found]   ` <1573329671.649762688@f148.i.mail.ru>
2019-11-09 22:52     ` [Tarantool-patches] [tarantool-patches] [PATCH v4 11/20] refactoring: use non _xc version of functions in triggers Ilya Kosarev
2019-11-11 14:37       ` Sergey Ostanevich
     [not found] ` <e5cebfe21734bcfe8b7a8b477968668620cb3aa8.1569253692.git.i.kosarev@tarantool.org>
     [not found]   ` <20191112105951.GC10433@tarantool.org>
2019-11-12 15:32     ` [Tarantool-patches] [tarantool-patches] Re: [PATCH v4 12/20] refactoring: remove exceptions from space_def_new_from_tuple Ilya Kosarev
2019-11-19 15:16       ` Ilya Kosarev
2019-12-16 11:55         ` [Tarantool-patches] [tarantool-patches] Re[2]: " Sergey Ostanevich
     [not found] ` <6f586562e3079b4ca5776b74913894db73bd979f.1569253692.git.i.kosarev@tarantool.org>
     [not found]   ` <20191113133416.dtdgl63r7erfwfht@tarantool.org>
2019-11-13 13:49     ` [Tarantool-patches] [PATCH] refactoring: remove exceptions from fk_constraint_def_new_from_tuple Ilya Kosarev
2019-11-13 16:02       ` Kirill Yukhin
2019-11-13 13:50     ` [Tarantool-patches] [tarantool-patches] Re: [PATCH v4 17/20] " Ilya Kosarev

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=1572498125.840239809@f466.i.mail.ru \
    --to=sergos@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [Tarantool-patches] [tarantool-patches] [PATCH v4 07/20] refactoring: remove exceptions from index_def_new_from_tuple' \
    /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