Re: LOCAL and TIME ZONE in SET

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Zbigniew Szmigiero <zszmigiero(at)gmail(dot)com>, pgsql-docs(at)postgresql(dot)org
Subject: Re: LOCAL and TIME ZONE in SET
Date: 2017-09-12 19:17:35
Message-ID: CAEfWYywoRpN-c0+kgAn6ZO3zn5M5Z8VYmipnK1435S+FKihsqw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Tue, Sep 12, 2017 at 11:07 AM, Zbigniew Szmigiero <zszmigiero(at)gmail(dot)com>
wrote:

>
> Hi Steve,
>
> You do not test syntax provided in my examples:
>
> 1. ALTER DATABASE name SET TIME ZONE to ‚timezone’
>
> You used TIMEZONE instead of TIME ZONE - please check
>
> Your examples do not match the documentation. That is why they don't work.

TIME<space>ZONE is a special case as detailed at the top of:
https://www.postgresql.org/docs/9.6/static/sql-set.html

Specifically, for "time zone" there is no "to" between "time zone" and the
zone name but "local" is a special-case allowed option which is not one of
the options for configuration parameters (local would not make sense for
most configuration parameters while default usually does).

But "timezone" (no space) is a configuration parameter and *does* require
the "to".

Won't work:

steve=# alter database steve set timezone local;
ERROR: syntax error at or near "local"
LINE 1: alter database steve set timezone local;
^
steve=# alter database steve set time zone to local;
ERROR: syntax error at or near "to"
LINE 1: alter database steve set time zone to local;

steve=# alter database steve set timezone 'US/Eastern';
ERROR: syntax error at or near "'US/Eastern'"
LINE 1: alter database steve set timezone 'US/Eastern';

steve=# alter database steve set timezone to 'local';
ERROR: invalid value for parameter "TimeZone": "local"

Will work:

steve=# alter database steve set time zone 'US/Eastern';
ALTER DATABASE

steve=# alter database steve set time zone local;
ALTER DATABASE

steve=# alter database steve set time zone default;
ALTER DATABASE

steve=# alter database steve set timezone to 'US/Eastern';
ALTER DATABASE

steve=# alter database steve set timezone to default;
ALTER DATABASE

>
> 2. ALTER DATABASE name SET TIMEZONE TO LOCAL generates error - my pg is
> 9.5.9, please do that with correct privileges, your account was not able
> execute it.
>
>
I know - I was just showing both the privileged and unprivileged attempts.

Cheers,
Steve

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Zbigniew Szmigiero 2017-09-12 19:43:02 Re: LOCAL and TIME ZONE in SET
Previous Message devvapp 2017-09-11 20:55:54 Incorrect result in the Table 9-28. to_char examples