[Tarantool-patches] [PATCH v1 1/1] sql: fix cast of small negative DOUBLE to INTEGER

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Mon Jul 26 22:47:21 MSK 2021


Thanks for the patch!

> diff --git a/changelogs/unreleased/gh-6225-cast-of-small-negative-double-to-int.md b/changelogs/unreleased/gh-6225-cast-of-small-negative-double-to-int.md
> new file mode 100644
> index 000000000..9f5d62231
> --- /dev/null
> +++ b/changelogs/unreleased/gh-6225-cast-of-small-negative-double-to-int.md
> @@ -0,0 +1,4 @@
> +## bugfix/sql
> +
> +* Fixed assert on cast of DOUBLE value that greater than -1.0 and less than 0.0
> +  to INTEGER and UNSIGNED (gh-6255).

1. I tried to revert the patch and only got an error, not an assertion.

> diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c
> index e4ce233e0..6b95e41d3 100644
> --- a/src/box/sql/mem.c
> +++ b/src/box/sql/mem.c
> @@ -1322,7 +1322,7 @@ mem_get_uint(const struct Mem *mem, uint64_t *u)
>  	}
>  	if (mem->type == MEM_TYPE_DOUBLE) {
>  		double d = mem->u.r;
> -		if (d >= 0 && d < (double)UINT64_MAX) {
> +		if (d > -1.0 && d < (double)UINT64_MAX) {

2. I see there are 6 changes extending 0 to -1.0, but only 2
tests. Can you cover all the changed places?


More information about the Tarantool-patches mailing list