ONLY with parentheses

Started by Peter Eisentrautabout 17 years ago4 messages
#1Peter Eisentraut
peter_e@gmx.net

While working on TRUNCATE with ONLY, I said to myself, hmm, when writing

TRUNCATE ONLY a, b

it might be a bit confusing whether the ONLY refers to a or both a and
b. Then I noticed that the SQL standard requires parentheses, like

TRUNCATE ONLY (a), b

which is clearer. While we support that in gram.y, I don't see it
anywhere in the documentation.

Should we document this and emphasize it as having more clarity?

#2Alvaro Herrera
alvherre@commandprompt.com
In reply to: Peter Eisentraut (#1)
Re: ONLY with parentheses

Peter Eisentraut wrote:

While working on TRUNCATE with ONLY, I said to myself, hmm, when writing

TRUNCATE ONLY a, b

it might be a bit confusing whether the ONLY refers to a or both a and
b. Then I noticed that the SQL standard requires parentheses, like

TRUNCATE ONLY (a), b

which is clearer.

Hmm, if I want to truncate only both (or is that "both only"?), what do
I have to do?

TRUNCATE ONLY (a), ONLY (b)
or
TRUNCATE ONLY (a, b)

Also, does this work?
TRUNCATE a, ONLY (b)

It's still not clear whether
TRUNCATE ONLY a, b
means to truncate both only, or only a only.

If only this was clearer ... if it was up to me, the ONLY keywords would
be inside the parentheses,
TRUNCATE (ONLY a), b
Now that is clear. What the hell do I know anyway.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

#3Cédric Villemain
cedric.villemain@dalibo.com
In reply to: Peter Eisentraut (#1)
Re: ONLY with parentheses

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Peter Eisentraut a écrit :

While working on TRUNCATE with ONLY, I said to myself, hmm, when writing

TRUNCATE ONLY a, b

it might be a bit confusing whether the ONLY refers to a or both a and
b. Then I noticed that the SQL standard requires parentheses, like

TRUNCATE ONLY (a), b

which is clearer. While we support that in gram.y, I don't see it
anywhere in the documentation.

Should we document this and emphasize it as having more clarity?

+1

- --
Cédric Villemain
Administrateur de Base de Données
Cel: +33 (0)6 74 15 56 53
http://dalibo.com - http://dalibo.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAklmA7wACgkQo/dppWjpEvxpcwCgyAA9OxtUN4X51EwuRmtMtGe+
Tm4AnAnjDzyc3roMZGFOhQWodOzueX1n
=TJ9x
-----END PGP SIGNATURE-----

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#2)
Re: ONLY with parentheses

Alvaro Herrera <alvherre@commandprompt.com> writes:

Peter Eisentraut wrote:

Then I noticed that the SQL standard requires parentheses, like

TRUNCATE ONLY (a), b

which is clearer.

Hmm, if I want to truncate only both (or is that "both only"?), what do
I have to do?

TRUNCATE ONLY (a, b)

Yeah. To me those parentheses look more like redundant parentheses,
eg writing 2 + (2) instead of just 2 + 2. If you consider that they're
not redundant then it becomes a fair question why Alvaro's multiple-
elements syntax doesn't work.

In the end what you have to point out is that ONLY binds tighter than
comma. I don't think that parens where the committee put them help
resolve that at all.

regards, tom lane