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 1lqg41-0005VI-VP for pgsql-bugs@arkaria.postgresql.org; Tue, 08 Jun 2021 18:02:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lqg40-0004aG-QP for pgsql-bugs@arkaria.postgresql.org; Tue, 08 Jun 2021 18:02:56 +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 1lqg40-0004a8-Jt for pgsql-bugs@lists.postgresql.org; Tue, 08 Jun 2021 18:02:56 +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 1lqg3v-000387-Rk for pgsql-bugs@postgresql.org; Tue, 08 Jun 2021 18:02:55 +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 158I2ojQ1123103; Tue, 8 Jun 2021 14:02:50 -0400 From: Tom Lane To: =?UTF-8?B?55SE5piO5rSL?= cc: pgsql-bugs@postgresql.org Subject: Re: setting the timezone parameter with space cause diff result In-reply-to: <37c04704.1327.179eab261fd.Coremail.zhenmingyang@yeah.net> References: <37c04704.1327.179eab261fd.Coremail.zhenmingyang@yeah.net> Comments: In-reply-to =?UTF-8?B?55SE5piO5rSL?= message dated "Tue, 08 Jun 2021 16:17:09 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1123101.1623175370.1@sss.pgh.pa.us> Date: Tue, 08 Jun 2021 14:02:50 -0400 Message-ID: <1123102.1623175370@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =?UTF-8?B?55SE5piO5rSL?= writes: > /* timezone string with space */ > postgres=# set timezone=' +04:00 '; > SET > postgres=# select now(); > now > ------------------------------- > 2021-06-08 05:14:36.486693-03 > (1 row) What is happening here is that the setting is being interpreted much like 'X+04:00Y'. That is, it's taken as a POSIX timezone specifier with standard-time abbreviation being ' ', daylight- savings abbreviation also being ' ', and the daylight-savings offset and transition rules all being defaulted. Your example without any spaces is recognized as a POSIX timezone spec with no DST part, so that's why it behaves differently. There's certainly room to quibble about whether a single space ought to be considered a valid zone abbreviation. However, this behavior comes directly from the IANA tzcode library, so I'm hesitant to change it. regards, tom lane