BUG #17305: to_timestamp accept dates rejected by timestamptz cast

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: nguyenkhacchinh(at)hotmail(dot)com
Subject: BUG #17305: to_timestamp accept dates rejected by timestamptz cast
Date: 2021-12-01 13:59:30
Message-ID: 17305-f46fefde8303adf0@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17305
Logged by: Chinh Nguyen
Email address: nguyenkhacchinh(at)hotmail(dot)com
PostgreSQL version: 10.19
Operating system: Linux
Description:

I don't know if this is a bug or just an unusual behavior. I had assumed,
per the documentation, that function to_timestamp() is the same as
timestamptz but with control for different formats.

The following dates are all rejected by timestamptz (e.g., select
'0000-01-01T00:00:01Z'::timestamptz):
0000-01-01T00:00:01Z, 0000-02-29T00:00:01Z, 0000-02-30T00:00:01Z,
0000-02-31T00:00:01Z

But they are accepted by to_timestamp (e.g., select to_timestamp('0000-01-01
00:00:00+00','YYYY-MM-DDThh24:mi:ssZ')). The results from to_timestamp
are:
0001-01-01 00:00:00+00 BC, 0001-02-29 00:00:00+00 BC, 0001-03-01 00:00:00+00
BC, 0001-03-02 00:00:00+00 BC

My version is 10.19 but I also tested against an online test db running
11.10.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alexander Korotkov 2021-12-01 22:08:27 Re: BUG #17302: gist index prevents insertion of some data
Previous Message Michael Paquier 2021-12-01 07:19:44 Re: pg_upgrade test for binary compatibility of core data types