Re: Functional dependencies and GROUP BY

From: Alex Hunsaker <badalex(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Functional dependencies and GROUP BY
Date: 2010-07-17 04:29:27
Message-ID: AANLkTimb1WK788F9EG1LCIzlsj30KAtxsNknrucU-tei@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jun 25, 2010 at 14:06, Peter Eisentraut <peter_e(at)gmx(dot)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?)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2010-07-17 07:55:37 Re: ALTER TABLE SET STATISTICS requires AccessExclusiveLock
Previous Message Stephen Frost 2010-07-17 04:02:44 Re: SHOW TABLES