Обсуждение: [BUGS] BUG #14511: Set timezone to local

Поиск
Список
Период
Сортировка

[BUGS] BUG #14511: Set timezone to local

От
adrian.klaver@aklaver.com
Дата:
The following bug has been logged on the website:

Bug reference:      14511
Logged by:          Adrian Klaver
Email address:      adrian.klaver@aklaver.com
PostgreSQL version: 9.5.5
Operating system:   Linux openSUSE 42.2
Description:

test=> select version();
                                       version
        
-------------------------------------------------------------------------------------
 PostgreSQL 9.5.5 on x86_64-pc-linux-gnu, compiled by gcc (SUSE Linux)
4.8.5, 64-bit
(1 row)


test=> set timezone = DEFAULT;
SET

test=> set timezone = LOCAL;
ERROR:  invalid value for parameter "TimeZone": "local"

test=> set time zone LOCAL;
SET

The docs:

https://www.postgresql.org/docs/9.5/static/sql-set.html

say the last two commands should yield the same result. Not sure if this
error in docs or code.


--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Re: [BUGS] BUG #14511: Set timezone to local

От
Tom Lane
Дата:
adrian.klaver@aklaver.com writes:
> test=> set timezone = DEFAULT;
> SET

> test=> set timezone = LOCAL;
> ERROR:  invalid value for parameter "TimeZone": "local"

> test=> set time zone LOCAL;
> SET

"SET TIME ZONE LOCAL" is a SQL-standard-mandated variant way of writing
"set timezone to default", following the SQL committee's time-honored
principle of never using orthogonal syntax if somebody can think of an
idiosyncratic way instead.

Given the way that our grammar is set up, the only way we could handle
"set timezone = LOCAL" would be to allow LOCAL as a synonym for DEFAULT
for *all* SET variables.  That doesn't seem like a particularly good
idea.

> The docs:
> https://www.postgresql.org/docs/9.5/static/sql-set.html
> say the last two commands should yield the same result.

AFAICS, the docs show the syntax restriction accurately:

SET [ SESSION | LOCAL ] configuration_parameter { TO | = } { value | 'value' | DEFAULT }
SET [ SESSION | LOCAL ] TIME ZONE { timezone | LOCAL | DEFAULT }

LOCAL is not listed as a valid alternative for the first syntax.

            regards, tom lane


--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Re: [BUGS] BUG #14511: Set timezone to local

От
Adrian Klaver
Дата:
On 01/24/2017 09:38 AM, Tom Lane wrote:
> adrian.klaver@aklaver.com writes:
>> test=> set timezone = DEFAULT;
>> SET
>
>> test=> set timezone = LOCAL;
>> ERROR:  invalid value for parameter "TimeZone": "local"
>
>> test=> set time zone LOCAL;
>> SET
>
> "SET TIME ZONE LOCAL" is a SQL-standard-mandated variant way of writing
> "set timezone to default", following the SQL committee's time-honored
> principle of never using orthogonal syntax if somebody can think of an
> idiosyncratic way instead.
>
> Given the way that our grammar is set up, the only way we could handle
> "set timezone = LOCAL" would be to allow LOCAL as a synonym for DEFAULT
> for *all* SET variables.  That doesn't seem like a particularly good
> idea.
>
>> The docs:
>> https://www.postgresql.org/docs/9.5/static/sql-set.html
>> say the last two commands should yield the same result.
>
> AFAICS, the docs show the syntax restriction accurately:
>
> SET [ SESSION | LOCAL ] configuration_parameter { TO | = } { value | 'value' | DEFAULT }
> SET [ SESSION | LOCAL ] TIME ZONE { timezone | LOCAL | DEFAULT }
>
> LOCAL is not listed as a valid alternative for the first syntax.

I did not crawl that far up the page, I stopped at:

SET TIME ZONE value is an alias for SET timezone TO value.

and assumed since LOCAL was valid for the one it was valid for the 
other. I should know better:(

>
>             regards, tom lane
>


-- 
Adrian Klaver
adrian.klaver@aklaver.com


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs