inherit support for foreign tables - Mailing list pgsql-hackers

From Shigeru Hanada
Subject inherit support for foreign tables
Date
Msg-id CAEZqfEfVJNptoTSEY3QrQ90K9WD2nxfM+6fsk3YTc1ZXZ1Y5-g@mail.gmail.com
Whole thread Raw
Responses Re: inherit support for foreign tables  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi hackers,

I'd like to propose adding inheritance support for foriegn tables.
David Fetter mentioned this feature last July, but it seems stalled.

    http://www.postgresql.org/message-id/20130719005601.GA5760@fetter.org

Supporting inheritance by foreign tables allows us to distribute query
to remote servers by using foreign tables as partition table of a
(perhaps ordinary) table.  For this purpose, I think that constraint
exclusion is necessary.

As result of extending Devid's patch for PoC, and AFAIS we need these changes:

1) Add INHERITS(rel, ...) clause to CREATE/ALTER FOREIGN TABLE
Apperantly we need to add new syntax to define parent table(s) of a
foreign table.  We have options about the position of INHERIT clause,
but I'd prefer before SERVER clause because having options specific to
foreign tables at the tail would be most extensible.

    a) CREATE FOREIGN TABLE child (...) INHERITS(p1, p2) SERVER server;
    b) CREATE FOREIGN TABLE child (...) SERVER server INHERITS(p1, p2);

2) Allow foreign tables to have CHECK constraints
Like NOT NULL, I think we don't need to enforce the check duroing
INSERT/UPDATE against foreign table.

3) Allow foreign table as a child node of Append
Currently prepunion.c assumes that children of Append have
RELKIND_RELATION as relkind always, so we need to set relkind of child
RTE explicitly.

Please see attached PoC patch.  I'll enhance implementation, tests and
document and submit the patch for the next CF.

Regards,
--
Shigeru HANADA

Attachment

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Assertions in PL/PgSQL
Next
From: Tom Lane
Date:
Subject: Re: inherit support for foreign tables