Re: TRUNCATE TABLE corrupts pg_class.relfilenode = pg_attrdef.pg_attrdef

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sebastien FLAESCH <sf(at)4js(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: TRUNCATE TABLE corrupts pg_class.relfilenode = pg_attrdef.pg_attrdef
Date: 2017-05-22 12:04:23
Message-ID: 64541.1495454663@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Sebastien FLAESCH <sf(at)4js(dot)com> writes:
> It is normal that a TRUNCATE TABLE statement changes the table/sequence relation in pg_attrdef?

It is normal for TRUNCATE, as well as several other kinds of DDL, to
change relfilenode.

> test1=> select a.adsrc from pg_class p join pg_attrdef a on (p.relfilenode = a.adrelid) where lower(p.relname) = lower('mytab');

This query is simply wrong; the join column should be p.oid. See the
system catalog definitions,

https://www.postgresql.org/docs/current/static/catalogs.html

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Eliober Cleger Despaigne 2017-05-23 18:38:45 about LEFT and INNER JOIN
Previous Message Sebastien FLAESCH 2017-05-22 11:14:05 Re: TRUNCATE TABLE corrupts pg_class.relfilenode = pg_attrdef.pg_attrdef