[Tarantool-patches] [PATCH v5 42/52] sql: introduce mem_to_str() and mem_to_str0()

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Wed Apr 14 01:58:05 MSK 2021


Thanks for working on this!

> diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c
> index 9a0234e60..be7b47e76 100644
> --- a/src/box/sql/mem.c
> +++ b/src/box/sql/mem.c
> @@ -822,6 +822,130 @@ mem_to_number(struct Mem *mem)

<...>

> +
> +int
> +mem_to_str0(struct Mem *mem)
> +{
> +	if ((mem->flags & (MEM_Str | MEM_Term)) == (MEM_Str | MEM_Term))
> +		return 0;
> +	if ((mem->flags & MEM_Str) != 0)
> +		return str_to_str0(mem);
> +	if ((mem->flags & (MEM_Int | MEM_UInt)) != 0)
> +		return int_to_str0(mem);
> +	if ((mem->flags & MEM_Real) != 0)
> +		return double_to_str0(mem);
> +	if ((mem->flags & MEM_Bool) != 0)
> +		return bool_to_str0(mem);
> +	if ((mem->flags & MEM_Blob) != 0) {
> +		if ((mem->flags & MEM_Subtype) == 0)
> +			return bin_to_str0(mem);
> +		if (mp_typeof(*mem->z) == MP_MAP)
> +			return map_to_str0(mem);
> +		return array_to_str0(mem);
> +	}
> +	return -1;
> +}
> +
> +int
> +mem_to_str(struct Mem *mem)
> +{
> +	if ((mem->flags & MEM_Str) != 0)
> +		return 0;
> +	if ((mem->flags & (MEM_Int | MEM_UInt)) != 0)
> +		return int_to_str0(mem);
> +	if ((mem->flags & MEM_Real) != 0)
> +		return double_to_str0(mem);
> +	if ((mem->flags & MEM_Bool) != 0)
> +		return bool_to_str0(mem);
> +	if ((mem->flags & MEM_Blob) != 0) {
> +		if ((mem->flags & MEM_Subtype) == 0)
> +			return bin_to_str(mem);
> +		if (mp_typeof(*mem->z) == MP_MAP)
> +			return map_to_str0(mem);
> +		return array_to_str0(mem);
> +	}
> +	return -1;

In the old function there was an assertion that only simple types
are passed (no Aggs, Frames). Please, keep it, or add a diag_set()
here. The same above.


More information about the Tarantool-patches mailing list