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 1m4TaQ-0002Cd-8R for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Jul 2021 19:33:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m4TaP-0005VM-6o for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Jul 2021 19:33:25 +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 1m4TaO-0005VE-RJ for pgsql-hackers@lists.postgresql.org; Fri, 16 Jul 2021 19:33:24 +0000 Received: from mail-il1-x12e.google.com ([2607:f8b0:4864:20::12e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m4TaM-000389-Mo for pgsql-hackers@postgresql.org; Fri, 16 Jul 2021 19:33:24 +0000 Received: by mail-il1-x12e.google.com with SMTP id y6so9282614ilj.13 for ; Fri, 16 Jul 2021 12:33:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=e5nHcAivNqyOEJAA2Y+xLmGYxeQmwVAjgw3UJyJATqE=; b=r19NjPGjmvTtnbJ9vtvIpZDhBIMqT1FccZiyzct6OUIf6OaeipF3O4LVYQScB5Qf58 ef+2Cda+RS+yw/RhRKZ+ti3OZxaMdKpC48N0AeOiEIBD8bkpnzIr3A38VjPV0OA/74+7 zWY6mfuLykSQ6lorAXzolFs7Gz6oa+uccVrRoU/UJIKBBXNXeAiWzXTy16YJJ5dArB3n JtbBt1ElnzLnacg1+KkrTbSoKHHVRIhB2m0TZF3W/G/wAEYHdicCtTMH1gZ1gUAlZrVr dBT4tER/7hkSIvFbhIJ6kcj9EPRZtwftZtuCqr8KKe2Aje4KNuKIGMDx5FTE8vvSH7FZ Nq1w== 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=e5nHcAivNqyOEJAA2Y+xLmGYxeQmwVAjgw3UJyJATqE=; b=sQYpwTfLEc+B/tEZX/G+KLAzOd0H5zYqfEzugqnqga6nJvO08qLRoR3rlp1T4dtebo /69vMzLCmYlaEiXvzS1Fy2OAiicT47moetGRbDop7UxzlFMy1Hq8ycqLh6ybKqOFR+TZ NzXCgndwFTta2PFPoBSiunz8yMtxTBtj5LOgkTFTY+yvyvpWZ6yWqBMlUU2s2+5R1za1 KXW9Rfw8o4RYGx2LaCMOo1S+QPuzWkGZqDr9IENLuFZmzLmhWKJeTGhutkOT9hWJA2uM uxB6tNLfBkv580anFA66ghLU/YgQjG/eKHgnIUwCZbZWNVFBCGGCleglTOR1APAYq9kC RO3Q== X-Gm-Message-State: AOAM533dZ5dymuzchbwvsl9oGmqT2YMI/hi9XoKf9AUfVN1wgqR/mAOy eeTXO9rRVYFEjmFxG5/eDDQ8OQ== X-Google-Smtp-Source: ABdhPJx4Wn9lPFwpC1i568lKZ+tXLzjMMJGxVp78MwGsugj33mksVdgNU974wVhWmWaQP5CqxsnmqA== X-Received: by 2002:a92:ddc6:: with SMTP id d6mr7408790ilr.51.1626464001164; Fri, 16 Jul 2021 12:33:21 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id e14sm5249380ilq.32.2021.07.16.12.33.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Jul 2021 12:33:20 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id A9090800CCF; Fri, 16 Jul 2021 14:33:19 -0500 (CDT) Date: Fri, 16 Jul 2021 14:33:19 -0500 From: Justin Pryzby To: Tom Lane Cc: Alvaro Herrera , pgsql-hackers@postgresql.org, Amit Langote Subject: Re: CREATE TABLE .. PARTITION OF fails to preserve tgenabled for inherited row triggers Message-ID: <20210716193319.GS20208@telsasoft.com> References: <20201027174318.GM9241@telsasoft.com> <202107141802.5wzzuwqwodsx@alvherre.pgsql> <20210716181012.GR20208@telsasoft.com> <3746987.1626459326@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3746987.1626459326@sss.pgh.pa.us> 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 On Fri, Jul 16, 2021 at 02:15:26PM -0400, Tom Lane wrote: > Justin Pryzby writes: > > I think there's still an issue that comments on child triggers aren't > > preserved, right ? > > Do we care? That seems like messing with a system-internal object. > In general we won't promise to preserve the results of doing so. It's fine if that's the conclusion. Back in October, that seemed like one too many things misbehaving, which led me to walk away from the patch and re-orient. I was going re-check the behavior, but instead hit another bug: 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(); \d p1 2021-07-16 14:30:12.371 CDT client backend[6252] psql ERROR: more than one row returned by a subquery used as an expression 2021-07-16 14:30:12.371 CDT client backend[6252] psql STATEMENT: SELECT t.tgname, pg_catalog.pg_get_triggerdef(t.oid, true), t.tgenabled, t.tgisinternal, (SELECT (NULLIF(a.relid, t.tgrelid))::pg_catalog.regclass FROM pg_catalog.pg_trigger AS u, pg_catalog.pg_partition_ancestors(t.tgrelid) AS a WHERE u.tgname = t.tgname AND u.tgrelid = a.relid AND u.tgparentid = 0) AS parent FROM pg_catalog.pg_trigger t WHERE t.tgrelid = '37718' AND (NOT t.tgisinternal OR (t.tgisinternal AND t.tgenabled = 'D') OR EXISTS (SELECT 1 FROM pg_catalog.pg_depend WHERE objid = t.oid AND refclassid = 'pg_catalog.pg_trigger'::pg_catalog.regclass)) ORDER BY 1; ERROR: more than one row returned by a subquery used as an expression The tgenabled issue was a contributing factor which led us to stop using inherited triggers, so I'm not very motivated to dig into it. -- Justin