pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feed From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: luc.lavoie@usherbrooke.ca
Subject: BUG #17573: timestamptz casting precision goes down as the year goes up
Date: Thu, 04 Aug 2022 21:12:37 +0000
Message-ID: <17573-816a53478f1c08e2@postgresql.org> (raw )
The following bug has been logged on the website:
Bug reference: 17573
Logged by: Luc Lavoie
Email address: luc.lavoie@usherbrooke.ca
PostgreSQL version: 14.4
Operating system: macOS 12.5
Description:
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.
select
'Exact p = 1 microsecond' as "message",
to_timestamp (extract (epoch from timestamptz '2022-08-01 00:00:00.000000
+00:00')) as "2022-08-01 00:00:00.000000",
to_timestamp (extract (epoch from timestamptz '2022-08-01 00:00:00.000001
+00:00')) as "2022-08-01 00:00:00.000001",
to_timestamp (extract (epoch from timestamptz '2022-08-01 00:00:00.000002
+00:00')) as "2022-08-01 00:00:00.000002",
to_timestamp (extract (epoch from timestamptz '2022-08-01 00:00:00.000003
+00:00')) as "2022-08-01 00:00:00.000003" ;
select
'Error p ~ 2 microseconds' as "message",
to_timestamp (extract (epoch from timestamptz '2361-08-01 00:00:00.000000
+00:00')) as "2361-08-01 00:00:00.000000",
to_timestamp (extract (epoch from timestamptz '2361-08-01 00:00:00.000001
+00:00')) as "2361-08-01 00:00:00.000001",
to_timestamp (extract (epoch from timestamptz '2361-08-01 00:00:00.000002
+00:00')) as "2361-08-01 00:00:00.000002",
to_timestamp (extract (epoch from timestamptz '2361-08-01 00:00:00.000003
+00:00')) as "2361-08-01 00:00:00.000003";
select
'Error p ~ 4 microseconds' as "message",
to_timestamp (extract (epoch from timestamptz '2713-08-01 00:00:00.000000
+00:00')) as "2713-08-01 00:00:00.000000",
to_timestamp (extract (epoch from timestamptz '2713-08-01 00:00:00.000001
+00:00')) as "2713-08-01 00:00:00.000001",
to_timestamp (extract (epoch from timestamptz '2713-08-01 00:00:00.000002
+00:00')) as "2713-08-01 00:00:00.000002",
to_timestamp (extract (epoch from timestamptz '2713-08-01 00:00:00.000003
+00:00')) as "2713-08-01 00:00:00.000003";
select
'Error p ~ 8 microseconds' as "message",
to_timestamp (extract (epoch from timestamptz '4022-08-01 00:00:00.000000
+00:00')) as "4022-08-01 00:00:00.000000",
to_timestamp (extract (epoch from timestamptz '4022-08-01 00:00:00.000010
+00:00')) as "4022-08-01 00:00:00.000010",
to_timestamp (extract (epoch from timestamptz '4022-08-01 00:00:00.000020
+00:00')) as "4022-08-01 00:00:00.000020",
to_timestamp (extract (epoch from timestamptz '4022-08-01 00:00:00.000030
+00:00')) as "4022-08-01 00:00:00.000030";
select
'Error p ~ 32 microseconds' as "message",
to_timestamp (extract (epoch from timestamptz '8022-08-01
00:00:00.000000')) as "8022-08-01 00:00:00.000000",
to_timestamp (extract (epoch from timestamptz '8022-08-01
00:00:00.000010')) as "8022-08-01 00:00:00.000010",
to_timestamp (extract (epoch from timestamptz '8022-08-01
00:00:00.000020')) as "8022-08-01 00:00:00.000020",
to_timestamp (extract (epoch from timestamptz '8022-08-01
00:00:00.000030')) as "8022-08-01 00:00:00.000030";
Results obtained
+-----------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+
|message |2022-08-01 00:00:00.000000 |2022-08-01
00:00:00.000001 |2022-08-01 00:00:00.000002 |2022-08-01
00:00:00.000003 |
+-----------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+
|Exact p = 1 microsecond|2022-08-01 00:00:00.000000 +00:00|2022-08-01
00:00:00.000001 +00:00|2022-08-01 00:00:00.000002 +00:00|2022-08-01
00:00:00.000003 +00:00|
+-----------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+
+------------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+
|message |2361-08-01 00:00:00.000000 |2361-08-01
00:00:00.000001 |2361-08-01 00:00:00.000002 |2361-08-01
00:00:00.000003 |
+------------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+
|Error p ~ 2 microseconds|2361-08-01 00:00:00.000000 +00:00|2361-08-01
00:00:00.000002 +00:00|2361-08-01 00:00:00.000002 +00:00|2361-08-01
00:00:00.000004 +00:00|
+------------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+
+------------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+
|message |2713-08-01 00:00:00.000000 |2713-08-01
00:00:00.000001 |2713-08-01 00:00:00.000002 |2713-08-01
00:00:00.000003 |
+------------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+
|Error p ~ 4 microseconds|2713-08-01 00:00:00.000000 +00:00|2713-08-01
00:00:00.000000 +00:00|2713-08-01 00:00:00.000004 +00:00|2713-08-01
00:00:00.000004 +00:00|
+------------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+
+-------------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+
|message |4022-08-01 00:00:00.000000 |4022-08-01
00:00:00.000010 |4022-08-01 00:00:00.000020 |4022-08-01
00:00:00.000030 |
+-------------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+
|Error p ~ 8 microseconds|4022-08-01 00:00:00.000000 +00:00|4022-08-01
00:00:00.000008 +00:00|4022-08-01 00:00:00.000024 +00:00|4022-08-01
00:00:00.000032 +00:00|
+-------------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+
+-------------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+
|message |8022-08-01 00:00:00.000000 |8022-08-01
00:00:00.000010 |8022-08-01 00:00:00.000020 |8022-08-01
00:00:00.000030 |
+-------------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+
|Error p ~ 32 microseconds|8022-08-01 00:00:00.000000 +00:00|8022-08-01
00:00:00.000000 +00:00|8022-08-01 00:00:00.000032 +00:00|8022-08-01
00:00:00.000032 +00:00|
+-------------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+
view thread (2+ messages) latest in thread
Message-ID: <17573-816a53478f1c08e2@postgresql.org>
Permalink: ../17573-816a53478f1c08e2@postgresql.org/
Also on: postgresql.org/message-id/17573-816a53478f1c08e2@postgresql.org
copy link · copy postgr.es
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: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, luc.lavoie@usherbrooke.ca
Subject: Re: BUG #17573: timestamptz casting precision goes down as the year goes up
In-Reply-To: <17573-816a53478f1c08e2@postgresql.org>
* 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