Re: Strange primary key constraint influence to grouping

From: Gražvydas Valeika <gvaleika(at)gmail(dot)com>
To: Andreas Karlsson <andreas(at)proxel(dot)se>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Strange primary key constraint influence to grouping
Date: 2012-01-18 23:54:11
Message-ID: CAO6eJZo3JGBeaeQGtbu_A048nbQrsjB5=7Pc3J5C+qfUkcyBkA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
>
> This is because PostgreSQL 9.1 added the feature of simple checking of
> functional dependencies for GROUP BY. The manual of 9.1 explains quite well
> when PostgreSQL considers there to be a functional dependency.
>
> "When GROUP BY is present, it is not valid for the SELECT list expressions
> to refer to ungrouped columns except within aggregate functions or if the
> ungrouped column is functionally dependent on the grouped columns, since
> there would otherwise be more than one possible value to return for an
> ungrouped column. A functional dependency exists if the grouped columns (or
> a subset thereof) are the primary key of the table containing the ungrouped
> column."
>
> I completely agree with documentation.

But my case shows that "not valid" expression which refers to column which
is ungrouped still works in 9.1.

G.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2012-01-19 00:01:05 Re: Measuring relation free space
Previous Message Andreas Karlsson 2012-01-18 23:41:41 Re: Strange primary key constraint influence to grouping