Thread: Reserved word: OWNER

Reserved word: OWNER

From
PG Doc comments form
Date:
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/14/sql-keywords-appendix.html
Description:

You say it's a non-reserved word, but on this page:

https://www.postgresql.org/docs/current/sql-alterdatabase.html#:~:text=To%20alter%20the%20owner%2C%20you,default%20tablespace%20of%20the%20database.

you clearly use OWNER as a reserved word:

ALTER DATABASE name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER |
SESSION_USER }

and if I try to use OWNER as a column name in pgAdmin, it is marked blue (ie
a reserved word). So which is it?

Re: Reserved word: OWNER

From
Thom Brown
Date:
On Fri, 13 May 2022 at 13:23, PG Doc comments form
<noreply@postgresql.org> wrote:
>
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/14/sql-keywords-appendix.html
> Description:
>
> You say it's a non-reserved word, but on this page:
>
https://www.postgresql.org/docs/current/sql-alterdatabase.html#:~:text=To%20alter%20the%20owner%2C%20you,default%20tablespace%20of%20the%20database.
>
> you clearly use OWNER as a reserved word:
>
> ALTER DATABASE name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER |
> SESSION_USER }
>
> and if I try to use OWNER as a column name in pgAdmin, it is marked blue (ie
> a reserved word). So which is it?

That sounds like a PgAdmin issue, and probably because of the way that
their syntactic highlighting works.  OWNER isn't a reserved word.

postgres=# CREATE TABLE owner (owner TEXT);
CREATE TABLE
postgres=# \d owner
              Table "public.owner"
 Column | Type | Collation | Nullable | Default
--------+------+-----------+----------+---------
 owner  | text |           |          |

Regards

Thom



Re: Reserved word: OWNER

From
Tom Lane
Date:
Thom Brown <thom@linux.com> writes:
> On Fri, 13 May 2022 at 13:23, PG Doc comments form
>> Page: https://www.postgresql.org/docs/14/sql-keywords-appendix.html
>> if I try to use OWNER as a column name in pgAdmin, it is marked blue (ie
>> a reserved word). So which is it?

> That sounds like a PgAdmin issue, and probably because of the way that
> their syntactic highlighting works.  OWNER isn't a reserved word.

Yeah.  It is a keyword, but not a reserved one, meaning it's okay to use
as an identifier.  See the explanatory text at the top of that page.

There are actually four levels of keyword reserved-ness in Postgres,
and a simple highlighted-or-not scheme is not going to capture any of
that nuance.

            regards, tom lane