Thread
Commits
-
Fix behavior when converting a float infinity to numeric.
- 72d4fd08ea63 9.2.24 landed
- 2e82fba0e6a9 9.3.20 landed
- def03e4bfe30 9.6.6 landed
- c38575edce0d 9.4.15 landed
- ad56dbd6c0b8 9.5.10 landed
- 7769fc000aa3 11.0 landed
- 07ea925e20ee 10.0 landed
-
Float value 'Infinity' is cast to numeric 1 on Windows
Taiki Kondo <tai-kondo@yk.jp.nec.com> — 2017-09-27T10:41:26Z
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. -
Re: Float value 'Infinity' is cast to numeric 1 on Windows
Kohei KaiGai <kaigai@heterodb.com> — 2017-09-27T11:06:55Z
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@yk.jp.nec.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@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-hackers > -- HeteroDB, Inc / The PG-Strom Project KaiGai Kohei <kaigai@heterodb.com>
-
Re: [HACKERS] Float value 'Infinity' is cast to numeric 1 on Windows
Tom Lane <tgl@sss.pgh.pa.us> — 2017-09-27T14:39:59Z
Kohei KaiGai <kaigai@heterodb.com> writes: > Does it make sense to put a check of "isinf(val)" and ereport prior to > the snprintf()? Yeah, that was my reaction too. Obviously this wasn't thought about in the original coding ... regards, tom lane