Re: BUG #17439: DROP FUNCTION functionName(); drops associated generated column without using CASCADE - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #17439: DROP FUNCTION functionName(); drops associated generated column without using CASCADE
Date
Msg-id 453334.1647397423@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #17439: DROP FUNCTION functionName(); drops associated generated column without using CASCADE  (Kevin Humphreys <kmanh999@gmail.com>)
Responses Re: BUG #17439: DROP FUNCTION functionName(); drops associated generated column without using CASCADE  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-bugs
Kevin Humphreys <kmanh999@gmail.com> writes:
> Thanks for deep-diving into this Tom! I don't have any experience with the
> internal workings of Postgres but if I am understanding correctly:
> - This is definitely a bug and not intended or expected behavior and goes
> against SQL specifications

Looks like a bug to me.  The aspect of this that a drop of a table
column causes silent drop of dependent generated columns is clearly
intentional, but AFAICS that's based on a misreading of the spec.
I suspect that the fact that it carries over to other dependencies
of the generation expression was just failure to consider that case.

> - This is a non-trivial fix
> - This is a fix that can not be back-ported to Postgres 13?
> - This is a fix that can be made to Postgres 14?

Yes, yes, no.  I don't think we'd risk trying to change this for
any released branch, because redefining catalog contents in
existing installations carries all sorts of hazards.  Given that
it's been wrong since v12 and you're the first to complain,
I judge that fixing it in released branches is not worth taking
such risks for.  We should definitely endeavor to get it fixed
for v15 though.

> Is there any recommendation you would have for mitigation besides not
> dropping functions that may be used by generated columns?

I don't see any good user-level workaround :-(.

            regards, tom lane



pgsql-bugs by date:

Previous
From: Kevin Humphreys
Date:
Subject: Re: BUG #17439: DROP FUNCTION functionName(); drops associated generated column without using CASCADE
Next
From: "David G. Johnston"
Date:
Subject: Re: BUG #17439: DROP FUNCTION functionName(); drops associated generated column without using CASCADE