Re: Infinities in type numeric
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-06-16T17:24:56Z
Lists: pgsql-hackers
Attachments
- numeric-infinities-3.patch (text/x-diff) patch
Dean Rasheed <dean.a.rasheed@gmail.com> writes: > On Fri, 12 Jun 2020 at 02:16, Tom Lane <tgl@sss.pgh.pa.us> wrote: >> * I had to invent some semantics for non-standardized functions, >> particularly numeric_mod, numeric_gcd, numeric_lcm. This area >> could use review to be sure that I chose desirable behaviors. > I think the semantics you've chosen for numeric_mod() are reasonable, > and I think they're consistent with POSIX fmod(). Ah, I had not thought to look at fmod(). I see that POSIX treats x-is-infinite the same as y-is-zero: raise EDOM and return NaN. I think it's okay to deviate to the extent of throwing an error in one case and returning NaN in the other, but I added a comment noting the difference. > Similar arguments apply to lcm(), so I'd say that both gcd() and lcm() > should return 'NaN' if either input is 'Inf' or 'NaN'. Works for me; that's easier anyway. The attached v3 patch fixes these things and also takes care of an oversight in v2: I'd made numeric() apply typmod restrictions to Inf, but not numeric_in() or numeric_recv(). I believe the patch itself is in pretty good shape now, though there are still some issues elsewhere as noted in the first message in this thread. Thanks for reviewing! regards, tom lane
Commits
-
Support infinity and -infinity in the numeric data type.
- a57d312a7706 14.0 landed