From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: 甄明洋 <zhenmingyang@yeah.net>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: setting the timezone parameter with space cause diff result
Date: Tue, 08 Jun 2021 23:20:50 -0400
Message-ID: <1264125.1623208850@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwaiJ-DwpjatbVFpxjGvYmttP-GskRFf6=3vzj3xswEMGA@mail.gmail.com>
References: <37c04704.1327.179eab261fd.Coremail.zhenmingyang@yeah.net>
<1123102.1623175370@sss.pgh.pa.us>
<6229140a.5c5.179ee988fce.Coremail.zhenmingyang@yeah.net>
<CAKFQuwaiJ-DwpjatbVFpxjGvYmttP-GskRFf6=3vzj3xswEMGA@mail.gmail.com>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Tuesday, June 8, 2021, 甄明洋 <zhenmingyang@yeah.net> wrote:
>> Here is an example, which seems to be a problem of parsing, if format
>> string with FF and TZH:TZM, but the datetime string without fractional
>> seconds will cause parsing misalignment,
> Yes, with a template language this complex it is possible that invalid
> input will mis-parse instead of provoking an error. Use regexes if you
> need to validate the input format - all the parser should really be relied
> upon to do is take a valid input and convert it.
TBH, if we simply took away to_timestamp(), most users would be better off.
I do not think I've ever seen a single complaint about it that didn't
involve an input format that timestamp_in doesn't handle as well or
better.
to_timestamp with a normal-looking format is an antipattern. Just cast
the string to timestamp(tz), instead. Consider to_timestamp *only*
after you find that doesn't work.
regards, tom lane
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, david.g.johnston@gmail.com, zhenmingyang@yeah.net
Subject: Re: setting the timezone parameter with space cause diff result
In-Reply-To: <1264125.1623208850@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