LOCAL and TIME ZONE in SET

Started by Zbigniew Szmigieroover 8 years ago5 messagesdocs
Jump to latest
#1Zbigniew Szmigiero
zszmigiero@gmail.com

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/9.5/static/sql-alterdatabase.html
Description:

The "ALTER DATABASE name TIME ZONE ..." is rejected

THE "ALTER DATABASE name TIMEZONE TO LOCAL" is rejected

Please update documentation or provide correct syntax

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

#2Steve Crawford
scrawford@pinpointresearch.com
In reply to: Zbigniew Szmigiero (#1)
Re: LOCAL and TIME ZONE in SET

On Fri, Sep 8, 2017 at 1:05 PM, <zszmigiero@gmail.com> wrote:

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/9.5/static/sql-alterdatabase.html
Description:

The &quot;ALTER DATABASE name TIME ZONE ...&quot; is rejected

THE &quot;ALTER DATABASE name TIMEZONE TO LOCAL&quot; is rejected

Please update documentation or provide correct syntax

It works as described in the documentation:

steve=> alter database steve set timezone to local;
ERROR: must be owner of database steve

postgres=# alter database steve set timezone to 'US/Pacific';
ALTER DATABASE
postgres=# alter database steve set timezone to default;
ALTER DATABASE

Cheers,
Steve

#3David G. Johnston
david.g.johnston@gmail.com
In reply to: Steve Crawford (#2)
Re: LOCAL and TIME ZONE in SET

On Mon, Sep 11, 2017 at 8:26 AM, Steve Crawford <
scrawford@pinpointresearch.com> wrote:

On Fri, Sep 8, 2017 at 1:05 PM, <zszmigiero@gmail.com> wrote:

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/9.5/static/sql-alterdatabase.html
Description:

The &quot;ALTER DATABASE name TIME ZONE ...&quot; is rejected

THE &quot;ALTER DATABASE name TIMEZONE TO LOCAL&quot; is rejected

Please update documentation or provide correct syntax

It works as described in the documentation:

steve=> alter database steve set timezone to local;
ERROR: must be owner of database steve

postgres=# alter database steve set timezone to 'US/Pacific';
ALTER DATABASE
postgres=# alter database steve set timezone to default;
ALTER DATABASE

​More specifically the first listed syntax only applies if the inherent
database "option" you wish to ​set is one of:
ALLOW_CONNECTIONS allowconn
CONNECTION LIMIT connlimit
IS_TEMPLATE istemplate

What you want to do is setup a default User-Database Configuration (GUC)
value (which in this case applies to all users connecting to this
database); which is what the last 4 syntax specifications pertain to - as
noted in the description section on that page.

18.1.3 describes this dynamic in more detail:

https://www.postgresql.org/docs/9.5/static/config-setting.html#CONFIG-SETTING-SQL-COMMAND-INTERACTION

David J.

#4Steve Crawford
scrawford@pinpointresearch.com
In reply to: David G. Johnston (#3)
Re: LOCAL and TIME ZONE in SET

On Tue, Sep 12, 2017 at 11:07 AM, Zbigniew Szmigiero <zszmigiero@gmail.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

#5Zbigniew Szmigiero
zszmigiero@gmail.com
In reply to: Steve Crawford (#4)
Re: LOCAL and TIME ZONE in SET

Hi,

Thanks for explanation.
Some information from my side. I am working on tool which create randomized SQL stream which covers all possible syntaxes for many different databases.
The reason to do that is have possibility to check SQL parsing by DAM (Database activity monitoring) tools like Guardium, Imperva.

I am incorrectly read syntax, now everything is clear.

Best wishes,

Zibi

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