Hi,
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.
Could you please provide some references where similar functionality was implemented ? Thanks.
Attached basic patch without handling dependencies.
Example of problem that I mention using basic implementation:
postgres=# CREATE TYPE enum_test as ENUM ('1', '2', '3');
CREATE TYPE
postgres=# CREATE TYPE test_enum as ENUM ('1', '2', '3');
CREATE TYPE
postgres=# CREATE TABLE test_table (value test_enum);
CREATE TABLE
postgres=# INSERT INTO test_table VALUES ('1'), ('2');
INSERT 0 2
postgres=# ALTER TYPE test_enum DELETE VALUE '2';
ALTER TYPE
postgres=# SELECT enum_range(NULL::test_enum);
enum_range
------------
{1,3}
(1 row)
postgres=# SELECT * FROM test_table;
ERROR: invalid internal value for enum: 16396
Best regards,
Maksim Kita