Inconsistency between attname of index and attname of relation
От | Ronan Dunklau |
---|---|
Тема | Inconsistency between attname of index and attname of relation |
Дата | |
Msg-id | CAA8M49r=1XoE27tQ08sAPhft_ayBu4Vvib+ubwX4SRqtUGJ+3g@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: Inconsistency between attname of index and attname of relation
Re: Inconsistency between attname of index and attname of relation |
Список | pgsql-hackers |
Hello,
I've noticed that renaming an indexed column produces inconsistencies in the catalog. Namely, the attname of the attribute of the relation is properly updated, whereas the attname of the attribute in the index is not, and keeps the old value.
Example:
test # create table test (id int primary key);
CREATE TABLE
test # alter table test rename id to idnew;
ALTER TABLE
test # select attrelid::regclass, attname from pg_attribute where attrelid in ('test'::regclass, 'test_pkey'::regclass) and attnum > 0;
attrelid | attname
-----------+---------
test | idnew
test_pkey | id
CREATE TABLE
test # alter table test rename id to idnew;
ALTER TABLE
test # select attrelid::regclass, attname from pg_attribute where attrelid in ('test'::regclass, 'test_pkey'::regclass) and attnum > 0;
attrelid | attname
-----------+---------
test | idnew
test_pkey | id
We ran into that while using wal2json, which uses the replication id index attnames to identify which columns are part of the primary key. If the primary key column has been renamed, we end with no information about the identity of the tuple being updated / deleted.
I think this could be considered a bug in Postgres. If it isn't, what should be the proper way to retrieve this information ?
В списке pgsql-hackers по дате отправления: