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

Started by PG Bug reporting formalmost 8 years ago6 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

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;

#2Andrew Gierth
andrew@tao11.riddles.org.uk
In reply to: PG Bug reporting form (#1)
Re: BUG #15286: BEFORE or AFTER not working while adding values for existing enums

"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)

#3Nivruth Nandigam
nivruth_n@yahoo.com
In reply to: Andrew Gierth (#2)
Re: BUG #15286: BEFORE or AFTER not working while adding values for existing enums

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. 

Sent from Yahoo Mail on Android

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)

#4Andrew Gierth
andrew@tao11.riddles.org.uk
In reply to: Nivruth Nandigam (#3)
Re: BUG #15286: BEFORE or AFTER not working while adding values for existing enums

"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.

#5Nivruth Nandigam
nivruth_n@yahoo.com
In reply to: Andrew Gierth (#4)
Re: BUG #15286: BEFORE or AFTER not working while adding values for existing enums

Thanks Andrew, that makes sense. Could you also please answer these questions if possible? 
impact to table on adding values to existing enum postgresql
|
|
|
| | |

|

|
|
| |
impact to table on adding values to existing enum postgresql

I am new to PostgreSQL and using enum (MY_ENUM) as a column type for a table (MY_TABLE). Let's say MY_ENUM has values ('one', 'three', 'four') with default 'one' and there are 1 million records in
| |

|

|

Thanks,Nivruth 

Sent from Yahoo Mail on Android

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.

#6Andrew Gierth
andrew@tao11.riddles.org.uk
In reply to: Nivruth Nandigam (#5)
Re: BUG #15286: BEFORE or AFTER not working while adding values for existing enums

"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)