Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rxudU-00D3dN-6z for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Apr 2024 20:15:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rxudS-005CJY-Nc for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Apr 2024 20:15:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rxudS-005CJO-DX for pgsql-hackers@lists.postgresql.org; Fri, 19 Apr 2024 20:15:02 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rxudP-001rXU-QD for pgsql-hackers@lists.postgresql.org; Fri, 19 Apr 2024 20:15:01 +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 43JKEuHA2233392; Fri, 19 Apr 2024 16:14:56 -0400 From: Tom Lane To: Etsuro Fujita cc: Laurenz Albe , pgsql-hackers@lists.postgresql.org Subject: Re: postgres_fdw fails because GMT != UTC In-reply-to: References: <465248.1712211585@sss.pgh.pa.us> Comments: In-reply-to Etsuro Fujita message dated "Wed, 10 Apr 2024 20:30:59 +0900" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <2233357.1713557670.0@sss.pgh.pa.us> Date: Fri, 19 Apr 2024 16:14:56 -0400 Message-ID: <2233391.1713557696@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2233357.1713557670.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Etsuro Fujita writes: > On Thu, Apr 4, 2024 at 3:49=E2=80=AFPM Laurenz Albe wrote: >> On Thu, 2024-04-04 at 02:19 -0400, Tom Lane wrote: >>> I am not quite clear on how broken an installation needs to be to >>> reject "UTC" as a time zone setting, except that the breakage cannot >>> be subtle. However, I notice that our code in pgtz.c and other >>> places treats "GMT" as a hard-wired special case ... but not "UTC". >>> I wonder if we ought to modify those places to force "UTC" down the >>> same hard-wired paths. If we acted like that, this would have worked >>> no matter how misconfigured the installation was. >>> = >>> An alternative answer could be to change postgres_fdw to send "GMT" >>> not "UTC". That's ugly from a standards-compliance viewpoint, but >>> it would fix this problem even with a non-updated remote server, >>> and I think postgres_fdw is generally intended to work with even >>> very old remote servers. >>> = >>> Or we could do both. > +1 for both (assuming that the latter does not make the postgres_fdw > code complicated). I looked briefly at changing the server like this, and decided that it would be a little invasive, if only because there would be documentation and such to update. Example question: should we change the boot-time default value of the timezone GUC from "GMT" to "UTC"? Probably, but I doubt we want to back-patch that, nor does it seem like something to be messing with post-feature-freeze. So I'm in favor of working on that when the tree opens for v18, but not right now. However, we can change postgres_fdw at basically no cost AFAICS. That's the more important part anyway I think. If your own server burps because it's got a bad timezone database, you are probably in a position to do something about that, while you may have no control over a remote server. (As indeed the original complainant didn't.) So I propose to apply and back-patch the attached, and leave it at that for now. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="make-postgres_fdw-send-GMT-not-UTC.patch"; charset="us-ascii" Content-ID: <2233357.1713557670.2@sss.pgh.pa.us> Content-Description: make-postgres_fdw-send-GMT-not-UTC.patch Content-Transfer-Encoding: quoted-printable diff --git a/contrib/postgres_fdw/connection.c b/contrib/postgres_fdw/conn= ection.c index 603e043af4..33e8054f64 100644 --- a/contrib/postgres_fdw/connection.c +++ b/contrib/postgres_fdw/connection.c @@ -671,10 +671,12 @@ configure_remote_session(PGconn *conn) * anyway. However it makes the regression test outputs more predictabl= e. * * We don't risk setting remote zone equal to ours, since the remote - * server might use a different timezone database. Instead, use UTC - * (quoted, because very old servers are picky about case). + * server might use a different timezone database. Instead, use GMT + * (quoted, because very old servers are picky about case). That's + * guaranteed to work regardless of the remote's timezone database, + * because pg_tzset() hard-wires it (at least in PG 9.2 and later). */ - do_sql_command(conn, "SET timezone =3D 'UTC'"); + do_sql_command(conn, "SET timezone =3D 'GMT'"); = /* * Set values needed to ensure unambiguous data output from remote. (Th= is ------- =_aaaaaaaaaa0--