pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gary Bernhardt <gary.bernhardt@gmail.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Converting to UTC multiple times converts back to local time zone
Date: Mon, 25 Jun 2018 17:40:27 -0700
Message-ID: <1529973627.48469.1420256816.1159290F@webmail.messagingengine.com> (raw)
In-Reply-To: <CAKFQuwaUeC-VqtWDu_ASVGaWh1ktppF1HqN_5Nb16DRe6-AXOQ@mail.gmail.com>
References: <1529970473.36096.1420218376.3C13DF11@webmail.messagingengine.com>
	<CAKFQuwYeHxefXOWmF_fXOM=MfR=QOz=Uas-HNz5_fA=R-koUfw@mail.gmail.com>
	<1529972735.44579.1420252720.11BFA61D@webmail.messagingengine.com>
	<CAKFQuwaUeC-VqtWDu_ASVGaWh1ktppF1HqN_5Nb16DRe6-AXOQ@mail.gmail.com>

The last example in my original email showed this happening where one
"AT TIME ZONE" is in a subquery and the other is in the outer query.
Imagine that scaled up to a large, complex query; and imagine that it
eventually grows a redundant "AT TIME ZONE" because someone modifying an
outer query doesn't realize that a deep subquery is already doing "AT
TIME ZONE". Now the time is suddenly in the wrong zone, but the
programmer explicitly asked for the timestamp to be in UTC.
We can certainly call that a mistake in the query (it's redundant if
nothing else). But I would never expect the value to switch back to
local time when I add "AT TIME ZONE 'utc'".
On Mon, Jun 25, 2018, at 5:32 PM, David G. Johnston wrote:
> On Mon, Jun 25, 2018 at 5:25 PM, Gary Bernhardt
> <gary.bernhardt@gmail.com> wrote:>> On Mon, Jun 25, 2018, at 5:20 PM, David G. Johnston wrote:
>>  > I'll agree that this was a surprising finding for me too, but in
>>  > the overall scheme of how PostgreSQL works, and other features it
>>  > provides (e.g., TimeZone GUC and to_char()) it fits.
>>
>> Thanks, David. I find this behavior quite off-putting, but I'm happy
>> to take your word that it's intended and consistent with other
>> features.> 
> Care to be more specific?  You didn't really provide an example that
> gives others insight into why you would use "AT TIME ZONE" twice in
> the same expression.> 
> David J.
> 

view thread (8+ messages)  latest in thread

Message-ID: <1529973627.48469.1420256816.1159290F@webmail.messagingengine.com>
Permalink:  ../1529973627.48469.1420256816.1159290F@webmail.messagingengine.com/
Also on:    postgresql.org/message-id/1529973627.48469.1420256816.1159290F@webmail.messagingengine.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: gary.bernhardt@gmail.com, david.g.johnston@gmail.com
  Subject: Re: Converting to UTC multiple times converts back to local time zone
  In-Reply-To: <1529973627.48469.1420256816.1159290F@webmail.messagingengine.com>
  References: <1529970473.36096.1420218376.3C13DF11@webmail.messagingengine.com> <CAKFQuwYeHxefXOWmF_fXOM=MfR=QOz=Uas-HNz5_fA=R-koUfw@mail.gmail.com> <1529972735.44579.1420252720.11BFA61D@webmail.messagingengine.com> <CAKFQuwaUeC-VqtWDu_ASVGaWh1ktppF1HqN_5Nb16DRe6-AXOQ@mail.gmail.com> <1529973627.48469.1420256816.1159290F@webmail.messagingengine.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox