information_schema.constraint_column_usage shows wrong table name

From: Alex Zeng <Alex(dot)Zeng(at)datam(dot)co(dot)nz>
To: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: information_schema.constraint_column_usage shows wrong table name
Date: 2021-08-10 02:57:00
Message-ID: SY4PR01MB7201EE307A0E5F28C4BF26B8B7F79@SY4PR01MB7201.ausprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2021-08-10 03:17:59 Re: information_schema.constraint_column_usage shows wrong table name
Previous Message Rob Mingus 2021-08-10 02:02:22 Re: BUG #17138: account set up and password problems