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 1mdwS3-0001cu-Pf for pgsql-bugs@arkaria.postgresql.org; Fri, 22 Oct 2021 15:27:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mdwS2-0005gB-Ny for pgsql-bugs@arkaria.postgresql.org; Fri, 22 Oct 2021 15:27:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mdwS2-0005fu-GV for pgsql-bugs@lists.postgresql.org; Fri, 22 Oct 2021 15:27:22 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mdwRz-0000yI-T1 for pgsql-bugs@lists.postgresql.org; Fri, 22 Oct 2021 15:27:22 +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 19MFRGDc2712290; Fri, 22 Oct 2021 11:27:16 -0400 From: Tom Lane To: edouard.hibon@free.fr cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17244: strange string to timestamp with time zone conversion due to summer time / winter time switch ? In-reply-to: <17244-bda5a623ad3ca0ca@postgresql.org> References: <17244-bda5a623ad3ca0ca@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Fri, 22 Oct 2021 14:12:02 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2712288.1634916436.1@sss.pgh.pa.us> Date: Fri, 22 Oct 2021 11:27:16 -0400 Message-ID: <2712289.1634916436@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > With current_setting('timezone') = 'Europe/Brussels', the following > conversion results are quite strange : > SELECT '2003-03-30 02:59:59'::timestamp with time zone < '2003-03-30 > 03:00:00'::timestamp with time zone returns False which sounds strange. Well, you're asking a silly question and getting a silly answer. In that zone, clocks advanced from 1:59:59 directly to 3:00:00 on that day, so that the time 02:59:59 didn't really exist. Our approach for such cases is to assume that the invalid time is meant to represent local standard time, making it 0:59:59 later than the DST transition instant, while 03:00:00 is read as exactly the transition instant. See https://www.postgresql.org/docs/current/datetime-invalid-input.html > This behavior might be not understandable from a user standpoint and may > conduct to some errors in the system. I would suggest to forbid the > conversion to timestamp with time zone for strings between '2003-03-30 > 02:00:00' and '2003-03-30 02:59:59' with an explicit error message saying > that the resulting timestamp doesn't correrspond to a real time due to the > winter time / summer time switch. If you'd made that suggestion about twenty years ago, we might have taken it, but at this point backwards compatibility is a pretty strong argument for not changing it. In any case, there's lots of precedent for this type of behavior, eg mktime(3) acts similarly on most Unix platforms. regards, tom lane