UNION DISTINCT in doc

Started by Hitoshi Haradaabout 15 years ago5 messages
#1Hitoshi Harada
umi.tanuki@gmail.com

I found PostgreSQL accepts UNION DISTINCT but documents don't mention it.

http://www.postgresql.org/docs/9.0/static/sql-select.html#SQL-UNION

select_statement UNION [ ALL ] select_statement

UNION DISTINCT is nothing more than UNION itself, but gram.y
definitely accept it and the SQL standard describes it as well. Should
we add DISTINCT to docs?

Regards,

--
Hitoshi Harada

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Hitoshi Harada (#1)
Re: UNION DISTINCT in doc

Hitoshi Harada <umi.tanuki@gmail.com> writes:

UNION DISTINCT is nothing more than UNION itself, but gram.y
definitely accept it and the SQL standard describes it as well. Should
we add DISTINCT to docs?

I think it'd be hard to describe without confusing people, because
while DISTINCT is a noise word there, it's definitely not a noise
word after SELECT. And the way that the reference pages are laid
out, it's hard to connect different descriptions of the same
keyword to different usages. If you can think of a non-forced
way of describing this, fine. But I don't have a problem with
leaving it as an undocumented standards-compliance nit.

regards, tom lane

#3Robert Haas
robertmhaas@gmail.com
In reply to: Hitoshi Harada (#1)
Re: UNION DISTINCT in doc

On Thu, Oct 14, 2010 at 10:37 AM, Hitoshi Harada <umi.tanuki@gmail.com> wrote:

I found PostgreSQL accepts UNION DISTINCT but documents don't mention it.

http://www.postgresql.org/docs/9.0/static/sql-select.html#SQL-UNION

select_statement UNION [ ALL ] select_statement

UNION DISTINCT is nothing more than UNION itself, but gram.y
definitely accept it and the SQL standard describes it as well. Should
we add DISTINCT to docs?

+1, with due regard for the issue raised by Tom.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#4Hitoshi Harada
umi.tanuki@gmail.com
In reply to: Tom Lane (#2)
Re: UNION DISTINCT in doc

2010/10/15 Tom Lane <tgl@sss.pgh.pa.us>:

Hitoshi Harada <umi.tanuki@gmail.com> writes:

UNION DISTINCT is nothing more than UNION itself, but gram.y
definitely accept it and the SQL standard describes it as well. Should
we add DISTINCT to docs?

I think it'd be hard to describe without confusing people, because
while DISTINCT is a noise word there, it's definitely not a noise
word after SELECT.  And the way that the reference pages are laid
out, it's hard to connect different descriptions of the same
keyword to different usages.  If you can think of a non-forced
way of describing this, fine.  But I don't have a problem with
leaving it as an undocumented standards-compliance nit.

I thought adding DISTINCT next to ALL is enough like

select_statement UNION [ ALL | DISTINCT ] select_statement

and say "UNION DISTINCT is identical to UNION only" or something. That
sounds not so confusing with DISTINCT clause description.

Regards,

--
Hitoshi Harada

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Hitoshi Harada (#4)
Re: UNION DISTINCT in doc

Hitoshi Harada <umi.tanuki@gmail.com> writes:

2010/10/15 Tom Lane <tgl@sss.pgh.pa.us>:

I think it'd be hard to describe without confusing people, because
while DISTINCT is a noise word there, it's definitely not a noise
word after SELECT.

I thought adding DISTINCT next to ALL is enough like

select_statement UNION [ ALL | DISTINCT ] select_statement

and say "UNION DISTINCT is identical to UNION only" or something. That
sounds not so confusing with DISTINCT clause description.

I looked at this more closely and decided that we could probably avoid
confusion if the description of the "DISTINCT clause" was careful to say
SELECT DISTINCT and SELECT ALL, rather than just DISTINCT/ALL.
Committed that way.

regards, tom lane