From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 05C2820EDB for ; Wed, 25 Jul 2018 09:22:30 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FgW6ngBWQKhR for ; Wed, 25 Jul 2018 09:22:29 -0400 (EDT) Received: from smtp55.i.mail.ru (smtp55.i.mail.ru [217.69.128.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id B52B320044 for ; Wed, 25 Jul 2018 09:22:29 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [tarantool-patches] Re: [PATCH v1 1/2] sql: use schema API to get index info in analyze From: "n.pettik" In-Reply-To: Date: Wed, 25 Jul 2018 16:22:27 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <2966C909-20F8-4682-A915-E922E3A0FC1A@tarantool.org> References: <5899c7db-b1c0-d099-989e-dcb41b801cdd@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: Kirill Shcherbatov > On 24 Jul 2018, at 14:05, Kirill Shcherbatov = wrote: >=20 > 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: =E2=80=9C 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. " >=20 > Part of #3551. > --- > src/box/sql/analyze.c | 82 = ++++++++++++++++++++++++++++++--------------------- > 1 file changed, 48 insertions(+), 34 deletions(-) >=20 > 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, > } >=20 > /** > + * 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 =E2=80=9Cpointer to index otherwise=E2=80=9D. > + */ > +static struct index * > +space_index_by_name(struct space *space, const char *name, uint32_t = len) > +{ > + uint32_t idx_cnt =3D space->index_count; > + for (uint32_t i =3D 0; i < idx_cnt; i++) { > + const char *idx_name =3D space->index[i]->def->name; > + if (strlen(idx_name) =3D=3D len && memcmp(idx_name, = name, len) =3D=3D 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..