From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Wed, 24 Jul 2019 23:44:59 +0300 From: Konstantin Osipov Subject: Re: [PATCH v4 4/4] box: introduce functional indexes Message-ID: <20190724204459.GA11089@atlas> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: To: Kirill Shcherbatov Cc: tarantool-patches@freelists.org, vdavydov.dev@gmail.com List-ID: * Kirill Shcherbatov [19/07/24 10:38]: > index f98a77a51..c36b6643e 100644 > --- a/src/box/alter.cc > +++ b/src/box/alter.cc > @@ -45,6 +45,7 @@ > #include "fiber.h" /* for gc_pool */ > #include "scoped_guard.h" > #include "third_party/base64.h" > +#include "memtx_engine.h" > #include /* for placement new */ > #include /* snprintf() */ > #include > @@ -195,7 +196,7 @@ err: > */ > static void > index_opts_decode(struct index_opts *opts, const char *map, > - struct region *region) > + struct space *space, struct region *region) > { > index_opts_create(opts); > if (opts_decode(opts, index_opts_reg, &map, ER_WRONG_INDEX_OPTIONS, > @@ -229,6 +230,22 @@ index_opts_decode(struct index_opts *opts, const char *map, > "bloom_fpr must be greater than 0 and " > "less than or equal to 1"); > } > + /** > + * Can't verify functional index function > + * reference on load because the function object > + * had not been registered in Tarantool yet. > + */ > + struct memtx_engine *engine = (struct memtx_engine *)space->engine; > + if (engine->state == MEMTX_OK && opts->functional_fid > 0) { > + struct func *func = func_cache_find(opts->functional_fid); > + if (func->def->language != FUNC_LANGUAGE_LUA || > + func->def->body == NULL || !func->def->is_deterministic || > + !func->def->is_sandboxed) { > + tnt_raise(ClientError, ER_WRONG_INDEX_OPTIONS, 0, > + "referenced function doesn't satisfy " > + "functional index constraints"); > + } > + } this part is obviously incorrect. alter should not depend on memtx_engine. And you don't need it at all. Please verify key parts inside the trigger on _func_index space, then you don't need to check for recovery state. -- Konstantin Osipov, Moscow, Russia