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 1jR1w3-0007fR-Sn for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Apr 2020 23:04:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jR1vX-0002I7-2m for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Apr 2020 23:03:39 +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 1jR1vW-0002Hz-P9 for pgsql-hackers@lists.postgresql.org; Tue, 21 Apr 2020 23:03:38 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jR1vS-0001T5-UG for pgsql-hackers@lists.postgresql.org; Tue, 21 Apr 2020 23:03:37 +0000 Received: by mail-qt1-x841.google.com with SMTP id 92so217413qtg.0 for ; Tue, 21 Apr 2020 16:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=iKXhQ/6B95iLfHnbAN912mg+B47NcMfOIwW4SWkwS5Q=; b=Ft4KQYDLZkzAFFtxretoLMqy+JYhPm39jcPWpa+5F0YPtTTAaljF7vv1lrQmV6LlYY Xs0k2WSulJCWFi00elZjF806LxAFR02lTpe73tY6xiEB6ysWHaR+7avenIa3RKgA4KEl ZQ1W4WMcsaWV6pJQXl6MWQFcxqh2dcYQUlPEqab5tb29mf2ZkyJCD7YHq4L+IAIAqV4l f2P6+5f7YPldzWYCTcfUC0qq28tSeSn1cM5p/tTpvB0aMO8tr+bXQ1+KGnAjVbDOjfZO H4ywalcPeWlBW7nQ54+djlGKIFF8GQ1MF4O2SZn9pJy+0B0+9sWXgv2QPvQu5U7OXIRD gxvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=iKXhQ/6B95iLfHnbAN912mg+B47NcMfOIwW4SWkwS5Q=; b=fnrF1fYb88NIX7x781RZY7lPH5iy6MLH+jxbklwhcBxIM+RaenYILGzoLfkFLJ0mwv t8/zNcmpDAk4mePoemsvfQ2GNjgPwOeY4qoB9zJZtHMTZpoLJMijkxxRFPTYmroaiHGE BxObyD/NnT8ng3Jlw5kQoU74Usq9OSkmjrw5/0jiW+poZUEEE6urbMf0NoCvCkfTBg4g Bra+ucHPvIqT7pbyGVukGRQiMjp1UwiHc9QlsNquKABnuJmnHcHRgrjiv0E4D1hqpNsO AICjkgSaHKENhiUtuOZi/0eS5qh5ccy4pkPwWrSluGvT93T4ZoDyvOhTBC0kjd1IRl6P r23g== X-Gm-Message-State: AGi0Puax/iZh2AoXGSJGRr8aSnCbhr6kOJ/oAoz+8cQflrpujApJg104 SED6iPNJBkZ+Vv87DrL5UX9I4w== X-Google-Smtp-Source: APiQypK3XFLHsQdAziTifYV2WT1sKsUch2dQ1l2f4C7/TEDrvZsZVkquFiuzlbJkOoS74caMnnoOzA== X-Received: by 2002:ac8:6c24:: with SMTP id k4mr23436713qtu.257.1587510213131; Tue, 21 Apr 2020 16:03:33 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.95.18.252]) by smtp.gmail.com with ESMTPSA id x125sm2806642qke.34.2020.04.21.16.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 16:03:32 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 686DD3007EB; Tue, 21 Apr 2020 19:03:30 -0400 (-04) Date: Tue, 21 Apr 2020 19:03:30 -0400 From: Alvaro Herrera To: Justin Pryzby Cc: Amit Langote , Tom Lane , PostgreSQL Hackers Subject: Re: DETACH PARTITION and FOR EACH ROW triggers on partitioned tables Message-ID: <20200421230330.GA23831@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200420195740.GE3890@telsasoft.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Apr-20, Justin Pryzby wrote: > On Mon, Apr 20, 2020 at 06:35:44PM +0900, Amit Langote wrote: > > Also, how about, for consistency, making the parent table labeling of > > the trigger look similar to that for the foreign constraint, so > > Triggers: > > TABLE "f1" TRIGGER "trig" BEFORE INSERT ON f11 FOR EACH ROW EXECUTE FUNCTION trigfunc() > > I'll leave that for committer to decide. Pushed. Many thanks for this! Changes: I thought that printing the "ON TABLE" bit when it's defined in the same table is pointless and ugly, so I added a NULLIF to prevent it in that case (it's not every day that you can put NULLIF to work). I also changed the empty string to NULL for the case with older servers, so that it doesn't print a lame "ON TABLE " clause for them. Lastly, added pg_catalog qualifications everywhere needed. Contrary to what I had said, I decided to leave the output as submitted; the constraint lines are not really precedent against it: 55432 13devel 24286=# \d lev3 Partitioned table "public.lev3" Column │ Type │ Collation │ Nullable │ Default ────────┼─────────┼───────────┼──────────┼───────── a │ integer │ │ not null │ Partition of: lev2 FOR VALUES IN (3) Partition key: LIST (a) Indexes: "lev3_pkey" PRIMARY KEY, btree (a) Foreign-key constraints: TABLE "lev1" CONSTRAINT "lev1_a_fkey" FOREIGN KEY (a) REFERENCES lev1(a) Referenced by: TABLE "lev1" CONSTRAINT "lev1_a_fkey" FOREIGN KEY (a) REFERENCES lev1(a) Triggers: tt AFTER UPDATE ON lev3 FOR EACH ROW EXECUTE FUNCTION trigger_nothing(), ON TABLE lev2 Number of partitions: 1 (Use \d+ to list them.) In the "FK constraints" and "referenced by" entries, it looks natural since the constraint refers to a table. Not so in the trigger case. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services