From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Mon, 10 Jun 2019 12:44:33 +0300 From: Vladimir Davydov Subject: Re: [PATCH v2 3/9] box: rework func cache update machinery Message-ID: <20190610094433.3dl5lphc3iq25py4@esperanza> 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 List-ID: On Thu, Jun 06, 2019 at 03:03:59PM +0300, Kirill Shcherbatov wrote: > diff --git a/src/box/func.c b/src/box/func.c > index 098bc02b6..5051286a3 100644 > --- a/src/box/func.c > +++ b/src/box/func.c > @@ -475,17 +475,18 @@ func_call(struct func *func, box_function_ctx_t *ctx, const char *args, > } > > void > -func_update(struct func *func, struct func_def *def) > +func_delete(struct func *func) > { > func_unload(func); > free(func->def); > - func->def = def; > + free(func); > } > > void > -func_delete(struct func *func) > +func_reuse_runtime(struct func *new_func, struct func *old_func) > { > - func_unload(func); > - free(func->def); > - free(func); > + new_func->module = old_func->module; > + new_func->func = old_func->func; > + old_func->module = NULL; > + old_func->func = NULL; > } If you look at the code coverage, you'll see that this function isn't covered by any test, because we never update functions - only create or drop them. Since this code leads to a new virtual function, let's simply drop it? I mean, - raise ER_UNSUPPORTED in on_replace_dd_func/UPDATE, - replace func_cache_replace with func_cache_insert, which would panic if the function with the same id/name already exists. This would simplify the code quite a bit. If anybody needs to alter the definition of an existing function, we can do it later.