information_schema.constraint_column_usage shows wrong table name
От | Alex Zeng |
---|---|
Тема | information_schema.constraint_column_usage shows wrong table name |
Дата | |
Msg-id | SY4PR01MB7201EE307A0E5F28C4BF26B8B7F79@SY4PR01MB7201.ausprd01.prod.outlook.com обсуждение исходный текст |
Ответы |
Re: information_schema.constraint_column_usage shows wrong table name
Re: information_schema.constraint_column_usage shows wrong table name |
Список | 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)В списке pgsql-bugs по дате отправления: