Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W5QRR-0001VG-0G for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Jan 2014 01:47:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W5QRP-0006Jo-Nt for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Jan 2014 01:47:47 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W5QRO-0006Jg-9s for pgsql-hackers@postgresql.org; Tue, 21 Jan 2014 01:47:46 +0000 Received: from tyo202.gate.nec.co.jp ([202.32.8.206]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W5QRK-000326-QJ for pgsql-hackers@postgresql.org; Tue, 21 Jan 2014 01:47:44 +0000 Received: from mailgate3.nec.co.jp ([10.7.69.160]) by tyo202.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id s0L1ldIU011499; Tue, 21 Jan 2014 10:47:39 +0900 (JST) Received: from mailsv.nec.co.jp (imss63.nec.co.jp [10.7.69.158]) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) with ESMTP id s0L1ldZ01465; Tue, 21 Jan 2014 10:47:39 +0900 (JST) Received: from mail03.kamome.nec.co.jp (mail03.kamome.nec.co.jp [10.25.43.7]) by mailsv.nec.co.jp (8.13.8/8.13.4) with ESMTP id s0L1lcHf008305; Tue, 21 Jan 2014 10:47:38 +0900 (JST) Received: from genzui.jp.nec.com ([10.26.220.13] [10.26.220.13]) by mail02.kamome.nec.co.jp with ESMTP id BT-MMP-73824; Tue, 21 Jan 2014 10:42:09 +0900 Received: from [10.164.24.200] ([10.164.24.200] [10.164.24.200]) by mail.jp.nec.com with ESMTPA id BT-MMP-9504; Tue, 21 Jan 2014 10:42:09 +0900 Message-ID: <52DDD071.9090405@ak.jp.nec.com> Date: Tue, 21 Jan 2014 10:42:09 +0900 From: KaiGai Kohei User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: Shigeru Hanada , Tom Lane CC: Robert Haas , PostgreSQL-development Subject: Re: inherit support for foreign tables References: <12432.1384406906@sss.pgh.pa.us> <10163.1384786524@sss.pgh.pa.us> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -4.2 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org (2014/01/14 18:24), Shigeru Hanada wrote: > 2013/11/18 Tom Lane : >> Robert Haas writes: >>> I think it's been previously proposed that we have some version of a >>> CHECK constraint that effectively acts as an assertion for query >>> optimization purposes, but isn't actually enforced by the system. I >>> can see that being useful in a variety of situations, including this >>> one. >> >> Yeah, I think it would be much smarter to provide a different syntax >> to explicitly represent the notion that we're only assuming the condition >> is true, and not trying to enforce it. > > I'd like to revisit this feature. > > Explicit notation to represent not-enforcing (assertive?) is an > interesting idea. I'm not sure which word is appropriate, but for > example, let's use the word ASSERTIVE as a new constraint attribute. > > CREATE TABLE parent ( > id int NOT NULL, > group int NOT NULL, > name text > ); > > CREATE FOREIGN TABLE child_grp1 ( > /* no additional column */ > ) INHERITS (parent) SERVER server1; > ALTER TABLE child_grp1 ADD CONSTRAINT chk_group1 CHECK (group = 1) ASSERTIVE; > > If ASSERTIVE is specified, it's not guaranteed that the constraint is > enforced completely, so it should be treated as a hint for planner. > As Robert mentioned, enforcing as much as we can during INSERT/UPDATE > is one option about this issue. > > In addition, an idea which I can't throw away is to assume that all > constraints defined on foreign tables as ASSERTIVE. Foreign tables > potentially have dangers to have "wrong" data by updating source data > not through foreign tables. This is not specific to an FDW, so IMO > constraints defined on foreign tables are basically ASSERTIVE. Of > course PG can try to maintain data correct, but always somebody might > break it. > qu > Does it make sense to apply "assertive" CHECK constraint on the qual of ForeignScan to filter out tuples with violated values at the local side, as if row-level security feature doing. It enables to handle a situation that planner expects only "clean" tuples are returned but FDW driver is unavailable to anomalies. Probably, this additional check can be turned on/off on the fly, if FDW driver has a way to inform the core system its capability, like FDW_CAN_ENFORCE_CHECK_CONSTRAINT that informs planner to skip local checks. > Besides CHECK constraints, currently NOT NULL constraints are > virtually ASSERTIVE (not enforcing). Should it also be noted > explicitly? > Backward compatibility.... NOT NULL [ASSERTIVE] might be an option. Thanks, -- OSS Promotion Center / The PG-Strom Project KaiGai Kohei -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers