Thread: BUG #15286: BEFORE or AFTER not working while adding values forexisting enums

BUG #15286: BEFORE or AFTER not working while adding values forexisting enums

From
PG Bug reporting form
Date:
The following bug has been logged on the website:

Bug reference:      15286
Logged by:          Nivruth Nandigam
Email address:      nivruth_n@yahoo.com
PostgreSQL version: 10.4
Operating system:   Windows
Description:

Hi there,

I'm trying to modify an existing enum and use the BEFORE or AFTER feature to
add a value in between the existing values but I'm noticing that the values
are only being added to the enum in the end. Please look into this and fix
this as soon as possible. The query I'm using is 

alter type my_enum add value 'second' after 'one;


>>>>> "PG" == PG Bug reporting form <noreply@postgresql.org> writes:

 PG> I'm trying to modify an existing enum and use the BEFORE or AFTER
 PG> feature to add a value in between the existing values but I'm
 PG> noticing that the values are only being added to the enum in the
 PG> end.

How are you looking at the order of values?

I get this:

create type e1 as enum ('foo','bar','baz');
alter type e1 add value 'quux' after 'foo';

postgres=# select * from unnest(enum_range(null::e1)) order by 1;
 unnest 
--------
 foo
 quux
 bar
 baz
(4 rows)

which is the expected order.

-- 
Andrew (irc:RhodiumToad)


Re: BUG #15286: BEFORE or AFTER not working while adding values forexisting enums

From
Nivruth Nandigam
Date:
Right clicking on the source and then checking the values. Executing this query also gives me the values in order but shouldn't the enum also reflect the order when right clicked and checked?

Also, when I try to set this as a db column I see the wrong order in the drop down, the added values appear last in the drop down menu of the enum column. 


On Thu, Jul 19, 2018 at 10:15 PM, Andrew Gierth
<andrew@tao11.riddles.org.uk> wrote:
>>>>> "PG" == PG Bug reporting form <noreply@postgresql.org> writes:

PG> I'm trying to modify an existing enum and use the BEFORE or AFTER
PG> feature to add a value in between the existing values but I'm
PG> noticing that the values are only being added to the enum in the
PG> end.

How are you looking at the order of values?

I get this:

create type e1 as enum ('foo','bar','baz');
alter type e1 add value 'quux' after 'foo';

postgres=# select * from unnest(enum_range(null::e1)) order by 1;
unnest
--------
foo
quux
bar
baz
(4 rows)

which is the expected order.

--
Andrew (irc:RhodiumToad)
>>>>> "Nivruth" == Nivruth Nandigam <nivruth_n@yahoo.com> writes:

 Nivruth> Right clicking

Postgresql does not have anything that you could "right click" on. Any
graphical tool you might be using (whether it's pgadmin or something
else) is a separate project; bugs in such projects are NOT handled on
this list.

-- 
Andrew.


Re: BUG #15286: BEFORE or AFTER not working while adding values forexisting enums

From
Nivruth Nandigam
Date:
Thanks Andrew, that makes sense. Could you also please answer these questions if possible? 



Thanks,
Nivruth 


On Thu, Jul 19, 2018 at 10:48 PM, Andrew Gierth
<andrew@tao11.riddles.org.uk> wrote:
>>>>> "Nivruth" == Nivruth Nandigam <nivruth_n@yahoo.com> writes:

Nivruth> Right clicking

Postgresql does not have anything that you could "right click" on. Any
graphical tool you might be using (whether it's pgadmin or something
else) is a separate project; bugs in such projects are NOT handled on
this list.


--
Andrew.
>>>>> "Nivruth" == Nivruth Nandigam <nivruth_n@yahoo.com> writes:

 Nivruth> Thanks Andrew, that makes sense. Could you also please answer
 Nivruth> these questions if possible?

 [ https://stackoverflow.com/questions/51434307 ]

Adding a value to an enum does not have any impact on tables that use
the enum type, regardless of where you add the value.

-- 
Andrew (irc:RhodiumToad)