Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XjCjD-0007X3-6C for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Oct 2014 19:46:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XjCjC-0007Ma-DY for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Oct 2014 19:46:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XjCjB-0007MU-Pr for pgsql-bugs@postgresql.org; Tue, 28 Oct 2014 19:46:49 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XjCj8-0002u2-DI for pgsql-bugs@postgresql.org; Tue, 28 Oct 2014 19:46:48 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s9SJkbtH031110; Tue, 28 Oct 2014 15:46:37 -0400 From: Tom Lane To: djlu126@126.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #11804: The delete rule problem In-reply-to: <20141027062943.2615.76034@wrigleys.postgresql.org> References: <20141027062943.2615.76034@wrigleys.postgresql.org> Comments: In-reply-to djlu126@126.com message dated "Mon, 27 Oct 2014 06:29:43 -0000" Date: Tue, 28 Oct 2014 15:46:37 -0400 Message-ID: <31109.1414525597@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org djlu126@126.com writes: > [ complicated example ] It's pretty much a crapshoot what you're going to get out of that details_d1 rule, because it specifies multiple updates to the same row of the "stock" table anytime multiple "details" rows with the same "prd_id" are deleted. That's allowed but only one of the update actions will take, and it's unspecified which one. (There's been some talk of making such cases throw an error instead, but that wouldn't lead to a working solution for you either.) You'd be *way* better off building this behavior with a trigger, both as to efficiency and understandability. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs