X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7450FD1CAF0 for ; Wed, 1 Oct 2003 03:23:30 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 18778-10 for ; Wed, 1 Oct 2003 00:22:43 -0300 (ADT) Received: from www.postgresql.com (unknown [64.117.225.209]) by svr1.postgresql.org (Postfix) with ESMTP id B6827D1CC3D for ; Tue, 30 Sep 2003 23:22:14 -0300 (ADT) Received: from svr4.postgresql.org (svr4.postgresql.org [64.117.224.192]) by www.postgresql.com (Postfix) with ESMTP id 354C6CF7251 for ; Tue, 30 Sep 2003 15:46:53 -0300 (ADT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr4.postgresql.org (Postfix) with ESMTP id 6EE711CB4761 for ; Tue, 30 Sep 2003 15:33:40 +0000 (GMT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id BD50735321; Tue, 30 Sep 2003 08:29:54 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id BB76535320; Tue, 30 Sep 2003 08:29:54 -0700 (PDT) Date: Tue, 30 Sep 2003 08:29:54 -0700 (PDT) From: Stephan Szabo To: Tom Lane Cc: Bruce Momjian , Jan Wieck , Christopher Kings-Lynne , Peter Childs , PostgreSQL-development Subject: Re: ADD FOREIGN KEY (was Re: [GENERAL] 7.4Beta) In-Reply-To: <19584.1064934958@sss.pgh.pa.us> Message-ID: <20030930082522.L15622@megazone.bigpanda.com> References: <200309301233.h8UCXcQ21796@candle.pha.pa.us> <19140.1064930871@sss.pgh.pa.us> <20030930074408.H14474@megazone.bigpanda.com> <19584.1064934958@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/13 X-Sequence-Number: 44695 On Tue, 30 Sep 2003, Tom Lane wrote: > Stephan Szabo writes: > > As a side note, in the partial implementation I'd already done, I noticed > > a potential problem if the person doing the alter table didn't have read > > permissions on the pktable. I'd written it to bail and do the slow check > > in that case (well actually in most error cases that didn't themselves > > cause an elog), does anyone have a better idea? > > Wouldn't all the subsequent triggers fail also in such a case? (For > that matter, wouldn't the existing implementation of the initial check > fail?) I can't see a reason to expend code to avoid failing here. It's No, because the triggers change permissions to the owner of the appropriate (either fk or pk) table before running the query, so the old method works as well as the final constraint would. However, if the two owners are not the same, you can't set to both during the single query. > not very sensible to be able to create an FK on a table you don't have > read permission for. IIRC, you only need references permissions to make an fk constraint, not select.