Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 75D79B61638 for ; Tue, 31 May 2011 04:44:38 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 52780-09 for ; Tue, 31 May 2011 07:44:31 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.anarazel.de (mail.anarazel.de [217.115.131.40]) by mail.postgresql.org (Postfix) with ESMTP id 4FFDEB61584 for ; Tue, 31 May 2011 04:44:31 -0300 (ADT) Received: from intern.anarazel.de (f053042007.adsl.alicedsl.de [78.53.42.7]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPA id 802EA448005; Tue, 31 May 2011 09:44:29 +0200 (CEST) From: Andres Freund To: pgsql-bugs@postgresql.org Subject: Re: Unlogged tables cannot be truncated twice Date: Tue, 31 May 2011 09:44:25 +0200 User-Agent: Kmail Cc: Alvaro Herrera , =?utf-8?q?C=C3=A9dric_Villemain?= , Greg Sabino Mullane References: <20110530160043.GC3012@core.home> <201105310247.50055.andres@anarazel.de> <1306805168-sup-4188@alvh.no-ip.org> In-Reply-To: <1306805168-sup-4188@alvh.no-ip.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <201105310944.26712.andres@anarazel.de> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/233 X-Sequence-Number: 30372 On Tuesday, May 31, 2011 03:27:22 Alvaro Herrera wrote: > Excerpts from Andres Freund's message of lun may 30 20:47:49 -0400 2011: > > On Tuesday, May 31, 2011 02:35:58 AM Andres Freund wrote: > > > On Tuesday, May 31, 2011 02:14:00 AM Andres Freund wrote: > > > > On Tuesday, May 31, 2011 01:56:05 AM C=C3=A9dric Villemain wrote: > > > > > I remove my own explanations as we conclude on the same thing. > > > > > Attached is the fix by adding a (!reindex) in the index.c if(). > > > >=20 > > > > Thats imo wrong because it will break a plain REINDEX? > > >=20 > > > > I think one possible correct fix would be the attached: > > > My version was wrong as well because it did not observe > > > RelationTruncate's nblocks argument. That function is used to > > > "shorten" the relation in vacuum. So dropping the init fork there is > > > not a good idea. > > >=20 > > > So I think it is the simpler version of simply checking the existance > > > of the fork before creating is ok. >=20 > Hmm, I wonder if what we should be doing here is observe isreindex in > index_build to avoid creating the init fork. Doing smgr access at that > level seems wrong. isreindex doesn't contain the necessary informormation as its set doing a=20 REINDEX even though a new relfilenode is created and thus the fork needs to= be=20 created. It doesn't seem terribly clean do do the !smgrexists(), I aggree with you=20 there. On the other hand we are calling smgrcreate() two lines down anyway.= I=20 personally don't realy like the placement of that piece of code very much.= =20 Doing it in index_build seems to be the wrong place. I don't think there=20 really is a good place for it right now. Andres