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 1sYu8A-00ExlY-LJ for pgsql-general@arkaria.postgresql.org; Tue, 30 Jul 2024 21:11:38 +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 1sYu89-00DhlI-11 for pgsql-general@arkaria.postgresql.org; Tue, 30 Jul 2024 21:11:37 +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 1sYu87-00Dhkh-Qk for pgsql-general@lists.postgresql.org; Tue, 30 Jul 2024 21:11:36 +0000 Received: from fout6-smtp.messagingengine.com ([103.168.172.149]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sYu84-002Jo4-5x for pgsql-general@lists.postgresql.org; Tue, 30 Jul 2024 21:11:35 +0000 Received: from compute8.internal (compute8.nyi.internal [10.202.2.227]) by mailfout.nyi.internal (Postfix) with ESMTP id D16341380145; Tue, 30 Jul 2024 17:11:30 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute8.internal (MEProxy); Tue, 30 Jul 2024 17:11:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1722373890; x=1722460290; bh=FCjksVold/4nnO/CoQ8uD1V3jb2TtuNtTOQBhV73V4o=; b= GBguCYtdOzudsYPWo206cv65OHa0l0Sl0qP8gjmPgEFPgF9UlaY9o8hvX8+TtDz0 D0msgZVPCY9D8CdVqEyHijVWCMVRFFL8pEc6zo06z+46d48zRreBwRRzFiD5bmjT sS+sGyiXilO+t9NnoQAU6mi/ilwFi1RLlhXd1kwgyfmUplsUKvrTUd+vUTjcUvbz IaeZPvs94Cljeoy+0yCxpKPXkEkd2j3RUmwVHYZ9pXfWAlRz07Jjx4KAoQa/IE6w ExxUMRAV/MKjtosifq8OOyy+ixWiwDXAMOFHNpgwtjvNmRStfS88blofLYUANfuJ +hTky+Qy0sNR7B9PiVRm9g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1722373890; x= 1722460290; bh=FCjksVold/4nnO/CoQ8uD1V3jb2TtuNtTOQBhV73V4o=; b=W 2csE3vbIid1rgh3TQD/paNG6fuxUOKGAvwO7Q1emll3jHc1D4GwGKCoYalzW6Cg0 n7v2Qx/ES0JuI5D59lKnQ1XXZsPEfzCgZmGYenDnbtz+pWqQDJU3FDOs8AssIU7M 2em0PxfFtijMEwvXeuN8qi0V8WCEBJMoTnCWbr7YfIk3s9rRvir3hsPfTGLLx4zx 2BPioOEm3tYGcbNd2s9bCoZ18wyKh5JOmOzPYR7qUfAuQGmYjdU7l6buB+JqvkV9 +aPHvKzN1RCOjtS14sv5YwprpmKFxmfjm9JomTqWyqu7xPtw2ujk0wz65Wq45REr pxAuE0iwwF1/30X7UY8MA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrjeeggdduheelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuggftrfgrthhtvghrnhepfeegfeeiuedtgffgteeggfehkeejheetieeliefg teeikeejvdeiveeigfehvedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdp nhgspghrtghpthhtoheptd X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 30 Jul 2024 17:11:29 -0400 (EDT) Message-ID: Date: Tue, 30 Jul 2024 14:11:28 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Trigger usecase To: "David G. Johnston" , sud Cc: Laurenz Albe , pgsql-general References: <85cc2eb0ca709ab753e618584f46dbf8801e9658.camel@cybertec.at> Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/30/24 13:28, David G. Johnston wrote: > On Tue, Jul 30, 2024 at 11:46 AM sud > wrote: > > > Not sure of the exact pros and cons, but we were following certain > rules like , if it's business logic which needs to be implemented in > Database, then it should not be done using triggers but rather > should be done through database procedure/functions. Hope this > understanding correct. > > > That is my personal take.  For process-oriented stuff you can follow the > trail of calls all the way through to the end of the process and its > final result.  With triggers you follow the trail to the > insert/update/delete then stop thinking that's it, while in reality it > continues because you have triggers performing yet more work. > "On insert/update/delete to this table the following actions are taken via triggers using the supplied function/procedure: Insert Data is sent to audit table using table_audit() Update Data is sent to audit table using table_audit() Delete Data is sent to audit table using table_audit() See function specific documentation below [...] " > David J. > -- Adrian Klaver adrian.klaver@aklaver.com