Clarification on SET SESSION AUTHORIZATION Syntax
Clarification on SET SESSION AUTHORIZATION Syntax
От:
PG Doc comments form <noreply@postgresql.org>
Дата:
The following documentation comment has been logged on the website: Page: https://www.postgresql.org/docs/18/sql-set-session-authorization.html Description: Hi Team, In the `SET SESSION AUTHORIZATION` statement, the syntax is defined as: ```sql SET [ SESSION | LOCAL ] SESSION AUTHORIZATION user_name; ``` I would like to clarify whether the following query is valid: ```sql SET SESSION SESSION AUTHORIZATION user_name; ``` Since `SESSION` and `LOCAL` are optional alternatives in the syntax, does the first `SESSION` keyword allow the query to contain two consecutive `SESSION` keywords? If this syntax is not valid, should we update the grammar to the following? ```sql SET [ LOCAL ] SESSION AUTHORIZATION user_name; ``` Please clarify the expected syntax so that we can update the grammar accordingly. Thanks.
Re: Clarification on SET SESSION AUTHORIZATION Syntax
От:
Matemática A3K <matematica.a3k@gmail.com>
Дата:
On Thu, Nov 12, 2026 at 2:23 PM PG Doc comments form
wrote:
>
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/18/sql-set-session-authorization.html
> Description:
>
> Hi Team,
>
> In the `SET SESSION AUTHORIZATION` statement, the syntax is defined as:
>
> ```sql
> SET [ SESSION | LOCAL ] SESSION AUTHORIZATION user_name;
> ```
>
> I would like to clarify whether the following query is valid:
>
> ```sql
> SET SESSION SESSION AUTHORIZATION user_name;
> ```
~/code/pw main
❯ sudo -u postgres psql
[sudo] password for bot:
psql (18.6)
Type "help" for help.
postgres=# SET SESSION AUTHORIZATION 'paul';
ERROR: role "paul" does not exist
postgres=# SET SESSION SESSION AUTHORIZATION 'paul';
ERROR: role "paul" does not exist
postgres=# SET SESSION SESSION AUTHORIZATION 'postgres';
SET
postgres=# SET SESSION AUTHORIZATION 'postgres';
SET
postgres=# SET LOCAL SESSION AUTHORIZATION 'postgres';
WARNING: SET LOCAL can only be used in transaction blocks
SET
> Since `SESSION` and `LOCAL` are optional alternatives in the syntax,
I first read it as "one or the other", but it is "one or the other or
none", as you may see from my console log
> does
> the first `SESSION` keyword allow the query to contain two consecutive
> `SESSION` keywords?
If the question is "Is SET SESSION SESSION AUTHORIZATION 'user_name';
a valid statement?", then, yes. Otherwise, it is not clear to me.
> If this syntax is not valid, should we update the grammar to the following?
>
> ```sql
> SET [ LOCAL ] SESSION AUTHORIZATION user_name;
> ```
>
> Please clarify the expected syntax so that we can update the grammar
> accordingly.
The syntax is valid, no need to update that. The page makes more sense
after reading the SET one
(https://www.postgresql.org/docs/18/sql-set.html) linked,
After re-reading both, I wonder if a more appropriate syntax description is:
SET [ SESSION | LOCAL ] SESSION AUTHORIZATION { user_name |
'user_name' | DEFAULT }
RESET SESSION AUTHORIZATION
> Thanks.
Np
Clarification on SET SESSION AUTHORIZATION Syntax
От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
On Thursday, November 12, 2026, Matemática A3K <matematica.a3k@gmail.com> wrote:
> SET [ SESSION | LOCAL ] SESSION AUTHORIZATION user_name;
I first read it as "one or the other", but it is "one or the other or
none", as you may see from my console log
The square brackets are defined to mean optional in this scheme. It would be { SESSION | LOCAL } if the choice were mandatory.
David J.
Re: Clarification on SET SESSION AUTHORIZATION Syntax
От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
On Thursday, November 12, 2026, Matemática A3K <matematica.a3k@gmail.com> wrote:
After re-reading both, I wonder if a more appropriate syntax description is:
SET [ SESSION | LOCAL ] SESSION AUTHORIZATION { user_name |
'user_name' | DEFAULT }
RESET SESSION AUTHORIZATION
Yes, the difference there seems like a simple oversight.
David J.
Re: Clarification on SET SESSION AUTHORIZATION Syntax
On Fri, Nov 13, 2026 at 12:32 AM David G. Johnston
wrote:
>
> On Thursday, November 12, 2026, Matemática A3K wrote:
>>
>> After re-reading both, I wonder if a more appropriate syntax description is:
>> SET [ SESSION | LOCAL ] SESSION AUTHORIZATION { user_name |
>> 'user_name' | DEFAULT }
>> RESET SESSION AUTHORIZATION
>
>
> Yes, the difference there seems like a simple oversight.
Indeed! I tried changing the syntax to that and realized that I
couldn't rewrite the last paragraph of the description (woof! too
hard...). So, I only added the string literal referenced in the
description to the syntax.
Attaching the patch for completeness.
It makes sense to me to generate a bigger patch with all the patches
like this from time to time (let´s say, a month...), and commit it
with a subject like "doc: Monthly minor fixes". This way, small fixes
can get their way into the doc.
Do you think it would get approved?
>
> David J.
>
Re: Clarification on SET SESSION AUTHORIZATION Syntax
От:
Fujii Masao <masao.fujii@gmail.com>
Дата:
On Sat, Nov 14, 2026 at 11:59 AM Matemática A3K wrote: > So, I only added the string literal referenced in the > description to the syntax. At least to me, adding the quoted form to the syntax summary seems unnecessary. Because other commands, such as SET ROLE and SET, also accept both identifiers and string literals, but their syntax summaries in the docs don't explicitly show the quoted forms. Also the SET SESSION AUTHORIZATION docs already states, "The user name can be written as either an identifier or a string literal". Thought? Regards, -- Fujii Masao