Re: BUG #17573: timestamptz casting precision goes down as the year goes up - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #17573: timestamptz casting precision goes down as the year goes up
Date
Msg-id 3675316.1659652621@sss.pgh.pa.us
Whole thread Raw
In response to BUG #17573: timestamptz casting precision goes down as the year goes up  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> timestamptz casting on year 2022 values returns a precision of one
> microsecond (as it is expected).
> As the year goes up, the precision goes down as the script below will show
> for years 2022, 23621, 2713, 4022, and 8022.

The issue here is not with the timestamp, nor even with the extract().
It's with your use of to_timestamp(), which takes float8, which has
limited precision.  The precision is disappearing in the implicit
cast to float8.

Prior to v14, there was also an issue with extract() returning float8,
but nowadays it returns numeric.  If you look directly at the extract()
results you'll see no precision is lost.

Maybe we should invent a variant of to_timestamp that takes numeric, but
the use-case seems pretty niche ...

            regards, tom lane



pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #17573: timestamptz casting precision goes down as the year goes up
Next
From: PG Bug reporting form
Date:
Subject: BUG #17574: Attaching an invalid index to partition head make head index invalid forever