[Tarantool-patches] [PATCH v1 1/1] sql: allow to convert big real values to integer

Nikita Pettik korablev at tarantool.org
Thu Dec 5 15:36:06 MSK 2019


On 23 Nov 14:48, Mergen Imeev wrote:
> > BTW below I see path which is executed when
> > is_forced == false. And it is also about same wrong conversion. Please
> > check it as well and add test case.
> > 
> I found that is_forced variable did nothing it this code.
> Removed it from code along with "if" checked it.

If it is unused, please move this refactoring to a separate patch.

> diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
> index ab86be9..450e21d 100644
> --- a/src/box/sql/vdbe.c
> +++ b/src/box/sql/vdbe.c
> @@ -322,13 +322,16 @@ mem_apply_type(struct Mem *record, enum field_type type)
>  		if ((record->flags & MEM_UInt) == MEM_UInt)
>  			return 0;
>  		if ((record->flags & MEM_Real) == MEM_Real) {
> -			int64_t i = (int64_t) record->u.r;
> -			if (i == record->u.r)
> -				mem_set_int(record, record->u.r,
> -					    record->u.r <= -1);
> +			double d = record->u.r;
> +			int64_t i = (int64_t) d;
> +			uint64_t u = (uint64_t) d;
> +			if (i == d)
> +				mem_set_int(record, d, d <= -1);

Nit: mem_set_int(record, i, i <= -1;);

> +			else if (u == d)
> +				mem_set_u64(record, d);

Nit: mem_set_u64(record, u);



More information about the Tarantool-patches mailing list