agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Sebastien FLAESCH <sf@4js.com>
To: pgsql-sql@postgresql.org
Subject: TRUNCATE TABLE corrupts pg_class.relfilenode = pg_attrdef.pg_attrdef
Date: Mon, 22 May 2017 12:51:27 +0200
Message-ID: <66def74b-633e-65a0-cf44-4d486f15ebd9@4js.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>
Hi all,
Testing with Postgresql 9.6rc1 (but also detected with prior versions):
It is normal that a TRUNCATE TABLE statement changes the table/sequence relation in pg_attrdef?
test1=> create table mytab ( pkey serial, name varchar(10) );
test1=> select a.adsrc from pg_class p join pg_attrdef a on (p.relfilenode = a.adrelid) where lower(p.relname) = lower('mytab');
adsrc
-------------------------------------
nextval('mytab_pkey_seq'::regclass)
(1 row)
test1=> truncate table mytab;
TRUNCATE TABLE
test1=> select a.adsrc from pg_class p join pg_attrdef a on (p.relfilenode = a.adrelid) where lower(p.relname) = lower('mytab');
adsrc
-------
(0 rows)
test1=> select adrelid, adsrc from pg_attrdef where adsrc like '%mytab%';
adrelid | adsrc
---------+-------------------------------------
6904163 | nextval('mytab_pkey_seq'::regclass)
(1 row)
Are we mis-using the condition (p.relfilenode = a.adrelid) in the first SELECT?
How can we easily check if a table is defined with a SERIAL type?
Thanks!
Seb
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
view thread (5+ messages) latest in thread
Message-ID: <66def74b-633e-65a0-cf44-4d486f15ebd9@4js.com>
Permalink: ../66def74b-633e-65a0-cf44-4d486f15ebd9@4js.com/
Also on: postgresql.org/message-id/66def74b-633e-65a0-cf44-4d486f15ebd9@4js.com
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: sf@4js.com
Subject: Re: TRUNCATE TABLE corrupts pg_class.relfilenode = pg_attrdef.pg_attrdef
In-Reply-To: <66def74b-633e-65a0-cf44-4d486f15ebd9@4js.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox