Причина указана в следующем комментарии в AlterEnum
в src/backend/commands/typecmds.c
:
/*
* Ordinarily we disallow adding values within transaction blocks,
* because we can't cope with enum OID values getting into indexes and
* then having their defining pg_enum entries go away. However, it's
* okay if the enum type was created in the current transaction, since
* then there can be no such indexes that wouldn't themselves go away
* on rollback. (We support this case because pg_dump
* --binary-upgrade needs it.)
Обратите внимание, что это ограничение было снято в commit 212fab99 ; сообщение о фиксации гласит:
To prevent possibly breaking indexes on enum columns, we must keep
uncommitted enum values from getting stored in tables, unless we
can be sure that any such column is new in the current transaction.
Formerly, we enforced this by disallowing ALTER TYPE ... ADD VALUE
from being executed at all in a transaction block, unless the target
enum type had been created in the current transaction. This patch
removes that restriction, and instead insists that an uncommitted enum
value can't be referenced unless it belongs to an enum type created
in the same transaction as the value. Per discussion, this should be
a bit less onerous. It does require each function that could possibly
return a new enum value to SQL operations to check this restriction,
but there aren't so many of those that this seems unmaintainable.
Так что вы можете обновить до PostgreSQL v12 в ближайшее время: ^)