BUG #13126: table constraint loses its comment
От | xi@resolvent.net |
---|---|
Тема | BUG #13126: table constraint loses its comment |
Дата | |
Msg-id | 20150422154850.5198.26685@wrigleys.postgresql.org обсуждение исходный текст |
Ответы |
Re: BUG #13126: table constraint loses its comment
|
Список | pgsql-bugs |
The following bug has been logged on the website: Bug reference: 13126 Logged by: Kirill Simonov Email address: xi@resolvent.net PostgreSQL version: 9.4.1 Operating system: Ubuntu 15.04 Description: In some circumstances, the comment on a table constraint disappears. Here is an example: -- Create a table with a primary key constraint. CREATE TYPE enum1 AS ENUM ('foo', 'bar'); CREATE TYPE enum2 AS ENUM ('foo', 'bar', 'baz'); CREATE TABLE t (x enum1 NOT NULL); ALTER TABLE t ADD CONSTRAINT t_pk PRIMARY KEY (x); COMMENT ON CONSTRAINT t_pk ON t IS 'the primary key of table "t"'; -- Find the constraint: -- -- oid -- --------- -- 3400853 -- (1 row) SELECT c.oid FROM pg_constraint c WHERE c.conname = 't_pk'; -- Find the comment on the constraint: -- -- description -- ------------------------------ -- the primary key of table "t" -- (1 row) SELECT d.description FROM pg_description d, pg_constraint c WHERE d.classoid = 'pg_constraint'::regclass AND c.conname = 't_pk' AND d.objoid = c.oid; -- Change the type of the primary key column. ALTER TABLE t ALTER COLUMN x SET DATA TYPE enum2 USING x::text::enum2; -- The constraint now has a different OID: -- -- oid -- --------- -- 3400855 -- (1 row) SELECT c.oid FROM pg_constraint c WHERE c.conname = 't_pk'; -- The constraint comment is lost: -- -- description -- ------------- -- (0 rows) SELECT d.description FROM pg_description d, pg_constraint c WHERE d.classoid = 'pg_constraint'::regclass AND c.conname = 't_pk' AND d.objoid = c.oid; -- Cleanup. DROP TABLE t; DROP TYPE enum1; DROP TYPE enum2;
В списке pgsql-bugs по дате отправления: