I am trying to add new type value to my existing types in PostgreSQL. But I get the following error
error: ALTER TYPE ... ADD cannot run inside a transact
Workaround for earlier versions of PostgreSQL shown here:
Note this will require special permissions because it changes a system table.
'NEW_ENUM_VALUE'
with the value you want. 'type_egais_units'
with the oid
of the enum you want to change. (Use SELECT * FROM pg_enum
to find the enum you want to update, in my case it was a 5-digit number like '19969'
)The statement:
INSERT INTO pg_enum (
enumtypid,
enumlabel,
enumsortorder
)
SELECT
'type_egais_units'::regtype::oid,
'NEW_ENUM_VALUE',
(SELECT MAX(enumsortorder) + 1 FROM pg_enum WHERE enumtypid = 'type_egais_units'::regtype)
Of course , upgrading PostgreSQL as suggested in the accepted answer, is probably the best.
Does anyone know how to avoid using transactions when running queries from pgAdmin Version 3.5? (i.e. when executing with F5?)