Re: BUG #13034: Inconsistent attrelid field in pg_attribute table after adding columns to table. - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: BUG #13034: Inconsistent attrelid field in pg_attribute table after adding columns to table.
Date
Msg-id 20150413132512.GM4369@alvh.no-ip.org
Whole thread Raw
In response to BUG #13034: Inconsistent attrelid field in pg_attribute table after adding columns to table.  (alemagox@gmail.com)
Responses Re: BUG #13034: Inconsistent attrelid field in pg_attribute table after adding columns to table.  (Alejandro Sánchez Medina <alemagox@gmail.com>)
List pgsql-bugs
alemagox@gmail.com wrote:

> SELECT format_type(a.atttypid, a.atttypmod)
>     FROM pg_attribute a
>         JOIN pg_class b ON (a.attrelid = b.relfilenode)
>         JOIN pg_namespace c ON (c.oid = b.relnamespace)
>     WHERE b.relname = 'test' AND c.nspname = 'ab' AND a.attname = 'id';

pg_attribute.attrelid must be joined to pg_class.oid, not relfilenode.
The relfilenode changes when the table is rewritten, which happens
during some forms of ALTER TABLE and others.

--
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

pgsql-bugs by date:

Previous
From: alemagox@gmail.com
Date:
Subject: BUG #13034: Inconsistent attrelid field in pg_attribute table after adding columns to table.
Next
From: cestel@covermymeds.com
Date:
Subject: BUG #13042: pg_upgrade --check succeeded but run failed due to missing thesaurus file