Re: Allow deleting enum value - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Allow deleting enum value
Date
Msg-id 2151250.1602084214@sss.pgh.pa.us
Whole thread Raw
In response to Allow deleting enum value  (Maksim Kita <kitaetoya@gmail.com>)
Responses Re: Allow deleting enum value
List pgsql-hackers
Maksim Kita <kitaetoya@gmail.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
wantto  
> 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



pgsql-hackers by date:

Previous
From: Patrick REED
Date:
Subject: Re: Prepared Statements
Next
From: Tom Lane
Date:
Subject: Re: Allow deleting enum value