Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r6ah1-001Wrc-Nt for pgsql-docs@arkaria.postgresql.org; Fri, 24 Nov 2023 18:14:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r6ah0-00DsT7-9m for pgsql-docs@arkaria.postgresql.org; Fri, 24 Nov 2023 18:14:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r6ah0-00DsSz-25 for pgsql-docs@lists.postgresql.org; Fri, 24 Nov 2023 18:14:18 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r6agx-008Kfq-9r for pgsql-docs@postgresql.org; Fri, 24 Nov 2023 18:14:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2023062407; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=dG9P+ZLGapif4Y0u5538pkS3ZxlpZnsLtr3nmvBLbt8=; b=dcUuT Dg9g9GxzVydP1btr+dQHDqBMkBKri9hjhWfBEstt47rHTvX+6+hpVJf9rH6oBQodVhXeaftqT6Wq/ b3grLfMgdCPIX+tvnNW1hX0nu+5Le6QPn1A1YIokX40R9kHyvoKMxKPkn4lGawhGzHm9Fcm1Cbhsi FrEjGusVL/Dw9DvUSEs/xmKuJZChu7eUztb3F7PuvyISu+VNsvQg9pROAcoWHbkF6SQLw8yJQ/m15 awoQy38IzbVptcdjVEesKYDZzoCUsEM8j+BvLW2O3vSyjrfdlZdvvPNiVwx9tPMvXM/0G2slz3XpI LBaEjbn0KOt/Uvi5Q6sRjAGWp9DJg==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1r6agt-0025NM-1L; Fri, 24 Nov 2023 13:14:11 -0500 Date: Fri, 24 Nov 2023 13:14:11 -0500 From: Bruce Momjian To: Laurenz Albe Cc: Peter Geoghegan , neil@fairwindsoft.com, PostgreSQL-documentation , Andres Freund , Heikki Linnakangas Subject: Re: [DOCS] Confusing Trigger Docs. Message-ID: References: <20170703200710.27956.64565@wrigleys.postgresql.org> <20170831132544.GC2355@momjian.us> <103ef5b01c801d372f8aa2353aecf4fc8364bd6c.camel@cybertec.at> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="LKtGBDZMoTW0ecJK" Content-Disposition: inline In-Reply-To: <103ef5b01c801d372f8aa2353aecf4fc8364bd6c.camel@cybertec.at> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --LKtGBDZMoTW0ecJK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Nov 23, 2023 at 08:36:34AM +0100, Laurenz Albe wrote: > On Wed, 2023-11-22 at 14:49 -0800, Peter Geoghegan wrote: > > I don't think that your proposed wording for this is an improvement. > > Well, the existing wording is impenetrable even for someone with some > PostgreSQL knowledge, like me. I moved the parition pagagraph to a more logical location and tried to clarify the new paragraph to be more targeted on the goal, patch attached. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you. --LKtGBDZMoTW0ecJK Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="excluded.diff" diff --git a/doc/src/sgml/trigger.sgml b/doc/src/sgml/trigger.sgml index 6e1f370b21..a5390ff644 100644 --- a/doc/src/sgml/trigger.sgml +++ b/doc/src/sgml/trigger.sgml @@ -132,29 +132,19 @@ - A statement that targets a parent table in an inheritance or partitioning - hierarchy does not cause the statement-level triggers of affected child - tables to be fired; only the parent table's statement-level triggers are - fired. However, row-level triggers of any affected child tables will be - fired. + If an INSERT contains an ON CONFLICT + DO UPDATE clause, it is possible for row-level + BEFORE INSERT and then + BEFORE UPDATE triggers + to be executed on triggered rows. Such interactions can be + complex if the triggers are not idempotent because change made by + BEFORE INSERT triggers will be + seen by BEFORE UPDATE triggers, + including changes to EXCLUDED columns. - If an INSERT contains an ON CONFLICT - DO UPDATE clause, it is possible that the effects of - row-level BEFORE INSERT triggers and - row-level BEFORE UPDATE triggers can - both be applied in a way that is apparent from the final state of - the updated row, if an EXCLUDED column is referenced. - There need not be an EXCLUDED column reference for - both sets of row-level BEFORE triggers to execute, - though. The - possibility of surprising outcomes should be considered when there - are both BEFORE INSERT and - BEFORE UPDATE row-level triggers - that change a row being inserted/updated (this can be - problematic even if the modifications are more or less equivalent, if - they're not also idempotent). Note that statement-level + Note that statement-level UPDATE triggers are executed when ON CONFLICT DO UPDATE is specified, regardless of whether or not any rows were affected by the UPDATE (and @@ -169,6 +159,14 @@ triggers. + + A statement that targets a parent table in an inheritance or partitioning + hierarchy does not cause the statement-level triggers of affected child + tables to be fired; only the parent table's statement-level triggers are + fired. However, row-level triggers of any affected child tables will be + fired. + + If an UPDATE on a partitioned table causes a row to move to another partition, it will be performed as a DELETE --LKtGBDZMoTW0ecJK--