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 1n9a4m-0006rf-7j for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Jan 2022 22:02:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n9a4l-00062p-2Z for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Jan 2022 22:02:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n9a4k-00062f-Pa for pgsql-hackers@lists.postgresql.org; Mon, 17 Jan 2022 22:02:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n9a4h-0003OK-PJ for pgsql-hackers@postgresql.org; Mon, 17 Jan 2022 22:02:05 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 20HM20xx152508; Mon, 17 Jan 2022 17:02:00 -0500 From: Tom Lane To: Justin Pryzby cc: Alvaro Herrera , pgsql-hackers@postgresql.org, Amit Langote Subject: Re: \d with triggers: more than one row returned by a subquery used as an expression In-reply-to: <20211222210308.GD17618@telsasoft.com> References: <20211217154356.GJ17618@telsasoft.com> <20211222210308.GD17618@telsasoft.com> Comments: In-reply-to Justin Pryzby message dated "Wed, 22 Dec 2021 15:03:08 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <152506.1642456920.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 17 Jan 2022 17:02:00 -0500 Message-ID: <152507.1642456920@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Justin Pryzby writes: > On Fri, Dec 17, 2021 at 09:43:56AM -0600, Justin Pryzby wrote: >> I want to mention that the 2nd problem I mentioned here is still broken= . >> https://www.postgresql.org/message-id/20210717010259.GU20208@telsasoft.= com >> It happens if non-inheritted triggers on child and parent have the same= name. > This is the fix I was proposing > It depends on pg_partition_ancestors() to return its partitions in order= : > this partition =3D> parent =3D> ... =3D> root. I don't think that works at all. I might be willing to accept the assumption about pg_partition_ancestors()'s behavior, but you're also making an assumption about how the output of pg_partition_ancestors() is joined to "pg_trigger AS u", and I really don't think that's safe. ISTM the real problem is the assumption that only related triggers could share a tgname, which evidently isn't true. I think this query needs to actually match on tgparentid, rather than taking shortcuts. If we don't want to use a recursive CTE, maybe we could define it as only looking up to the immediate parent, rather than necessarily finding the root? regards, tom lane