Change seconds argument of make_*() functions to numeric

Started by Peter Eisentrautalmost 6 years ago3 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t43412
psql -h localhost -U postgres

Built from patchset v1 (message #1), July 27, 2026 at 06:01 PM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t43412_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t43412_1 && git checkout t43412_1

Patchset v1 (message #1) is on t43412_1

Jump to latest
#1Peter Eisentraut
peter_e@gmx.net

Along with the discussed change of the return type of EXTRACT from
float8 to numeric [0]/messages/by-id/42b73d2d-da12-ba9f-570a-420e0cce19d9@phystech.edu, I was looking around what other date/time APIs
might be using float arguments or return values. The only thing left
appears to be the functions make_time, make_timestamp, make_timestamptz,
and make_interval, which take an argument specifying the seconds, which
has type float8 right now. I'm proposing the attached patch to change
that to numeric.

Can we change the arguments, as proposed here, or do we need to add
separate overloaded versions and leave the existing versions in place?

[0]: /messages/by-id/42b73d2d-da12-ba9f-570a-420e0cce19d9@phystech.edu
/messages/by-id/42b73d2d-da12-ba9f-570a-420e0cce19d9@phystech.edu

Attachments:

t43412_1
0001-Change-seconds-argument-of-make_-functions-to-numeri.patchtext/plain; charset=UTF-8; name=0001-Change-seconds-argument-of-make_-functions-to-numeri.patch; x-mac-creator=0; x-mac-type=0Download+67-56
#2Pavel Stehule
pavel.stehule@gmail.com
In reply to: Peter Eisentraut (#1)
Re: Change seconds argument of make_*() functions to numeric

čt 17. 12. 2020 v 17:43 odesílatel Peter Eisentraut <
peter.eisentraut@enterprisedb.com> napsal:

Along with the discussed change of the return type of EXTRACT from
float8 to numeric [0], I was looking around what other date/time APIs
might be using float arguments or return values. The only thing left
appears to be the functions make_time, make_timestamp, make_timestamptz,
and make_interval, which take an argument specifying the seconds, which
has type float8 right now. I'm proposing the attached patch to change
that to numeric.

Can we change the arguments, as proposed here, or do we need to add
separate overloaded versions and leave the existing versions in place?

What this change does with views. Can it break upgrade by pg_upgrade?

Regards

Pavel

Show quoted text

[0]:

/messages/by-id/42b73d2d-da12-ba9f-570a-420e0cce19d9@phystech.edu

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#1)
Re: Change seconds argument of make_*() functions to numeric

Peter Eisentraut <peter.eisentraut@enterprisedb.com> writes:

Along with the discussed change of the return type of EXTRACT from
float8 to numeric [0], I was looking around what other date/time APIs
might be using float arguments or return values. The only thing left
appears to be the functions make_time, make_timestamp, make_timestamptz,
and make_interval, which take an argument specifying the seconds, which
has type float8 right now. I'm proposing the attached patch to change
that to numeric.

I don't really see the point here. Since the seconds value is constrained
to 0..60 and will be rounded off to microseconds, you would have to work
seriously hard to find an example where float8 roundoff error could be
a problem. I don't think we should take whatever speed and compatibility
hit is implied by using numeric instead of float8.

(make_interval in theory could be an exception, since it doesn't constrain
the range of seconds values. But I still don't believe there's a problem
in practice.)

Can we change the arguments, as proposed here, or do we need to add
separate overloaded versions and leave the existing versions in place?

Since there's no implicit float8 to numeric cast, removing the existing
versions could quite easily cause failures of queries that work today.

regards, tom lane