Re: Allow deleting enum value

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Maksim Kita <kitaetoya(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Allow deleting enum value
Date: 2020-10-07 15:23:34
Message-ID: 2151250.1602084214@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Maksim Kita <kitaetoya(at)gmail(dot)com> writes:
> There is a question related to TODO task with name "Allow deleting enumerated 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 inconsistency.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-10-07 16:03:15 Re: Allow deleting enum value
Previous Message Patrick REED 2020-10-07 14:27:22 Re: Prepared Statements