"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