Lists: | pgsql-bugs |
---|
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: | [email protected] |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
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.
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | nguyenkhacchinh(at)hotmail(dot)com |
Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #17305: to_timestamp accept dates rejected by timestamptz cast |
Date: | 2021-12-02 18:54:15 |
Message-ID: | [email protected] |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-bugs |
PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> 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.
It is not, and I don't see the documentation claiming that it is.
regards, tom lane
From: | Chinh Nguyen <nguyenkhacchinh(at)hotmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: BUG #17305: to_timestamp accept dates rejected by timestamptz cast |
Date: | 2021-12-03 15:06:23 |
Message-ID: | DM6PR02MB67940A966A28BAD4E7358194A46A9@DM6PR02MB6794.namprd02.prod.outlook.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-bugs |
I am simply going by this tip in the documentation:
"to_timestamp and to_date exist to handle input formats that cannot be converted by simple casting. For most standard date/time formats, simply casting the source string to the required data type works, and is much easier. Similarly, to_number is unnecessary for standard numeric representations."
It's interesting that 0000-02-31 is acceptable for one but not the other. But given the unlikelihood of seeing this date in data that I process, this behaviour is simply a curiosity.
Regards.
________________________________
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Sent: December 2, 2021 1:54 PM
To: nguyenkhacchinh(at)hotmail(dot)com <nguyenkhacchinh(at)hotmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17305: to_timestamp accept dates rejected by timestamptz cast
PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> 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.
It is not, and I don't see the documentation claiming that it is.
regards, tom lane