Re: setting time zone in a function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Steve Rogerson <steve(dot)pg(at)yewtc(dot)demon(dot)co(dot)uk>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: setting time zone in a function
Date: 2016-04-21 15:19:42
Message-ID: 11976.1461251982@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Steve Rogerson <steve(dot)pg(at)yewtc(dot)demon(dot)co(dot)uk> writes:
> I wonder what counts as a valid time zone

http://www.postgresql.org/docs/9.5/static/datatype-datetime.html#DATATYPE-TIMEZONES

> ... I wasn't expecting this:

> # set timezone = '==2.77';
> SET
> # select now();
> now
> -------------------------------
> 2016-04-18 09:40:52.089375-77
> (1 row)

Postgres is *very* lax about what is a valid timezone abbreviation in
the POSIX notation, mainly because the underlying Olson code is too.
I think it's taking that as '==' being the standard zone abbreviation
and '.' being the DST zone abbreviation.

If you wanted to restrict input to be the Olson-style zone names,
you could do some kind of precheck, maybe insist on only letters/
slashes/underscores.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2016-04-21 15:59:38 Re: Add relcreated (timestamp) column to pg_class catalog to record the time an object was created
Previous Message Melvin Davidson 2016-04-21 15:18:31 Re: Add relcreated (timestamp) column to pg_class catalog to record the time an object was created