Re: BUG #13034: Inconsistent attrelid field in pg_attribute table after adding columns to table.

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: alemagox(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #13034: Inconsistent attrelid field in pg_attribute table after adding columns to table.
Date: 2015-04-13 13:25:12
Message-ID: 20150413132512.GM4369@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

alemagox(at)gmail(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alejandro Sánchez Medina 2015-04-13 13:41:40 Re: BUG #13034: Inconsistent attrelid field in pg_attribute table after adding columns to table.
Previous Message Sandeep Thakkar 2015-04-13 12:10:05 Re: BUG #13013: Cannot install PostgreSQL