pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: luc.lavoie@usherbrooke.ca
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17573: timestamptz casting precision goes down as the year goes up
Date: Thu, 04 Aug 2022 18:37:01 -0400
Message-ID: <3675316.1659652621@sss.pgh.pa.us> (raw)
In-Reply-To: <17573-816a53478f1c08e2@postgresql.org>
References: <17573-816a53478f1c08e2@postgresql.org>

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





view thread (2+ messages)

Message-ID: <3675316.1659652621@sss.pgh.pa.us>
Permalink:  ../3675316.1659652621@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3675316.1659652621@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, luc.lavoie@usherbrooke.ca, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17573: timestamptz casting precision goes down as the year goes up
  In-Reply-To: <3675316.1659652621@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox