[Tarantool-patches] [PATCH] lua/key_def: fix compare_with_key() part count check

Alexander Turenko alexander.turenko at tarantool.org
Thu Dec 17 14:28:48 MSK 2020


> > diff --git a/src/box/lua/key_def.c b/src/box/lua/key_def.c
> > index a781aeff9..674891a85 100644
> > --- a/src/box/lua/key_def.c
> > +++ b/src/box/lua/key_def.c
> > @@ -362,6 +362,15 @@ lbox_key_def_compare_with_key(struct lua_State *L)
> >  	size_t key_len;
> >  	const char *key_end, *key = lbox_encode_tuple_on_gc(L, 3, &key_len);
> >  	uint32_t part_count = mp_decode_array(&key);
> > +
> > +	if (part_count > key_def->part_count) {
> > +		region_truncate(region, region_svp);
> > +		tuple_unref(tuple);
> > +		diag_set(ClientError, ER_KEY_PART_COUNT,
> > +			 key_def->part_count, part_count);
> > +		return luaT_error(L);
> > +	}
> 
> Why this check and the call below can't be all simply
> replaces with box_key_def_validate_key() call?

I agree.

I introduced this function to use in the corresponding place of the
tuple-keydef code:

https://github.com/tarantool/tuple-keydef/blob/10c00a9aa289bb16446239edfa056ee48b467161/tuple/keydef.c#L517

> 
> > +
> >  	if (key_validate_parts(key_def, key, part_count, true,
> >  			       &key_end) != 0) {
> >  		region_truncate(region, region_svp);


More information about the Tarantool-patches mailing list