Re: BUG #18449: Altering column type fails when an SQL routine depends on the column

From: Alexander Lakhin <exclusion(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Subject: Re: BUG #18449: Altering column type fails when an SQL routine depends on the column
Date: 2024-05-01 13:00:00
Message-ID: 548a47bc-87ae-b3df-c6a2-60b9966f808b@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello Tom,

28.04.2024 04:48, Tom Lane wrote:
> Thanks for the report. It looks like most of the other hard cases
> in RememberAllDependentForRebuilding just error out with code
> along the lines of
>
> ereport(ERROR,
> (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
> errmsg("cannot alter type of a column used by a view or rule"),
>
> I'm inclined to do likewise for functions.

I've discovered one more case, presumably as hard as the other ones:
CREATE TABLE t(a int);
CREATE PUBLICATION p FOR TABLE t WHERE (a > 0);

ALTER TABLE t ALTER COLUMN a TYPE bigint;
fails with:
ERROR:  unexpected object depending on column: publication of table t in publication p

Reproduced on REL_15_STABLE (52e4f0cd4) .. master.

> We could imagine trying
> to re-parse the function definition against the new column type,
> but there are way too many ways for that to go wrong. Just for
> starters, there are possibly-security-grade hazards if the current
> search_path isn't what it was when the function was created. There's
> no guarantee that we'd succeed anyway, eg the new column type might
> not work for some function or operator that's applied to it, and if
> not the resulting error message would likely be very surprising.

It looks like all these considerations apply to expressions defining row
filters for publications...

Best regards,
Alexander

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2024-05-01 14:08:43 Re: BUG #18449: Altering column type fails when an SQL routine depends on the column
Previous Message Jernej Simončič 2024-05-01 11:12:50 Re: BUG #18453: --exclude-database has problems with capital letters