Obviously, you are facing a naming conflict.
Error message for missing enum value:
ERROR: invalid input value for enum rainbow: "below" LINE 1: INSERT INTO t VALUES (1, 'below');
Your error message indicates that there is a composite type with the same name, which is most likely associated with a table with the same name . You must avoid using identical names !
For the general public to reproduce, view the following demo:
CREATE TYPE contacts AS ENUM ('above', 'below', 'lateral'); SELECT 'above'::contacts; -- all good, before the next step CREATE TEMP TABLE contacts (id int, x text); -- !the crucial part SELECT string_agg(e.enumlabel, '|') as enum_value FROM pg_type t JOIN pg_enum e on t.oid = e.enumtypid JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace WHERE typname = 'contacts'; -- all good -- DROP TABLE t; CREATE TEMP TABLE t (id int, r contacts); INSERT INTO t VALUES (1, 'above'); -- ERROR SELECT 'above'::contacts; -- same ERROR
This can only happen if the enumeration type and the table (composite type) exist in two different schemes . PostgreSQL would not allow in the same scheme. In your case, the schema with the table schema (composite type) clearly appeared before the enumeration type schema in search_path when creating the table. Or perhaps the type of enumeration did not even exist at that time.
In my example, the temporary table comes first because the pg_temp schema pg_temp to first place in the search path. When I create the contacts table, it is considered a composite type ( pg_temp.contacts ), not an enumeration type ( public.contacts ).
If you must have a table and enumeration with the same name, make sure that schema-qualify type names . In my example:
pg_temp.contacts
source share