Commit a756f5ce authored by Tom Lane's avatar Tom Lane

GROUP BY can only infer functional dependency from non-deferrable primary keys.

Peter's original patch had this right, but I dropped the check while revising
the code to search pg_constraint instead of pg_index.  Spotted by Dean Rasheed.
parent 8d8d5cb6
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/pg_constraint.c,v 1.55 2010/08/07 02:44:06 tgl Exp $ * $PostgreSQL: pgsql/src/backend/catalog/pg_constraint.c,v 1.56 2010/09/05 15:45:42 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -836,6 +836,9 @@ check_functional_grouping(Oid relid, ...@@ -836,6 +836,9 @@ check_functional_grouping(Oid relid,
/* Only PK constraints are of interest for now, see comment above */ /* Only PK constraints are of interest for now, see comment above */
if (con->contype != CONSTRAINT_PRIMARY) if (con->contype != CONSTRAINT_PRIMARY)
continue; continue;
/* Constraint must be non-deferrable */
if (con->condeferrable)
continue;
/* Extract the conkey array, ie, attnums of PK's columns */ /* Extract the conkey array, ie, attnums of PK's columns */
adatum = heap_getattr(tuple, Anum_pg_constraint_conkey, adatum = heap_getattr(tuple, Anum_pg_constraint_conkey,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment