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

From Maksim Kita
Subject Re: Allow deleting enum value
Date
Msg-id 20201007204707.GA210713@yetti
Whole thread Raw
In response to Re: Allow deleting enum value  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Allow deleting enum value  (Justin Pryzby <pryzby@telsasoft.com>)
List pgsql-hackers
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).

Example:

postgres=# CREATE TYPE test_enum AS enum ('1', '2', '3');
CREATE TYPE

postgres=# CREATE TABLE test_table ( value test_enum );
postgres=# INSERT INTO test_table VALUES ('1'), ('2'), ('3');
INSERT 0 3

postgres=# ALTER TYPE test_enum DELETE VALUE '2';
ALTER TYPE

postgres=# INSERT INTO test_table VALUES ('2');
ERROR:  enum value is dropped test_enum: "2"
LINE 1: INSERT INTO test_table VALUES ('2');

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';

postgres=# UPDATE test_table SET value = '3' WHERE value = '2';
ERROR:  enum value is dropped test_enum: "2"
LINE 1: UPDATE test_table SET value = '3' WHERE value = '2';

Probably we need to make more specific change for enum type to prevent
using of dropped column in context of insert or update (where we
creating dropped enum value), but not in others.

Is that possible ? What places should I look into ? Thanks.

Best regards,
Maksim Kita

Attachment

pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Recent failures on buildfarm member hornet
Next
From: Noah Misch
Date:
Subject: Re: Recent failures on buildfarm member hornet