DROP FUNCTION RESTRICT drops GENERATED columns

From: Jordan Lewis <jordanthelewis(at)gmail(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org, Jordan Lewis <jordanthelewis(at)gmail(dot)com>
Subject: DROP FUNCTION RESTRICT drops GENERATED columns
Date: 2020-12-30 02:53:35
Message-ID: CAALgziL0SqLHAk+yDASXkdVRygfW9jHprP=RDVN=QLa7A6y98w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2020-12-30 07:25:42 Re: BUG #16691: Autovacuum stops processing certain databases until postgresql rebooted
Previous Message PG Bug reporting form 2020-12-29 15:34:52 BUG #16796: Issue While passing null as value during procedure/Function Call from Groovy