pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter J. Holzer <hjp-pgsql@hjp.at>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15388: time convert error when use AT TIME ZONE '+8'
Date: Tue, 18 Sep 2018 14:27:50 -0400
Message-ID: <19153.1537295270@sss.pgh.pa.us> (raw)
In-Reply-To: <20180918163653.4lzayhdliejl3hkj@hjp.at>
References: <153724095414.13490.12512426893930004410@wrigleys.postgresql.org>
	<20541.1537242305@sss.pgh.pa.us>
	<20180918163653.4lzayhdliejl3hkj@hjp.at>

"Peter J. Holzer" <hjp-pgsql@hjp.at> writes:
> On 2018-09-17 23:45:05 -0400, Tom Lane wrote:
>> Another issue to keep in mind is that in POSIX time zone names,
>> positive offsets are used for locations west of Greenwich. Everywhere
>> else, PostgreSQL follows the ISO-8601 convention that positive timezone
>> offsets are east of Greenwich.

> I notice that '+8' doesn't match any of the documented formats.

[ pokes around for awhile... ] You're right, but there's more there than
meets the eye.  Purely-numeric zone specifications tend to have different
interpretations depending on context.  Datetime input has one set of
conventions, cf table 8.12 here:
https://www.postgresql.org/docs/current/static/datatype-datetime.html#DATATYPE-DATETIME-INPUT
while the timezone parameter has some other conventions documented on the
SET reference page.  Meanwhile, AT TIME ZONE doesn't do either of those
things but goes straight for the symbolic case (cf timestamp_zone()).
It's all kind of a mess.

> It is obviously parsed as the last one, with STD as an empty strings,
> but POSIX specifies that this must be "no less than three, nor more than
> {TZNAME_MAX}, bytes", so an empty STD isn't allowed. 

Yeah.  That was intentional, as localtime.c contains this comment:

	/* we allow empty STD abbrev, unlike IANA */

but I wonder whether it's such a hot idea.  The other types of
purely-numeric zone specifications seem to all follow the ISO sign
convention, but this allows purely-numeric input that uses the POSIX
sign convention.  I wonder if we should revert this code to match the
IANA upstream, so as to reduce confusion.  But then AT TIME ZONE '+8'
would fail, unless we stuck additional code in there.  (Then again,
failing might be better than silently changing sign convention.)

In any case, it might be a good idea for section 8.5.3 to mention that
it's not trying to cover numeric zone specifications.

			regards, tom lane




view thread (4+ messages)

Message-ID: <19153.1537295270@sss.pgh.pa.us>
Permalink:  ../19153.1537295270@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/19153.1537295270@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, hjp-pgsql@hjp.at
  Subject: Re: BUG #15388: time convert error when use AT TIME ZONE '+8'
  In-Reply-To: <19153.1537295270@sss.pgh.pa.us>
  References: <153724095414.13490.12512426893930004410@wrigleys.postgresql.org> <20541.1537242305@sss.pgh.pa.us> <20180918163653.4lzayhdliejl3hkj@hjp.at> <19153.1537295270@sss.pgh.pa.us>

* 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