Tarantool development patches archive
 help / color / mirror / Atom feed
From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v1 1/2] sql: use schema API to get index info in analyze
Date: Wed, 25 Jul 2018 16:22:27 +0300	[thread overview]
Message-ID: <2966C909-20F8-4682-A915-E922E3A0FC1A@tarantool.org> (raw)
In-Reply-To: <aa9d1ac8d749bd0dc5e1f189d8480bdd907d1701.1532430181.git.kshcherbatov@tarantool.org>


> On 24 Jul 2018, at 14:05, Kirill Shcherbatov <kshcherbatov@tarantool.org> wrote:
> 
> We would like to avoid starting transactions in ANALYZE
> so we need to use schema API that is more tolerant.

Please, provide more detailed explanation, such as:

“
Previously, ANALYZE routine used to invoke box_space_id_by_name
function, which in turn relies on sysview engine. On the other hand,
ANALYZE processing is surrounded by transaction started in memtx
(_sql_stat1 and _sql_stat4 are system spaces stored in memtx).
Thus, multi-engine transaction error may  occur. To avoid such
situation lets use internal schema_find_id() function.
"

> 
> Part of #3551.
> ---
> src/box/sql/analyze.c | 82 ++++++++++++++++++++++++++++++---------------------
> 1 file changed, 48 insertions(+), 34 deletions(-)
> 
> diff --git a/src/box/sql/analyze.c b/src/box/sql/analyze.c
> index 00d96d2..c7b85dc 100644
> --- a/src/box/sql/analyze.c
> +++ b/src/box/sql/analyze.c
> @@ -1219,6 +1219,26 @@ decode_stat_string(const char *stat_string, int stat_size, tRowcnt *stat_exact,
> }
> 
> /**
> + * Find index with specified @name in specified @space.
> + * @param space to lookup.
> + * @param name to use in comparation.
> + * @param len lenth of @name string.

Typo: length.

> + * @retval NULL on nothing found.

If nothing is found.

> + * @retval not NULL pointer on index AST else.

Index AST? I guess “pointer to index otherwise”.

> + */
> +static struct index *
> +space_index_by_name(struct space *space, const char *name, uint32_t len)
> +{
> +	uint32_t idx_cnt = space->index_count;
> +	for (uint32_t i = 0; i < idx_cnt; i++) {
> +		const char *idx_name = space->index[i]->def->name;
> +		if (strlen(idx_name) == len && memcmp(idx_name, name, len) == 0)
> +			return space->index[i];
> +	}
> +	return NULL;
> +}

Overall it is sad that we can't use schema_find_id for this purpose.
Mb it is worth to refactor this function so that it will take not id but
already encoded key to be found? It is only suggestion tho,
it can be contradictory way..

  parent reply	other threads:[~2018-07-25 13:22 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-20 13:52 [tarantool-patches] [PATCH v1 1/1] sql: prevent executing crossengine sql Kirill Shcherbatov
2018-07-20 15:03 ` [tarantool-patches] " Vladislav Shpilevoy
2018-07-20 17:50   ` Kirill Shcherbatov
2018-07-23 11:50     ` Vladislav Shpilevoy
2018-07-23 16:20       ` n.pettik
2018-07-23 16:39         ` Vladislav Shpilevoy
2018-07-23 17:09           ` n.pettik
2018-07-23 17:21             ` Vladislav Shpilevoy
2018-07-23 18:06               ` n.pettik
2018-07-23 18:29                 ` Vladislav Shpilevoy
2018-07-24 11:05                   ` [tarantool-patches] [PATCH v1 1/2] sql: use schema API to get index info in analyze Kirill Shcherbatov
     [not found]                     ` <cover.1532430181.git.kshcherbatov@tarantool.org>
2018-07-24 11:05                       ` [tarantool-patches] [PATCH v1 2/2] sql: prevent executing crossengine sql Kirill Shcherbatov
2018-07-25 13:24                         ` [tarantool-patches] " n.pettik
2018-07-25 17:07                           ` Kirill Shcherbatov
2018-07-25 21:05                             ` Vladislav Shpilevoy
2018-07-26  7:08                               ` Kirill Shcherbatov
2018-07-26  8:54                                 ` Vladislav Shpilevoy
2018-07-26 11:22                                   ` Kirill Shcherbatov
2018-07-26 21:26                                     ` Vladislav Shpilevoy
2018-07-27  7:13                                       ` Kirill Shcherbatov
2018-07-27  8:55                                         ` Vladislav Shpilevoy
2018-07-27 10:02                                           ` Kirill Shcherbatov
2018-07-27 10:14                                             ` Vladislav Shpilevoy
2018-07-31  7:54                         ` Kirill Yukhin
2018-07-25 13:22                     ` n.pettik [this message]
2018-07-25 17:07                       ` [tarantool-patches] Re: [PATCH v1 1/2] sql: use schema API to get index info in analyze Kirill Shcherbatov
2018-07-25 20:52                     ` 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=2966C909-20F8-4682-A915-E922E3A0FC1A@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v1 1/2] sql: use schema API to get index info in analyze' \
    /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