Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org,
	Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v1 3/4] box: introduce box_space_id_by_name
Date: Thu, 31 May 2018 20:36:52 +0300	[thread overview]
Message-ID: <91765db9-575c-9d10-c678-ff1f3b230735@tarantool.org> (raw)
In-Reply-To: <95c32aa69c7040aa5a63164e19de8ac8f06d9ce3.1527765756.git.kshcherbatov@tarantool.org>

Thanks for the patch! See 5 comments below.

On 31/05/2018 14:22, Kirill Shcherbatov wrote:
> Part of #3273.
> ---
>   src/box/box.cc | 10 ++++++++--
>   src/box/box.h  | 14 ++++++++++++++
>   2 files changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/src/box/box.cc b/src/box/box.cc
> index 02722d6..9540d85 100644
> --- a/src/box/box.cc
> +++ b/src/box/box.cc
> @@ -877,7 +877,7 @@ box_return_tuple(box_function_ctx_t *ctx, box_tuple_t *tuple)
>   
>   /* schema_find_id()-like method using only public API */
>   uint32_t
> -box_space_id_by_name(const char *name, uint32_t len)
> +space_id_by_name(uint32_t system_space_id, const char *name, uint32_t len)

1. The comment now is wrong - space_id_by_name will be used exactly for
non-public API.

2. space_id_by_name must not take system_space_id as an argument. It must
always use BOX_SPACE_ID.

Do this:

/**
  * ...
  *
  * Return 0 on success, -1 on error.
  * @param[out] space_id BOX_ID_NIL - not found. Else space_id is
  *             saved.
  *
  * ...
  */
static inline int
space_id_by_name_impl(system_space_id, name, len, uint32_t *space_id);

uint32_t
space_id_by_name(name, len)
{
	return space_id_by_name_impl(BOX_SPACE_ID, name, len);
}

uint32_t
box_space_id_by_name(name, len)
{
	return space_id_by_name_impl(BOX_VSPACE_ID, name, len);
}

>   {
>   	if (len > BOX_NAME_MAX)
>   		return BOX_ID_NIL;
> diff --git a/src/box/box.h b/src/box/box.h
> index bdd5d5c..ba33113 100644
> --- a/src/box/box.h
> +++ b/src/box/box.h
> @@ -220,6 +220,20 @@ API_EXPORT int
>   box_return_tuple(box_function_ctx_t *ctx, box_tuple_t *tuple);
>   
>   /**
> + * Find space id by name in specified system space.
> + *
> + * This function performs SELECT request to _vspace system space.

3. Not _vspace.

> + * \param system_space_id space to lookup name.
> + * \param name space name
> + * \param len length of \a name
> + * \retval BOX_ID_NIL on error or if not found (check box_error_last())
> + * \retval space_id otherwise
> + * \sa box_index_id_by_name
> + */
> +uint32_t
> +space_id_by_name(uint32_t system_space_id, const char *name, uint32_t len);

4. space_id_by_name is not public function. You must not put it inside
/** \cond public */.

It must be in schema.h like other <something_by_something> functions.

5. Why can not you just port schema_find_id to C?

> +
> +/**
>    * Find space id by name.
>    *
>    * This function performs SELECT request to _vspace system space.
> 

  reply	other threads:[~2018-05-31 17:37 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-31 11:22 [tarantool-patches] [PATCH v1 0/4] sql: remove Triggers to server Kirill Shcherbatov
2018-05-31 11:22 ` [tarantool-patches] [PATCH v1 1/4] box: move db->pShchema init to sql_init Kirill Shcherbatov
2018-05-31 17:36   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-01 20:24     ` Kirill Shcherbatov
2018-05-31 11:22 ` [tarantool-patches] [PATCH v1 2/4] sql: fix sql len in tarantoolSqlite3RenameTrigger Kirill Shcherbatov
2018-05-31 11:22 ` [tarantool-patches] [PATCH v1 3/4] box: introduce box_space_id_by_name Kirill Shcherbatov
2018-05-31 17:36   ` Vladislav Shpilevoy [this message]
2018-06-01 20:24     ` [tarantool-patches] " Kirill Shcherbatov
2018-06-04 13:27       ` Vladislav Shpilevoy
2018-06-04 19:21         ` Kirill Shcherbatov
2018-06-05 13:31           ` Vladislav Shpilevoy
2018-05-31 11:22 ` [tarantool-patches] [PATCH v1 4/4] sql: move Triggers to server Kirill Shcherbatov
2018-05-31 17:36   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-01 20:24     ` Kirill Shcherbatov
2018-06-01 20:25       ` Kirill Shcherbatov
2018-06-04 13:27         ` Vladislav Shpilevoy
2018-06-04 19:21           ` Kirill Shcherbatov
2018-06-05 13:31             ` Vladislav Shpilevoy
2018-06-09  9:32               ` Kirill Shcherbatov
2018-06-01 18:51   ` Konstantin Osipov
2018-05-31 17:36 ` [tarantool-patches] Re: [PATCH v1 0/4] sql: remove " Vladislav Shpilevoy
2018-06-04 13:27 ` Vladislav Shpilevoy
2018-06-05 13:31 ` Vladislav Shpilevoy

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=91765db9-575c-9d10-c678-ff1f3b230735@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v1 3/4] box: introduce box_space_id_by_name' \
    /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