SESSION SESSION - bug or intentional?

Started by Joe Conwayover 10 years ago4 messageshackers
Jump to latest
#1Joe Conway
mail@joeconway.com

I was looking at something in gram.y when I noticed that the following
production works:

SET SESSION SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;

"SESSION SESSION" seems fairly odd -- is it intentional?

Joe

--
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: Joe Conway (#1)
Re: SESSION SESSION - bug or intentional?

On Wed, Sep 30, 2015 at 2:52 PM, Joe Conway <mail@joeconway.com> wrote:

I was looking at something in gram.y when I noticed that the following
production works:

SET SESSION SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;

"SESSION SESSION" seems fairly odd -- is it intentional?

​Scanning the SET and SET TRANSACTION it doesn't appear to be something
they are documented as allowing.

However, SET SESSION AUTHORIZATION is defined as thus:


SET [ SESSION | LOCAL ] SESSION AUTHORIZATION user_name

​which implies that we don't ​take pains to avoid it. Since:

"The SESSION and LOCAL modifiers are a PostgreSQL extension, as is the
RESET syntax."

The standard doesn't have any undue influence on our particular decision.

David J.

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: David G. Johnston (#2)
Re: SESSION SESSION - bug or intentional?

"David G. Johnston" <david.g.johnston@gmail.com> writes:

On Wed, Sep 30, 2015 at 2:52 PM, Joe Conway <mail@joeconway.com> wrote:

I was looking at something in gram.y when I noticed that the following
production works:
SET SESSION SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;
"SESSION SESSION" seems fairly odd -- is it intentional?

However, SET SESSION AUTHORIZATION is defined as thus:
SET [ SESSION | LOCAL ] SESSION AUTHORIZATION user_name

Yeah. SET LOCAL SESSION AUTHORIZATION is valid and useful. The optional
SESSION is just a noise word here, but disallowing it would be
non-orthogonal compared to other similar syntaxes.

regards, tom lane

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

#4David G. Johnston
david.g.johnston@gmail.com
In reply to: Tom Lane (#3)
Re: SESSION SESSION - bug or intentional?

On Wed, Sep 30, 2015 at 5:49 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

"David G. Johnston" <david.g.johnston@gmail.com> writes:

On Wed, Sep 30, 2015 at 2:52 PM, Joe Conway <mail@joeconway.com> wrote:

I was looking at something in gram.y when I noticed that the following
production works:
SET SESSION SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;
"SESSION SESSION" seems fairly odd -- is it intentional?

However, SET SESSION AUTHORIZATION is defined as thus:
SET [ SESSION | LOCAL ] SESSION AUTHORIZATION user_name

Yeah. SET LOCAL SESSION AUTHORIZATION is valid and useful. The optional
SESSION is just a noise word here, but disallowing it would be
non-orthogonal compared to other similar syntaxes.

​While I get the gist of what you are saying the phrase:

"[...] but disallowing it would be non-orthogonal compared to other similar
syntaxes."

doesn't compute for me. You mind trying that again?

​I take it that means that disallowing it would be "inconsistent" given
what we allow in similar commands.​

Given that conclusion shouldn't the following be modified?
http://www.postgresql.org/docs/devel/static/sql-set-transaction.html​
SET [ SESSION | LOCAL ] SESSION CHARACTERISTICS AS TRANSACTION
transaction_mode [, ...]

Both are allowed though the one is redundant and the other (presumably)
ignored, repsectively.

A code comment in the grammar would be warranted at the least - not going
there myself.

I haven't tried to figure out what exactly LOCAL results in if specified
vis-a-vis the presence of absence of an active transcation.

David J.