Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f9XIS-0007yr-22 for pgsql-general@arkaria.postgresql.org; Fri, 20 Apr 2018 14:45:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f9XIP-0006dI-Dy for pgsql-general@arkaria.postgresql.org; Fri, 20 Apr 2018 14:45:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f9XIP-0006cj-30 for pgsql-general@lists.postgresql.org; Fri, 20 Apr 2018 14:45:53 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f9XHr-0002ON-8t for pgsql-general@postgresql.org; Fri, 20 Apr 2018 14:45:51 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id B3DED21DE2; Fri, 20 Apr 2018 10:45:17 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 20 Apr 2018 10:45:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=L5njOeGtvxDvk5K6A4Z8+9gavm4cP yG16b9vokodflA=; b=PcDkiHNX5xvb34vbp1UDBSogQA6fcn0eODhtTpD/W5SQv FByMc+rg1DHLDH2/+cZdpBpD+zKqL9Z9Bcc6oe/m2Nbi+mSFUJ7aSP7y3oKs076A Hz8odalIl4yTj5MWwG/Q2Y1kalb3d5luTwL1S1ss2qiug4HDBurdGLiyVuKbxEkX dksG7hcVSLc3OjljW4ftDvqzYTxlhP5DI0AHeYQmeIzZRIa1MPbZQ440Dznf+rDK IZQwjyXfIZ63b1q5f6KEtTIEZtGKTSaMZ9CK8A2uZm8FewsXgplhtwT7jOQL00yV JvGRnwcHrEbAECXceytpXB9+481Ly4EHBsnHURjXw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=L5njOe GtvxDvk5K6A4Z8+9gavm4cPyG16b9vokodflA=; b=PCpSNCj9LiKaHlFE/wgAzd ZSyYzTo5PcIVTu2wXuU5c+5N6jr5NQdzgCs4GtcYl9sry9tId0IukDvmg6h+wVPe 0KxFej15QXogCyUnF3kMBjLDnxHff2x6/xPuKypcgM9x6XwejLZCLfYdmvmwVj4P p5PHW8yMR8kGVE4PAhtD2nQFQYAk0Twon/7ycEnsOTWnvgcsB6cnuMzlEOkithyT sERAxKVXT2IEJgygTOgcyQ+5zkelKheW7v5B8WhlemDYXTOrwRf4eDwcfCHkQ29S a6vUBtx5EfaYNyIlVxEY132bjxtq6fVm7yIZzXm1UWK3UUJ33bxpxWE0IfEevxKg == X-ME-Sender: Received: from ranger.suse (unknown [74.94.73.222]) by mail.messagingengine.com (Postfix) with ESMTPA id 7B9D2E50A3; Fri, 20 Apr 2018 10:45:16 -0400 (EDT) Subject: Re: Problem with trigger makes Detail record be invalid To: "David G. Johnston" Cc: PegoraroF10 , pgsql-general References: <1524160534707-0.post@n3.nabble.com> <7cb5806e-7371-5c19-1c7b-b8ac556bdfb5@aklaver.com> <24449.1524164237@sss.pgh.pa.us> <2795.1524165702@sss.pgh.pa.us> <1524188994110-0.post@n3.nabble.com> <4f528d7d-90d0-55d1-f017-b72d730080db@aklaver.com> From: Adrian Klaver Message-ID: <6b96b2ad-4c89-cf11-8dcd-78ec7300d36c@aklaver.com> Date: Fri, 20 Apr 2018 07:45:15 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 04/20/2018 07:21 AM, David G. Johnston wrote: > On 04/19/2018 06:49 PM, PegoraroF10 wrote: > On Fri, Apr 20, 2018 at 6:55 AM, Adrian Klaver > >wrote: > > I know I did that trigger incorrectly but referential integrity is > obligatory. > > > I would agree if the FK relationship was entirely driven by the > system trigger e.g: > > alter table Detail add constraint FKMasterDetail foreign key (Master_ID) > references Master(ID) on update cascade on delete cascade; > > As soon as you added your UPDATE/DELETE trigger you took on > responsibility for how the data was passed around. > > > Such responsibility is an artifact of our specific implementation and > not an inherent property of writing triggers in the presence of FK > constraints. https://en.wikipedia.org/wiki/Foreign_key#Triggers > > We've left a foot-gun laying around and should not be surprised when > less experienced users pick it up and shoot themselves in the foot. > > IOW, I do agree with the OP - its just an unfortunate reality that this > isn't how things work today.  Whether one can accept and work within > this reality is a personal decision. > > This does reinforce that testing the restoration of ones backups is > important. > > David J. > -- Adrian Klaver adrian.klaver@aklaver.com