From: Alexander Turenko <alexander.turenko@tarantool.org> To: Sergey Nikiforov <void@tarantool.org> Cc: tarantool-patches@dev.tarantool.org, Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH] lua/key_def: fix compare_with_key() part count check Date: Thu, 17 Dec 2020 19:41:09 +0300 [thread overview] Message-ID: <20201217164109.xpzksjearubo5lnc@tkn_work_nb> (raw) In-Reply-To: <f208360f-a5d6-d674-138e-8e31ff7f9b30@tarantool.org> On Thu, Dec 17, 2020 at 04:27:09PM +0300, Sergey Nikiforov wrote: > > > 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? > > Because we need part_count later. With box_key_def_validate_key() we would > have to call mp_decode_array() twice or add yet another parameter to > box_key_def_validate_key(). Is that good idea? We can't change box_key_def_validate_key() parameters, it is in the public C API. The code would look more accurate if we'll reuse the public functions (box_key_def_validate_key() and box_tuple_compare_with_key()) here. However, right, it'll decode the msgpack array size twice. I think it is negligible comparing to the validation of the key against given key_def. If'll need maximum performance from the module, we'll add an option to skip validation at all. > > > > + > > > if (key_validate_parts(key_def, key, part_count, true, > > > &key_end) != 0) { > > > region_truncate(region, region_svp);
next prev parent reply other threads:[~2020-12-17 16:41 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-12-14 15:35 Sergey Nikiforov 2020-12-16 22:34 ` Vladislav Shpilevoy 2020-12-17 11:28 ` Alexander Turenko 2020-12-17 13:27 ` Sergey Nikiforov 2020-12-17 16:41 ` Alexander Turenko [this message] 2020-12-20 16:33 ` Vladislav Shpilevoy 2020-12-17 12:37 ` Alexander Turenko
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20201217164109.xpzksjearubo5lnc@tkn_work_nb \ --to=alexander.turenko@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --cc=void@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH] lua/key_def: fix compare_with_key() part count check' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox