Re: Functional dependencies and GROUP BY - Mailing list pgsql-hackers

From Alex Hunsaker
Subject Re: Functional dependencies and GROUP BY
Date
Msg-id AANLkTimb1WK788F9EG1LCIzlsj30KAtxsNknrucU-tei@mail.gmail.com
Whole thread Raw
In response to Re: Functional dependencies and GROUP BY  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: Functional dependencies and GROUP BY
Re: Functional dependencies and GROUP BY
List pgsql-hackers
On Fri, Jun 25, 2010 at 14:06, Peter Eisentraut <peter_e@gmx.net> wrote:
> Second version:

Hi!

Ive looked this over.  Looks great!  I have some nits about the
documentation and comments ( non issues like referencing primary keys
when it really means not null unique indexes :-P ), but on the whole
it works and looks good.

The only corner case I have run into is creating a view with what I
would call an implicit 'not null' constraint.  Demonstration below:

create table nn (a int4 not null, b int4, unique (a));
select * from nn group by a; -- should this work? I think not?
a | b
---+---
(0 rows)

create view vv as select a, b from nn group by a;
select * from vv;a | b
---+---
(0 rows)

=# alter table nn alter column a drop not null;
=# select * from nn group by a; -- ok, broken makes sense
ERROR:  column "nn.b" must appear in the GROUP BY clause or be used in
an aggregate function
LINE 1: SELECT * from nn group by a;

=# select * from vv; -- yipes should be broken?a | b
---+---
(0 rows)

Im thinking we should not allow the "select * from nn group by a;" to
work.  Thoughts?

(FYI I do plan on doing some performance testing with large columns
later, any other requests?)


pgsql-hackers by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: SHOW TABLES
Next
From: "Joshua D. Drake"
Date:
Subject: Re: SHOW TABLES