Re: Float value 'Infinity' is cast to numeric 1 on Windows

From: Kohei KaiGai <kaigai(at)heterodb(dot)com>
To: Taiki Kondo <tai-kondo(at)yk(dot)jp(dot)nec(dot)com>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Hiroshi Yanagisawa <hir-yanagisawa(at)ut(dot)jp(dot)nec(dot)com>
Subject: Re: Float value 'Infinity' is cast to numeric 1 on Windows
Date: 2017-09-27 11:06:55
Message-ID: CAOP8fzaLqeNFL99V0r=dxY9vXMxPhxnSV2KdL4-CSL8kz2sB9Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Hello,

Does it make sense to put a check of "isinf(val)" and ereport prior to
the snprintf()?
It is a lightweight check more than set_var_from_str().

Thanks,

2017-09-27 19:41 GMT+09:00 Taiki Kondo <tai-kondo(at)yk(dot)jp(dot)nec(dot)com>:
> Hi all,
>
> I build PostgreSQL 9.6.5 by Visual Studio 2013 on Windows, I found weird behavior on it.
>
> I execute following SQL, occurring ERROR is expected, but I got mysterious value 1.
>
>
> postgres=# select (float8 'inf')::numeric;
> numeric
> ---------
> 1
> (1 row)
>
>
> On Windows, at least Visual Studio, the string of float/double value meaning
> infinity is "1.#INF" not "inf". So, set_var_from_str() called from float8_numeric()
> in utils/adt/numeric.c will return numeric value 1, and no one checks this situation.
>
> This situation is also occurring by cast from float4.
>
> I wrote a patch to add check this situation.
> Please find attached.
>
>
> Sincerely,
>
> --
> Taiki Kondo
> NEC Solution Innovators, Ltd.
>
>
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

--
HeteroDB, Inc / The PG-Strom Project
KaiGai Kohei <kaigai(at)heterodb(dot)com>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2017-09-27 14:39:59 Re: [HACKERS] Float value 'Infinity' is cast to numeric 1 on Windows
Previous Message Taiki Kondo 2017-09-27 10:41:26 Float value 'Infinity' is cast to numeric 1 on Windows

Browse pgsql-hackers by date

  From Date Subject
Next Message amul sul 2017-09-27 11:07:22 Restrict concurrent update/delete with UPDATE of partition key
Previous Message Marko Tiikkaja 2017-09-27 10:52:33 200 = 199 + 1?