Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gSNhl-00071j-UX for pgsql-bugs@arkaria.postgresql.org; Thu, 29 Nov 2018 14:54:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gSNhk-0004xN-9j for pgsql-bugs@arkaria.postgresql.org; Thu, 29 Nov 2018 14:54:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gSNhk-0004xG-1e for pgsql-bugs@lists.postgresql.org; Thu, 29 Nov 2018 14:54:12 +0000 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gSNhi-0007KM-0h for pgsql-bugs@lists.postgresql.org; Thu, 29 Nov 2018 14:54:11 +0000 Received: by mail-io1-xd29.google.com with SMTP id w7so1757203iom.12 for ; Thu, 29 Nov 2018 06:54:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=JyLctejXi2+xcB8WfqqhYWeEBob9OklFCfQDPB7XsDU=; b=qtwYE4LbMV/UDxDl9lslhw3tWvB6ZroWLPqHFpUNGwzcHsmsXi/TT96+nSPpbmh7+U +X4T7mLyjOADlwssBnvlcNNNDhrFO1yC+X+ZBEPYgUdUwxr304AToYUyLX25GZD5hYSl Krl0J4O3MsZMhaOQBrkmxx2BjIYfZCslkWihez/NieMxxxGAS+D4nngGh0S6CDSGtfp8 +pSc/NX07JGYus1DHU5JrXOWNMszAml6hj1hZtaIHYeuPbTCesnIUbWABzW+UTDD0Zcd toAaZ2VCzubZx5SaPXSVmyfVtgtszOx8Hy/rW8bILfzSlgF5rxUO8/FIHKsI3Ry/66tJ fZZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=JyLctejXi2+xcB8WfqqhYWeEBob9OklFCfQDPB7XsDU=; b=U6OEOunKZyXPTSLDyjATQuzvalVkDvMFiRitwKrv8SX5j8c5+1LoiwwuFy+bz0r8+k /bfKBL9457OUjAV/WZt84y2L13AW6R7kE9t73V6aebiiQ/hNQcjoVGrAoK1FG/hZ/GqM stP+e+eAFB0cou3v0O8aHHyqHR+tXQnBNcgldmPW+31yFtXSgJfrSiPpoB0gLWT53E7d Oo6Y4coxz2zkqmUHzSamAkq26IdEymDdwd7IpnqCKQQcyX7YFIYWnEMeKNAUoge9VaHK 7pkv7xKRCq2/cKWqz0Th0ZBSxUY0NE70o6Lmot3XypEShstUq2drQNbjFJDLiCXnzovK TxgA== X-Gm-Message-State: AA+aEWarrGRAXI6kYYixE4EH4+ebqvGKquSs7wmHwG2J1Pdj7WtTeM5b K+7MV9znXR39px+lbrry4Q1zqiaY X-Google-Smtp-Source: AFSGD/VneMIzaXiii3dYCNt1ASFUph6k4BX0E3prQVTHca2Tc8bu/Pw/86QB3vcqpBYtn2n0usPyLg== X-Received: by 2002:a6b:e715:: with SMTP id b21mr1408149ioh.87.1543503246754; Thu, 29 Nov 2018 06:54:06 -0800 (PST) Received: from dhcp-193.raleigh.raritan.com (45-20-211-241.lightspeed.rlghnc.sbcglobal.net. [45.20.211.241]) by smtp.gmail.com with ESMTPSA id t64sm1078079itb.5.2018.11.29.06.54.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 06:54:05 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.0 \(3445.100.39\)) Subject: Re: BUG #15527: Issue converting from local date/time to 'timestamp with time zone' prior to dst transition From: Mike Davidson In-Reply-To: <15787.1543440639@sss.pgh.pa.us> Date: Thu, 29 Nov 2018 09:54:03 -0500 Cc: pgsql-bugs@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <15527-f1be0b4dc99ebbe7@postgresql.org> <15787.1543440639@sss.pgh.pa.us> To: Tom Lane X-Mailer: Apple Mail (2.3445.100.39) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Nov 28, 2018, at 4:30 PM, Tom Lane wrote: >=20 > =3D?utf-8?q?PG_Bug_reporting_form?=3D writes: >> We have an application that is storing time series data in postgres = using >> 'timestamp with time zone' field. Both the operating system and = postgres >> are configured using 'US/Eastern' time zone. No timezone is being = provided >> in the date/time values being inserted. We noticed that on 11/4/2018 = one >> hour worth of readings (from 1am to 2am US/Eastern) are missing. = Due to >> the dst rules for 'US/Eastern' the UTC offset should transition from = -04 to >> -05 on 11/4/2018 at 2am US/Eastern. However, please take a look at = the >> output below. It looks to me as if postgres is changing the UTC = offset from >> -04 to -05 at 1am instead of at 2am. I'm wondering if this is by = design. >=20 > In a fall-back transition, civil times between 1am and 2am are = ambiguous: > they could refer to either the first transition between those hours > (while still on DST) or the second transition (now on standard time). > Postgres assumes that an unlabeled input time between those hours is > to be read as standard time, which I'd agree is pretty arbitrary, > but the other possibilities aren't better. >=20 >> If that's the case there's no way to know if the date/time being >> inserted is 1am EDT (UTC -04) or 1am EST (UTC -05) >=20 > Well, yes, that's exactly the problem. It could be either. The only > real way to fix this is to change your data entry procedure so that > you specify a zone abbreviation or UTC offset when entering an = ambiguous > timestamp. Or you could set "timezone" to a non-DST-aware setting > and be sure to change it at exactly the right time. >=20 >> I looked at the documentation but didn't notice anything that >> specifically addressed this detail. >=20 > This behavior is pretty clearly documented in the source code: >=20 > * It's an invalid or ambiguous time due to timezone transition. = In a > * spring-forward transition, prefer the "before" interpretation; = in a > * fall-back transition, prefer "after". (We used to define and = implement > * this test as "prefer the standard-time interpretation", but that = rule > * does not help to resolve the behavior when both times are = reported as > * standard time; which does happen, eg Europe/Moscow in Oct 2014. = Also, > * in some zones such as Europe/Dublin, there is widespread = confusion > * about which time offset is "standard" time, so it's fortunate = that our > * behavior doesn't depend on that.) >=20 > but if this is mentioned anywhere in the SGML docs, I couldn't find it > in a quick search :-(. We should improve that. >=20 > regards, tom lane Tom, Makes sense=E2=80=A6thank you for the clarification.=20 Best regards, Mike