Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Ykwtf-000407-PZ for pgsql-bugs@arkaria.postgresql.org; Wed, 22 Apr 2015 15:49:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Ykwtf-0004Lh-9L for pgsql-bugs@arkaria.postgresql.org; Wed, 22 Apr 2015 15:49:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Ykwte-0004Lb-Lt for pgsql-bugs@postgresql.org; Wed, 22 Apr 2015 15:49:06 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Ykwtb-0005ZS-2a for pgsql-bugs@postgresql.org; Wed, 22 Apr 2015 15:49:05 +0000 MIME-Version: 1.0 Subject: BUG #13126: table constraint loses its comment To: pgsql-bugs@postgresql.org From: xi@resolvent.net Date: Wed, 22 Apr 2015 15:48:50 +0000 Message-ID: <20150422154850.5198.26685@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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; -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs