Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f4xRV-0002mP-89 for pgsql-hackers@arkaria.postgresql.org; Sat, 07 Apr 2018 23:40:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f4xRT-0001HN-TF for pgsql-hackers@arkaria.postgresql.org; Sat, 07 Apr 2018 23:40:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f4xRS-0001GJ-VU for pgsql-hackers@lists.postgresql.org; Sat, 07 Apr 2018 23:40:19 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f4xRO-0003aG-K2 for pgsql-hackers@postgresql.org; Sat, 07 Apr 2018 23:40:18 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id A6D2620B56; Sat, 7 Apr 2018 19:40:12 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Sat, 07 Apr 2018 19:40:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=Lwbs0H fSD76g+WEa0fy/U7Pn7vb+b73qk3ZqIEv2Nik=; b=Lktw55kTFiEQoN9BXwD7Ko 0z0jajQCB3kkAGI4gZ9lyasGvLwRcDeYWOVZ7QL52A/nG0t/rgdHVFltI75XVdbl Yrlgewj4jkr6aBYEOO421VCvM8Lhr4Gm2GYdOWXImg1/o+7fDpAX/nu/cBqAv5ft xVHlpj6sJRvNYsSuJy5kckelIXe9YJozpPqEmpWaO+viY64bTjM+2VEEHiUNcQlZ tCeRk/f2N35MEuOMo5nW9Ppdw2pTCrpQfbkK2AjkAxnU4ytgFSm1Um1g53Cx+/rN owTbQf9ZY3C3dpGvkN8XidrGjCFQ2EWiL8whEo8uB8TRztB+JEkcy93snAuXC2yA == X-ME-Sender: Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id 4332FE49E9; Sat, 7 Apr 2018 19:40:12 -0400 (EDT) Subject: Re: [PATCH] Logical decoding of TRUNCATE To: Alvaro Herrera References: <20180405170712.av633jvnnizmd5sn@alvherre.pgsql> Cc: Andres Freund , Marco Nenciarini , Petr Jelinek , Thomas Munro , Simon Riggs , PostgreSQL-development From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: <1baed811-47b2-5b7d-c641-4b7eb01d650f@2ndquadrant.com> Date: Sat, 7 Apr 2018 19:40:11 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180405170712.av633jvnnizmd5sn@alvherre.pgsql> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 4/5/18 13:07, Alvaro Herrera wrote: > Note that you start the loop having the Relation; yet you go extra > length to grab the relnamespace and relname from syscache instead of > just relations[i]->rd_rel->relname etc. fixed > Maybe not a big deal, but for future pg_waldump users I'm sure it'll be > nice to have the OIDs here. done >> +void >> +ExecuteTruncateGuts(List *explicit_rels, List *relids, List *relids_logged, >> + DropBehavior behavior, bool restart_seqs) >> +{ > > Please add a comment atop this function. done >> + /* >> + * Write a WAL record to allow this set of actions to be logically decoded. >> + * >> + * Assemble an array of relids so we can write a single WAL record for the >> + * whole action. >> + */ >> + if (list_length(relids_logged) > 0) >> + { >> + xl_heap_truncate xlrec; >> + int i = 0; > > I wonder if this should happen only if logical decoding? (Maybe it > already occurs because relids_logged would be empty? Worth a comment in > that case) Added an assertion and a comment. Committed with those changes. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services