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 1jQGhu-0007NM-T5 for pgsql-hackers@arkaria.postgresql.org; Sun, 19 Apr 2020 20:38: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 1jQGht-0000mG-OO for pgsql-hackers@arkaria.postgresql.org; Sun, 19 Apr 2020 20:38: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 1jQGht-0000m9-DZ for pgsql-hackers@lists.postgresql.org; Sun, 19 Apr 2020 20:38:25 +0000 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jQGhq-00055G-2V for pgsql-hackers@lists.postgresql.org; Sun, 19 Apr 2020 20:38:24 +0000 Received: by mail-qk1-x741.google.com with SMTP id l25so8552027qkk.3 for ; Sun, 19 Apr 2020 13:38:21 -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=TOnA9gjfas3llTP8Tq3HCF3oMvgRpxOY10cEZIS+DeE=; b=qOxTMSIGA9tUmDQG4ihkgNUtL3rKThXXPRDrjywqPLu3lHxSm39VFwdxg1usPx/Nmi dLpamlMv9yKbxagHRAP6DD0Jb1wEU5CoWQ+KZ6lOurNPqlGe0L9Zg7j8NzwYYRVOsVow Xv0ZxrlduSjZn+ovsuTepIvVZhuEcZqsGcPKkSWDHOlfypdUtPNZ6IhDxfzBUJFT/iSm lx+q6Dk52YgnNoZZdDsgxftSiNfJ16kSvy/x5MevJcYrdBRlYrtYhQWktswN+lBmiTy9 YGyo1Toe6uDstTcGeft8DGqi2CCME31h/r2s87G7XyXkaMR8KJJWNt+7lCO+MGlS3INR G/DA== 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=TOnA9gjfas3llTP8Tq3HCF3oMvgRpxOY10cEZIS+DeE=; b=CN2YYhS9XJDaWGzEYEDP738axN+ht+XDcKsV/Nr4Xe/rwq2XZ0rYxHpfmhGTE/ctLw OzekuqtprazqtKfsgpzWyjTkbS4qs0riyzq9fD0ZQYN4mu/FXA3NMBL/1Kemg4kEz2dE zXuyNWZIMUclxnyl0dWrhpOBqLOdJZsMFJBQ9YWJQfTanWFIOSnBdMJzKS/n0xMVsZVi S1/a0FQAjffXowR2vQp9aXeKpyU2kk2lLT5QXSfis6uVPu+ZNsJi36o+puTrw1uySjCU le5AGd6iTW25B5HxwUFqXvxvdWjIeOqGre3YzEyNQQp4grCSPaKzomhbvPQjOlaZzFAZ dVAQ== X-Gm-Message-State: AGi0PuZ/m3wMTPDSvz9RgLcpP/Lqo0qbC2xEPsMAOpxQ82vF0emSlWo8 2OYclh5Uy0X9Cm18Ei1Fjv3lOBI4o3EWfNpIpYhQlGwdhxYyh2MxAU9E70ISsuxMJq2CWbicpWd s0VRN76bt+2HUoTa8jiQuWMvO5RQvZfQQO7EKDXaCFUINOdw4oRjw07soWb6Inlk0UYXMxhBHFH GDRGQ1uY8h0hQlSDv1 X-Google-Smtp-Source: APiQypI2mpmYh+Ai/W8ULeVoY3Tmot7Cb+Jiq3WWN+SRT+t5qFJynJ7D9dLIYGyccyIw+4JkjG5RrQ== X-Received: by 2002:a37:9c9:: with SMTP id 192mr13329277qkj.149.1587328698875; Sun, 19 Apr 2020 13:38:18 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.95.18.252]) by smtp.gmail.com with ESMTPSA id w79sm10399527qkb.97.2020.04.19.13.38.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 13:38:18 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 05BA3301604; Sun, 19 Apr 2020 16:38:15 -0400 (-04) Date: Sun, 19 Apr 2020 16:38:15 -0400 From: Alvaro Herrera To: Justin Pryzby Cc: pgsql-hackers@lists.postgresql.org Subject: Re: DETACH PARTITION and FOR EACH ROW triggers on partitioned tables Message-ID: <20200419203815.GA825@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200419191854.GA14956@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-19, Justin Pryzby wrote: > It's probably rare that we'd be inserting into a table old enough to be > detached, and normally that would be ok, but if a trigger were missing, it > would misbehave. In our use-case, we're creating trigger on the parent as a > convenient way to maintain them on the partitions, which doesn't work if a > table exists but detached.. > > So we'd actually prefer the behavior of indexes/constraints, where the trigger > is preserved if the child is detached. I'm not requesting to do that just for > our use case, which may be atypical or not a good model, but adding our one > data point. I think the easiest way to implement this is to have two triggers -- the one that's direct in the partition checks whether the table is a partition and does nothing in that case. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services