[PATCH v4 4/4] box: introduce functional indexes

Konstantin Osipov kostja at tarantool.org
Wed Jul 24 23:44:59 MSK 2019


* Kirill Shcherbatov <kshcherbatov at tarantool.org> [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 <new> /* for placement new */
>  #include <stdio.h> /* snprintf() */
>  #include <ctype.h>
> @@ -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



More information about the Tarantool-patches mailing list