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 1myFOu-00087r-Hi for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Dec 2021 15:44:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1myFOt-0002G7-G8 for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Dec 2021 15:44:03 +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 1myFOs-0002Fu-W6 for pgsql-hackers@lists.postgresql.org; Fri, 17 Dec 2021 15:44:03 +0000 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1myFOp-00089N-H8 for pgsql-hackers@postgresql.org; Fri, 17 Dec 2021 15:44:02 +0000 Received: by mail-il1-x135.google.com with SMTP id d14so1965175ila.1 for ; Fri, 17 Dec 2021 07:43:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=ytYfcxA4Yb+zghGISMmOFyHz0X2xpsoUGQM8Y4bf6Nk=; b=E+1akUfwieDPiOnl9WcGPolsVHSwK0/i5G+C16H38c2lUQnPInxj3NZWPC0kREz4mF f+vgBgzM4w7SKK088l8lUBADn0kS6sc65wOi5KNPitTOpj7x4Go1KLio6L/VlweeH8WJ J94Q8K6EleVNYRcV6Xq818uxyM+b3AKc9E/Ie1NuzqOgHRqFhPUQ++pc7mjuMgQ2fMgh 2K0JRfo4m/SMGoAjilRamjY4//8BucG8WRJO2YHZf5e9EtBVAQLONXLZFg2O1w9CBYZM o15zqt62kYlV2SpPyPkzf04WZwCGiCnivck2WBkGk2B+1N2bm66H9wKZLhXq/IG2FztE M8Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=ytYfcxA4Yb+zghGISMmOFyHz0X2xpsoUGQM8Y4bf6Nk=; b=KZU7ICFAsQYPLRjQJEUQNYoTjjRE1mbwX9WxoCcxZQJhtulbDejwTrPPTiikK5MXTp lLTMSZK55DbRKU0LAZ7pdw6tvwOmdHg53zoEFB4Nmz9vsDzKtyBW4C6QJdEgLIkTLsmS RKsrhRND6+7IhzqevFr0TacSFsdRFdEAC6hYdr37i8IzmSd5C9SeMEeIssrlHGLOXXeG 1FjQ0Za4UB3fjkACUHzv+Iztmd+iaW9g68UkhC5soLinxtheaFzfDSsnSnIRk1DiZKP1 TQgrbRldG3kYKprPItsBqHSlGeJuurR/qmmQtYhGyba+NxMMD6AZ3A+NmHflOZKc1qp9 5m6Q== X-Gm-Message-State: AOAM533obkr1HKZkACbs9HhzMbA/MyL5ss1J6jDMc1Q1G7Eg3CY2qdDN PYh+iH/KXDFV+P6Ke5tjwGMOTA== X-Google-Smtp-Source: ABdhPJwg0Ja+7bOnursUCoxb9UJsZ460P8NpB+xyt4z4N0Qc810/T04HrqnaAUMnp5wP7WeUi9bgRA== X-Received: by 2002:a05:6e02:1be6:: with SMTP id y6mr1856874ilv.139.1639755837679; Fri, 17 Dec 2021 07:43:57 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id x7sm4470722ilq.86.2021.12.17.07.43.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Dec 2021 07:43:57 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 92F17800827; Fri, 17 Dec 2021 09:43:56 -0600 (CST) Date: Fri, 17 Dec 2021 09:43:56 -0600 From: Justin Pryzby To: Alvaro Herrera Cc: Tom Lane , pgsql-hackers@postgresql.org, Amit Langote Subject: \d with triggers: more than one row returned by a subquery used as an expression Message-ID: <20211217154356.GJ17618@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. On Fri, Jul 16, 2021 at 08:02:59PM -0500, Justin Pryzby wrote: > On Fri, Jul 16, 2021 at 06:01:12PM -0400, Alvaro Herrera wrote: > > On 2021-Jul-16, Justin Pryzby wrote: > > > CREATE TABLE p(i int) PARTITION BY RANGE(i); > > > CREATE TABLE p1 PARTITION OF p FOR VALUES FROM (1)TO(2); > > > CREATE FUNCTION foo() returns trigger LANGUAGE plpgsql AS $$begin end$$; > > > CREATE TRIGGER x AFTER DELETE ON p1 EXECUTE FUNCTION foo(); > > > CREATE TRIGGER x AFTER DELETE ON p EXECUTE FUNCTION foo(); > > > > Hmm, interesting -- those statement triggers are not cloned, so what is > > going on here is just that the psql query to show them is tripping on > > its shoelaces ... I'll try to find a fix. > > > > I *think* the problem is that the query matches triggers by name and > > parent/child relationship; we're missing to ignore triggers by tgtype. > > It's not great design that tgtype is a bitmask of unrelated flags ... > > I see it's the subquery Amit wrote and proposed here: > https://www.postgresql.org/message-id/CA+HiwqEiMe0tCOoPOwjQrdH5fxnZccMR7oeW=f9FmgszJQbgFg@mail.gmail.com > > .. and I realize that I've accidentally succeeded in breaking what I first > attempted to break 15 months ago: > > On Mon, Apr 20, 2020 at 02:57:40PM -0500, Justin Pryzby wrote: > > I'm happy to see that this doesn't require a recursive cte, at least. > > I was trying to think how to break it by returning multiple results or results > > out of order, but I think that can't happen. > > If you assume that pg_partition_ancestors returns its results in order, I think > you can fix it by adding LIMIT 1. Otherwise I think you need a recursive CTE, > as I'd feared. > > Note also that I'd sent a patch to add newlines, to make psql -E look pretty. > v6-0001-fixups-c33869cc3bfc42bce822251f2fa1a2a346f86cc5.patch