Re: Allow round() function to accept float and double precision
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Sayyid Ali Sajjad Rizavi <sasrizavi@gmail.com>,
pgsql-hackers@lists.postgresql.org
Date: 2022-12-01T01:45:38Z
Lists: pgsql-hackers
David Rowley <dgrowleyml@gmail.com> writes: > We do have some weirdness in some existing overloaded functions. > pg_size_pretty() is an example. > If you run: SELECT pg_size_pretty(1000); you get: > ERROR: function pg_size_pretty(integer) is not unique Yeah, you have to be careful about that when proposing to overload a function name. > That occurs because we don't know if we should promote the INT into a > BIGINT or into a NUMERIC. We have a pg_size_pretty() function for each > of those. I don't think the same polymorphic type resolution problem > exists for REAL, FLOAT8 and NUMERIC. I would counsel against bothering with a REAL version. FLOAT8 will cover that case just fine. > I'm unsure what the repercussions of the fact that REAL and FLOAT8 are > not represented as decimals. The main thing is that I think the output will still have to be NUMERIC, or you're going to get complaints about "inaccurate" results. Before we got around to inventing infinities for NUMERIC, that choice would have been problematic, but now I think it's OK. regards, tom lane
Commits
-
Doc: add example of round(v, s) with negative s.
- e10799aa252c 15.2 landed
- a475157e6bf0 13.10 landed
- a109a0bb50ad 16.0 landed
- 7ec2bfe9e031 14.7 landed