From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: amaury@castordoc.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #17271: Updating enum columns type fails when constraints exist
Date: Thu, 04 Nov 2021 10:22:57 -0400
Message-ID: <321163.1636035777@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwaY4CjKb=yHDMhSfER+y4P9p=vnC0PJ3Gdve5tewA15eA@mail.gmail.com>
References: <17271-8b4317357c4991e2@postgresql.org>
<CAKFQuwaY4CjKb=yHDMhSfER+y4P9p=vnC0PJ3Gdve5tewA15eA@mail.gmail.com>
"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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17271: Updating enum columns type fails when constraints exist
In-Reply-To: <321163.1636035777@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox