Re: SELECT DISTINCT ON bug?

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>, Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: SELECT DISTINCT ON bug?
Date: 2003-05-22 18:05:46
Message-ID: Pine.LNX.4.33.0305221154570.23585-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 21 May 2003, Bruno Wolff III wrote:

> On Wed, May 21, 2003 at 10:58:26 +0100,
> "Nigel J. Andrews" <nandrews(at)investsystems(dot)co(dot)uk> wrote:
> >
> > Syntax:
> > SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
> > * | expression [ AS output_name ] [, ...]
>
> This syntax expression does seem wrong. Usually concatenation takes
> precedence over alternation. I think there really should be {}s around
> the second line.

Good point. As written, syntax says you can either select * OR you can
select field1,field2,field3, but you can't select *,oid ...

Since we allow select *,field,function,expression, it would seem we need
the {}s there around * | expression [ AS output_name ] [, ...]
part.

Reference for those who like reading the SQL spec:

3.2 Notation

[ ] Square brackets indicate optional elements in a formula.
The portion of the formula within the brackets may be
explicitly specified or may be omitted.

{ } Braces group elements in a formula. The portion of the for-
mula within the braces shall be explicitly specified.

| The alternative operator. The vertical bar indicates that
the portion of the formula following the bar is an alterna-
tive to the portion preceding the bar. If the vertical bar
appears at a position where it is not enclosed in braces
or square brackets, it specifies a complete alternative for
the element defined by the production rule. If the vertical
bar appears in a portion of a formula enclosed in braces or
square brackets, it specifies alternatives for the contents
of the innermost pair of such braces or brackets.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-05-22 18:13:43 Re: Having problems with anoncvs
Previous Message Bruno Wolff III 2003-05-22 17:34:36 Re: SELECT DISTINCT ON bug?