Re: BUG #19903: ALTER COLUMN TYPE: "unexpected object depending on column" internal error via partition key

From: Andres Freund <andres(at)anarazel(dot)de>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: hackerzheng666(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Re: BUG #19903: ALTER COLUMN TYPE: "unexpected object depending on column" internal error via partition key
Date: 2026-11-16 23:57:55
Message-ID: ububohc36fspajtekbckcdyzgjusw3wadqcw2kgtbyjyh2kmzy@bu5quc356a5p
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

On 2026-11-16 18:01:01 -0500, Robert Haas wrote:
> On Mon, Nov 16, 2026 at 5:53 PM Andres Freund <andres(at)anarazel(dot)de> wrote:
> > Maybe I'm just tired, but that's not something anybody actually cares about
> > right? I guess we can dress this up to have a nicer error message, but also,
> > who cares?
> >
> > I think we want to do something here, it might be better to focus on rejecting
> > such absurd partition by clauses...
>
> The LLM-generated patch I attached before gives a nice error message
> for ALTER COLUMN TYPE, which I agree is nice but not critical, but it
> also makes ALTER COLUMN .. SET EXPRESSION succeed instead of failing.
> If that case is safe, we probably want to allow it.

I am very hesitant to expand what is allowed around any of this without very
careful analysis. It's not at all hard to imagine that allowing such a change
would add security issues. In this case it also might be breaking
partitioning, afaict such a SET EXPRESSION, were it allowed, could change what
partition a row belongs in, no?

Even if it is correct, I would vote strongly against allowing more in the back
branches.

Generally around all of this allowing more IMO is an anti-goal. The amount of
useless corner-case crap that we allow has cost me way way too much time over
the last months.

Nobody can tell me that it's useful to have partitioning expressions of this
kind:

-- Check if the rowtype is used in PARTITION BY expression of another table.
CREATE TABLE gtest31_1 (a int GENERATED ALWAYS AS (123) VIRTUAL);
CREATE TABLE gtest31_2 (b text) PARTITION BY RANGE ((('(1)'::gtest31_1).a + length(b)));

Greetings,

Andres

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message shihao zhong 2026-11-17 00:55:31 Re: BUG #19899: PL/Python backend crashes (SIGSEGV) when converting a column value to a Python object fails
Previous Message Tom Lane 2026-11-16 23:28:21 Re: 16.16: join order regression for pg_indexes self-join (schema filter applied last), ~50x slower than 16.15