Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Roman Khabibov <roman.habibov@tarantool.org>
Cc: Konstantin Osipov <kostja@tarantool.org>,
	tarantool-patches@dev.tarantool.org,
	Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH v2 3/3] box: let only box handle constraint dup errors
Date: Thu, 5 Dec 2019 22:13:57 +0300	[thread overview]
Message-ID: <20191205191357.GB2469@uranus> (raw)
In-Reply-To: <B4DA7969-21CC-43DB-B79B-601198877C2A@tarantool.org>

On Thu, Dec 05, 2019 at 09:59:33PM +0300, Roman Khabibov wrote:
> 
> Vlad, please, don’t see the previous.
> 
> Cyrill, I added both for sure.

Thanks!

> +/**
> + * Just return string with constraint type to print it in error
> + * message.
> + */
> +static inline const char *
> +cosntraint_type_str(struct constraint_def *def) {
> +	assert(def->type == CONSTRAINT_TYPE_PK || def->type ==
> +	       CONSTRAINT_TYPE_UNIQUE || def->type == CONSTRAINT_TYPE_FK ||
> +	       def->type == CONSTRAINT_TYPE_CK);
> +	switch (def->type) {
> +	case CONSTRAINT_TYPE_PK:
> +		return "PRIMARY KEY";
> +	case CONSTRAINT_TYPE_UNIQUE:
> +		return "UNIQUE";
> +	case CONSTRAINT_TYPE_FK:
> +		return "FOREIGN KEY";
> +	case CONSTRAINT_TYPE_CK:
> +		return "CHECK";
> +	default:
> +		break;
> +	}
> +	return NULL;
> +}

This is a way better than it was. To be honest I'm not strong
in the whole context of the series, but when I need to provide
some symbolic name I do something like

/**
 * popen_state_str - get process state string representation
 * @state:	process state
 */
const char *
popen_state_str(unsigned int state)
{
	/*
	 * A process may be in a number of states,
	 * running/sleeping/disk sleep/stopped and etc
	 * but we are interested only if it is alive
	 * or dead (via plain exit or kill signal).
	 *
	 * Thus while it present in a system and not
	 * yet reaped we call it "alive".
	 *
	 * Note this is API for lua, so change with
	 * caution if needed.
	 */
	static const char * state_str[POPEN_STATE_MAX] = {
		[POPEN_STATE_NONE]	= "none",
		[POPEN_STATE_RUNNING]	= "alive",
		[POPEN_STATE_EXITED]	= "exited",
		[POPEN_STATE_SIGNALED]	= "signaled",
	};

	return state < POPEN_STATE_MAX ? state_str[state] : "unknown";
}

but note that I know the number of entries so it might not fit
your needs thus I'm fine with your current code. Thanks!

  reply	other threads:[~2019-12-05 19:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1575468493.git.roman.habibov@tarantool.org>
2019-12-04 16:23 ` Roman Khabibov
2019-12-04 16:32   ` Cyrill Gorcunov
2019-12-04 17:54   ` Konstantin Osipov
2019-12-05 18:59     ` Roman Khabibov
2019-12-05 19:13       ` Cyrill Gorcunov [this message]
2019-12-07 16:35   ` Vladislav Shpilevoy
2019-12-10 12:49     ` Roman Khabibov

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=20191205191357.GB2469@uranus \
    --to=gorcunov@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=roman.habibov@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 3/3] box: let only box handle constraint dup errors' \
    /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