Re: BUG #4465: GROUP BY is not to SQL standard

From: "Tony Marston" <tony(at)marston-home(dot)demon(dot)co(dot)uk>
To: "'Peter Eisentraut'" <peter_e(at)gmx(dot)net>
Cc: <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #4465: GROUP BY is not to SQL standard
Date: 2008-10-14 23:54:16
Message-ID: D7E66A57DD2D4E4D991FE05A476D1AA5@ajmnotebook
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I think your definition of "Feature T301 Functional Dependencies" is
extremely questionable. A functional dependency in relational theory
automatically exists where a non-key column on a table is functionally
dependent on the key of that table. It is not something that can be turned
on or off with code, it is built into the design of the table, so it is
erroneous to say that "Postgresql does not support functional dependencies".
If you support both key and non-key columns on a table then you support
functional dependencies whether you like it or not.

As for your statement that PostgreSQL has never claimed that it is fully
SQL-compliant, every time I have posted a message to a PG newsgroup and
compared it with MySQL the immediate response which I receive has always
been along the lines of "don't compare PG with MySQL as that is a toy
database that does not follow the standards". As soon as I point out an SQL
standard that you DON'T follow I get a barrage of weasel words and pathetic
excuses.

Tony Marston

http://www.tonymarston.net
http://www.radicore.org

> -----Original Message-----
> From: Peter Eisentraut [mailto:peter_e(at)gmx(dot)net]
> Sent: 14 October 2008 20:17
> To: Tony Marston
> Subject: Re: [BUGS] BUG #4465: GROUP BY is not to SQL standard
>
>
> Tony Marston wrote:
> > I am using document WG3:HBA-003 H2-2003-305 dated August 2003.
> >
> > Section 7.9 - 7 of the SQL-1992 standard states:
> >
> > "If T is a grouped table, then each <column reference> in
> each <value
> > expression> that references a column of T shall reference a
> grouping
> > expression> column
> > or be specified within a <set function specification>."
> >
> > Section 7.12 - 15 of the SQL-2003
> >
> > "If T is a grouped table, then let G be the set of grouping
> columns of
> > T. In each <value expression> contained in <select list>,
> each column
> > reference that references a column of T shall reference
> some column C
> > that is functionally dependent on G or shall be contained in an
> > aggregated argument of a <set function specification> whose
> > aggregation query is QS."
> >
> > This means that it is no longer necessary for every column in the
> > SELECT list to be specified in the GROUP BY clause. It is
> permissible
> > to leave out any column which is functionally dependent on
> any column
> > in the GROUP BY clause. As any non-key column on a table is
> > functionally dependent on the table key then provided that
> the GROUP
> > BY clause contains the table key it is not necessary to specify any
> > non-key columns from that table.
>
> That assessment is correct, but later Section 7.12
> Conformance rule 3 says:
>
> "3) Without Feature T301, "Functional dependencies", in
> conforming SQL
> language, if T is a grouped table, then in each <value expression>
> contained in the <select list>, each <column reference> that
> references
> a column of T shall reference a grouping column or be specified in an
> aggregated argument of a <set function specification>."
>
> This specialized 7.12 GR 15 to allow only column references
> of directly
> grouped columns. In other words, SQL implementations have an
> option of
> supporting a simpler and a more sophisticated behavior,
> distinguished by
> feature T301. Since PostgreSQL does not support T301, we follow the
> specification of 7.12 CR 3. This is perfectly permissible within the
> SQL standard.
>
> > Postgresql still insists on enforcing the outdated 1992 standard,
> > therefore it is wrong to claim that it is SQL-compliant.
> That is why I
> > am reporting it as a bug.
>
> FWIW, PostgreSQL has never claimed that it is fully SQL-compliant.
>
>

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2008-10-15 00:28:42 Re: BUG #4465: GROUP BY is not to SQL standard
Previous Message Eric Haszlakiewicz 2008-10-14 15:49:47 Re: Re: BUG #4078: ERROR: operator does not exist: numeric = character varying