DROP FUNCTION RESTRICT drops GENERATED columns - Mailing list pgsql-bugs

From Jordan Lewis
Subject DROP FUNCTION RESTRICT drops GENERATED columns
Date
Msg-id CAALgziL0SqLHAk+yDASXkdVRygfW9jHprP=RDVN=QLa7A6y98w@mail.gmail.com
Whole thread Raw
List pgsql-bugs
According to the documentation (https://www.postgresql.org/docs/13/sql-dropfunction.html), DROP FUNCTION RESTRICT should refuse to drop a function if any objects depend on it. This behavior doesn't appear to be upheld for GENERATED columns, which appear not to track the dependency.

Version: PostgreSQL 13.1

SETUP:

jordan=# CREATE FUNCTION f (a INT) RETURNS INT AS 'SELECT a' IMMUTABLE LANGUAGE SQL;
CREATE FUNCTION
jordan=# CREATE TABLE t (a INT, b INT GENERATED ALWAYS AS (f(a)) STORED);
CREATE TABLE
jordan=# INSERT INTO t VALUES(1);
INSERT 0 1
jordan=# SELECT * FROM t;
 a | b
---+---
 1 | 1
(1 row)

jordan=# DROP FUNCTION f RESTRICT;

EXPECTED BEHAVIOR:

An error is returned, preventing the DROP FUNCTION from succeeding because t.b depends on f.

ACTUAL BEHAVIOR:

No error is returned, and t.b is silently dropped.

pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #16796: Issue While passing null as value during procedure/Function Call from Groovy
Next
From: Michael Paquier
Date:
Subject: Re: BUG #16691: Autovacuum stops processing certain databases until postgresql rebooted