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

From Justin Pryzby
Subject Re: Allow deleting enum value
Date
Msg-id 20201026003303.GO9241@telsasoft.com
Whole thread Raw
In response to Re: Allow deleting enum value  (Maksim Kita <kitaetoya@gmail.com>)
List pgsql-hackers
On Wed, Oct 07, 2020 at 11:47:07PM +0300, Maksim Kita wrote:
> I like the idea, during prototype I added additional column and modified
> enum_in method. But enum_in is called in contexts that can be important
> for user (like comparisons).
...
> postgres=# ALTER TYPE test_enum DELETE VALUE '2';
> ALTER TYPE

I think it should be called "DROP VALUE"

> postgres=# SELECT * FROM test_table WHERE value = '2';
> ERROR:  enum value is dropped test_enum: "2"
> LINE 1: SELECT * FROM test_table WHERE value = '2';

This fails if the value was never added, so why wouldn't it also fail if the
value is added and then removed ?

Maybe you'd want to rename old enum names to something "unlikely", like what we
do for dropped attributes in RemoveAttributeById.

How do you want to handle "adding a value back" ?

I think you should determine/propose/discuss the desired behaviors before
implementing it.

I think you'd also need to update these:
src/bin/pg_dump/pg_dump.c
src/bin/psql/describe.c
src/bin/psql/tab-complete.c
doc/src/sgml/catalogs.sgml
src/test/regress/sql/enum.sql
src/test/regress/expected/enum.out

-- 
Justin



pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: POC: contrib/unaccent as IMMUTABLE
Next
From: Kyotaro Horiguchi
Date:
Subject: Re: Mop-up around psql's \connect behavior