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

From Peter Eisentraut
Subject Re: Functional dependencies and GROUP BY
Date
Msg-id 1276258028.8488.23.camel@fsopti579.F-Secure.com
Whole thread Raw
In response to Re: Functional dependencies and GROUP BY  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On tis, 2010-06-08 at 10:05 -0400, Tom Lane wrote:
> Perhaps the correct fix would be to mark stored query trees as having
> a
> dependency on the index, so that dropping the index/constraint would
> force a drop of the rule too.  Just pushing the check to plan time, as
> I suggested yesterday, isn't a very nice fix because it would result
> in the rule unexpectedly starting to fail at execution.

There are actually pretty explicit instructions about this in the SQL
standard:

<drop table constraint definition>

4) If QS is a <query specification> that contains an implicit or
explicit <group by clause> and that contains a column reference to a
column C in its <select list> that is not contained in an aggregated
argument of a <set function specification>, and if G is the set of
grouping columns of QS, and if the table constraint TC is needed to
conclude that G ↦ C is a known functional dependency in QS, then QS is
said to be dependent on TC.

5) If V is a view that contains a <query specification> that is
dependent on a table constraint TC, then V is said to be dependent on
TC.

So the dependency between the view/rule and the constraint/index needs
to be stored in the dependency system, and RESTRICT/CASCADE will take
effect.



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Functional dependencies and GROUP BY
Next
From: Stephen Frost
Date:
Subject: Re: server authentication over Unix-domain sockets