Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lqom5-0005b1-L2 for pgsql-bugs@arkaria.postgresql.org; Wed, 09 Jun 2021 03:21:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lqom3-0004uy-BP for pgsql-bugs@arkaria.postgresql.org; Wed, 09 Jun 2021 03:20:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lqom3-0004uq-3m for pgsql-bugs@lists.postgresql.org; Wed, 09 Jun 2021 03:20:59 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lqolw-0007QK-E1 for pgsql-bugs@postgresql.org; Wed, 09 Jun 2021 03:20:57 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1593KodY1264126; Tue, 8 Jun 2021 23:20:50 -0400 From: Tom Lane To: "David G. Johnston" cc: =?UTF-8?B?55SE5piO5rSL?= , "pgsql-bugs@postgresql.org" Subject: Re: setting the timezone parameter with space cause diff result In-reply-to: References: <37c04704.1327.179eab261fd.Coremail.zhenmingyang@yeah.net> <1123102.1623175370@sss.pgh.pa.us> <6229140a.5c5.179ee988fce.Coremail.zhenmingyang@yeah.net> Comments: In-reply-to "David G. Johnston" message dated "Tue, 08 Jun 2021 19:46:18 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1264124.1623208850.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Tue, 08 Jun 2021 23:20:50 -0400 Message-ID: <1264125.1623208850@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Tuesday, June 8, 2021, 甄明洋 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