information_schema.constraint_column_usage shows wrong table name - Mailing list pgsql-bugs

From Alex Zeng
Subject information_schema.constraint_column_usage shows wrong table name
Date
Msg-id SY4PR01MB7201EE307A0E5F28C4BF26B8B7F79@SY4PR01MB7201.ausprd01.prod.outlook.com
Whole thread Raw
Responses Re: information_schema.constraint_column_usage shows wrong table name  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: information_schema.constraint_column_usage shows wrong table name  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Hi,

When creating a constraint from table A to table B, the table name and column name in information_schema.constraint_column_usage  shows table B. That makes impossible to check whether a constraint exists as we can have a constraint from table C to B and they will have same value in information_schema.constraint_column_usage.

Should we make the table_name and column_name as A's name?

=# create table item(id integer, item_name character VARYING(64),cat_id integer);
CREATE TABLE
=# create table catagory(id integer, cat_name character VARYING(64),CONSTRAINT catagory_pkey PRIMARY KEY (id) );
CREATE TABLE
=# alter table item add constraint fk_cat_id FOREIGN KEY (cat_id) REFERENCES catagory(id);
ALTER TABLE
=# select * from information_schema.constraint_column_usage where constraint_name='fk_cat_id';
 table_catalog | table_schema | table_name | column_name | constraint_catalog | constraint_schema | constraint_name
---------------+--------------+------------+-------------+--------------------+-------------------+-----------------
 vretrieve     | public       | catagory   | id          | vretrieve          | public            | fk_cat_id
(1 row)


This email with any attachments is confidential and may be subject to legal privilege. If it is not intended for you please reply immediately, destroy it and do not copy, disclose or use it in any way.

pgsql-bugs by date:

Previous
From: Rob Mingus
Date:
Subject: Re: BUG #17138: account set up and password problems
Next
From: "David G. Johnston"
Date:
Subject: Re: information_schema.constraint_column_usage shows wrong table name