[tarantool-patches] Re: [PATCH v2 5/8] sql: introduce a signature_mask for functions

Konstantin Osipov kostja at tarantool.org
Tue Aug 13 01:04:27 MSK 2019


* Kirill Shcherbatov <kshcherbatov at tarantool.org> [19/08/08 17:53]:
> This patch replaces nArgs field with signature_mask bitmask that
> allows to use an only hash table entry for all builtin functions
> overloads.
> 
> The code refactoring is not a goal of this patch: the most of
> affected code would be removed in following patches. The role of
> this patch itself is to introduce such mechanism (signature_mask)
> in Tarantool's SQL.
> 
> Needed for #2200, #4113, #2233
> ---
>  src/box/sql/sqlInt.h   | 70 ++++++++++++++++++++------------
>  src/box/sql/callback.c | 22 +++-------
>  src/box/sql/func.c     | 91 ++++++++++++++++++------------------------
>  src/box/sql/main.c     |  4 +-
>  src/box/sql/vdbeaux.c  |  6 ++-
>  5 files changed, 94 insertions(+), 99 deletions(-)
> 
> diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
> index 941c87420..114ac0e4b 100644
> --- a/src/box/sql/sqlInt.h
> +++ b/src/box/sql/sqlInt.h
> @@ -1254,7 +1254,20 @@ struct type_def {
>   * field is used by per-connection app-def functions.
>   */
>  struct FuncDef {
> -	i8 nArg;		/* Number of arguments.  -1 means unlimited */
> +	/**
> +	 * A bitmask representing all supported function
> +	 * overloads. The function supports argc == n iff this
> +	 * bitmask has bit n set 1. In particular case, a bitmask
> +	 * (~0) means this function works with any possible
> +	 * argument.
> +	 *
> +	 * The count of arguments for function is limited with
> +	 * (CHAR_BITS*sizeof(uint64_t) - 1). When the highest bit
> +	 * of the mask is set, this means that greater values
> +	 * are supported. E.g. greatest function works correctly
> +	 * with any number of input arguments.
> +	 */
> +	uint64_t signature_mask;

Good idea, but why make the mask sooo big?-)))
I don't think we have more than 3 arguments in any overloaded
function?

> +	if (!column_mask_fieldno_is_set(p->signature_mask, (uint32_t)nArg))
>  		return 0;

Are you sure you want to use column mask api just to test a bit?


-- 
Konstantin Osipov, Moscow, Russia




More information about the Tarantool-patches mailing list