Re: BUG #17271: Updating enum columns type fails when constraints exist - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #17271: Updating enum columns type fails when constraints exist
Date
Msg-id 321163.1636035777@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #17271: Updating enum columns type fails when constraints exist  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-bugs
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Thu, Nov 4, 2021 at 6:54 AM PG Bug reporting form <noreply@postgresql.org>
> wrote:
>> ERROR:  operator does not exist: direction_state = direction_state_old

> This does not surprise me - why do you believe it is a bug?  What should
> happen?

Yeah.  Concretely, what you have in the constraint (after the RENAME
TYPE) is

# \d example
...
Check constraints:
    "ck_example_direction" CHECK (direction = 'DOWN'::direction_state_old AND below OR NOT below)

Simply updating "direction" to some other type doesn't provide any
guidance about changing the type of the constant, so re-parsing the
constraint fails.  It's hard to see what we could do here that
wouldn't involve a lot of guesswork and chances of getting things
wrong.

I concur with David's advice that ALTER TYPE ADD VALUE would
be a better answer, at least for the specific use-case you're
showing here.

            regards, tom lane



pgsql-bugs by date:

Previous
From: Amaury Dumoulin
Date:
Subject: Re: BUG #17271: Updating enum columns type fails when constraints exist
Next
From: Tom Lane
Date:
Subject: Re: BUG #17271: Updating enum columns type fails when constraints exist