Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1middy-0000OG-DV for pgsql-bugs@arkaria.postgresql.org; Thu, 04 Nov 2021 14:23:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1middx-0003I0-9y for pgsql-bugs@arkaria.postgresql.org; Thu, 04 Nov 2021 14:23:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1middx-0003Hr-2Z for pgsql-bugs@lists.postgresql.org; Thu, 04 Nov 2021 14:23:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1middu-0004ZJ-EO for pgsql-bugs@lists.postgresql.org; Thu, 04 Nov 2021 14:23:03 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1A4EMvNo321164; Thu, 4 Nov 2021 10:22:57 -0400 From: Tom Lane To: "David G. Johnston" cc: amaury@castordoc.com, PostgreSQL mailing lists Subject: Re: BUG #17271: Updating enum columns type fails when constraints exist In-reply-to: References: <17271-8b4317357c4991e2@postgresql.org> Comments: In-reply-to "David G. Johnston" message dated "Thu, 04 Nov 2021 06:58:04 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <321162.1636035777.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 04 Nov 2021 10:22:57 -0400 Message-ID: <321163.1636035777@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Thu, Nov 4, 2021 at 6:54 AM PG Bug reporting form > wrote: >> ERROR: operator does not exist: direction_state =3D direction_state_ol= d > 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 =3D 'DOWN'::direction_state_ol= d 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