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 1kQBI5-0003fY-Gb for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Oct 2020 15:23:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kQBI4-0004iW-B9 for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Oct 2020 15:23:40 +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 1kQBI4-0004fD-4r for pgsql-hackers@lists.postgresql.org; Wed, 07 Oct 2020 15:23:40 +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 1kQBI0-0002n0-41 for pgsql-hackers@lists.postgresql.org; Wed, 07 Oct 2020 15:23:39 +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 097FNYbj2151251; Wed, 7 Oct 2020 11:23:34 -0400 From: Tom Lane To: Maksim Kita cc: pgsql-hackers@lists.postgresql.org Subject: Re: Allow deleting enum value In-reply-to: <20201007142656.GA181015@yetti> References: <20201007142656.GA181015@yetti> Comments: In-reply-to Maksim Kita message dated "Wed, 07 Oct 2020 17:26:56 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2151249.1602084214.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 07 Oct 2020 11:23:34 -0400 Message-ID: <2151250.1602084214@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Maksim Kita writes: > There is a question related to TODO task with name "Allow deleting enume= rated values from an existing enumerated data type". > I made simple changes in parser and implement RemoveEnumLabel function, = but as I understand if enum value that we want to = > delete is in use by some tables, we have to prevent deletion to avoid in= consistency. It's a lot worse than that. Even if you could ensure that the value is no longer present in any tables (which you cannot really, because of race conditions), that is not sufficient to ensure that it's not present in any indexes. For example, if a specific value has managed to work its way up into the upper levels of a btree index, it's basically never going to disappear short of a full REINDEX. So we have to keep around sufficient information to allow it to be compared correctly. That TODO item should either be removed or marked with a warning stating that it's next door to impossible. (Unfortunately, a lot of our TODO items are like that ... there's usually a good reason why they're not done already.) regards, tom lane