BUG #17271: Updating enum columns type fails when constraints exist
От | PG Bug reporting form |
---|---|
Тема | BUG #17271: Updating enum columns type fails when constraints exist |
Дата | |
Msg-id | 17271-8b4317357c4991e2@postgresql.org обсуждение исходный текст |
Ответы |
Re: BUG #17271: Updating enum columns type fails when constraints exist
Re: BUG #17271: Updating enum columns type fails when constraints exist |
Список | pgsql-bugs |
The following bug has been logged on the website: Bug reference: 17271 Logged by: Amaury Dumoulin Email address: amaury@castordoc.com PostgreSQL version: 12.8 Operating system: alpine 3.14 on docker (host macOs 11.6) Description: Error message upon failure The following fails CREATE TYPE direction_state AS ENUM('UP', 'DOWN'); CREATE TABLE example (id SERIAL PRIMARY KEY, direction direction_state NOT NULL, below BOOLEAN NOT NULL); ALTER TABLE example ADD CONSTRAINT ck_example_direction CHECK ((direction = 'DOWN' AND below) OR (NOT below)); ALTER TYPE direction_state RENAME TO direction_state_old; CREATE TYPE direction_state AS ENUM('UP', 'DOWN', 'UNKNOWN'); ALTER TABLE example ALTER COLUMN direction TYPE direction_state USING direction::text::direction_state; DROP TYPE direction_state_old With a sibyllin error message ERROR: operator does not exist: direction_state = direction_state_old HINT: No operator matches the given name and argument types. You might need to add explicit type casts. If we drop and recreate the constraint it works CREATE TYPE direction_state AS ENUM('UP', 'DOWN'); CREATE TABLE example (id SERIAL PRIMARY KEY, direction direction_state NOT NULL, below BOOLEAN NOT NULL); ALTER TABLE example ADD CONSTRAINT ck_example_direction CHECK ((direction = 'DOWN' AND below) OR (NOT below)); ALTER TYPE direction_state RENAME TO direction_state_old; CREATE TYPE direction_state AS ENUM('UP', 'DOWN', 'UNKNOWN'); ALTER TABLE example DROP CONSTRAINT ck_example_direction; ALTER TABLE example ALTER COLUMN direction TYPE direction_state USING direction::text::direction_state; DROP TYPE direction_state_old ALTER TABLE example ADD CONSTRAINT ck_example_direction CHECK ((direction = 'DOWN' AND below) OR (NOT below));
В списке pgsql-bugs по дате отправления: