Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m84BW-0001ou-0X for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Jul 2021 17:14:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m84BU-00006e-LP for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Jul 2021 17:14:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m84BT-00006A-T4 for pgsql-hackers@lists.postgresql.org; Mon, 26 Jul 2021 17:14:32 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m84BQ-0003xL-Ay for pgsql-hackers@lists.postgresql.org; Mon, 26 Jul 2021 17:14:31 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id E2D6F5C00E6; Mon, 26 Jul 2021 13:14:24 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 26 Jul 2021 13:14:24 -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:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=NsSrr0xsHtmR1PtrlvpIVQhbJyNu+aSM+FdqplVdwBs=; b=l5k2uH7V 0ZuM+BjrqzB1I8FAvNQKCrs0vde8d8RxtL8CbvulbDObsYZ+rZt83bbGSxlbZzrq LfkV81JmgCi9SA0wyc5RmPiupualKGXXr8+IhrQ9ZBlvbg62FZv3Qy7b0cJo6hEZ qUXjm1dHMXjydZ9a8CiGDhci8650Org5OCOLJMi8jD/apu2mLzUX/sdWtBYUqGkE /wM4K043oazqKCyy+EtN15bYxwc3qZHUbrX+PN9MQ0v6ZfmZU1a2wdDC9GUqSrjT Yzp8KXJqrLCg6ctPrHS5sSs5tGql0NDZ87533LFU24jfhZRos/2itjOQWZprbVnp Pgem6lj1WgFTyw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrgeehgddutdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpedujeevjeffjeevuddutedvkeeiueeitddvieelfeekveej udefgeeuvdejhfeuleenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhh vghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 26 Jul 2021 13:14:23 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 897A72A06A7; Mon, 26 Jul 2021 13:14:20 -0400 (-04) Date: Mon, 26 Jul 2021 13:14:20 -0400 From: Alvaro Herrera To: Tom Lane Cc: Arne Roland , vignesh C , Zhihong Yu , Pg Hackers Subject: Re: Rename of triggers for partitioned tables Message-ID: <202107261714.kuzrvstzrufh@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1337562.1627224583@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Jul-25, Tom Lane wrote: > Perhaps there's no actual bug there, but it's still horrible coding. > For one thing, the implication that found could be negative is extremely > confusing to readers. A boolean might be better. However, I wonder why > you bothered with a flag in the first place. The usual convention if > we know there can be only one match is to just not write a loop at all, > with a suitable comment, like this pre-existing example elsewhere in > trigger.c: > > /* There should be at most one matching tuple */ > if (HeapTupleIsValid(tuple = systable_getnext(tgscan))) > > If you're not quite convinced there can be only one match, then it > still shouldn't be an Assert --- a real test-and-elog would be better. I agree that coding there was dubious. I've removed the flag and assert. Arne complained that there should be a unique constraint on (tgrelid, tgparentid) which would sidestep the need for this to be a loop. I don't think it's really necessary, and I'm not sure how to create a system index WHERE tgparentid <> 0. -- Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/ "Saca el libro que tu religión considere como el indicado para encontrar la oración que traiga paz a tu alma. Luego rebootea el computador y ve si funciona" (Carlos Duclós)