On Thu, Mar 9, 2017 at 11:15 PM, Stephen Frost <sfr...@snowman.net> wrote: > While reviewing Amit Langote's patch to handle partitioned tables > properly in various contrib modules (mostly by throwing an error since > things like pageinspect aren't going to work on the empty 'parent' > table), I went looking through contrib for other modules that do > something with relkind and noticed that postgres_fdw's IMPORT SCHEMA > would pull in the child tables (relkind = 'r') but would ignore the > parent table (relkind = 'P', or soon to be 'p', I guess).
It is not as straight-forward as it seems. A foreign table can be defined as a child (use of PARTITION OF), but not as a parent (use PARTITION BY), and IMPORT SCHEMA has to issue queries to create foreign tables. It seems to me that the correct fix here is to ignore child tables that are part of a partition, and just include the parent in what is imported so as when querying the parent through postgres_fdw all the child partitions are considered automatically. Thoughts? Of course this should be documented. > I tend to view this as an issue which should be added to the open items > list and resolved before PG10 (though perhaps it could be done after > feature freeze), but I could see an argument that it should be just a > documented limitation of postgres_fdw and that adding such support would > be a new feature. Agreed. I think that this is a bug, because any database having one partitioning set of tables would fail to import automatically except by excluding some tables, and that's annoying for the user. > In any case, this seems like an issue that should be addressed one way > or the other, so I'll add it to the open items list. I'm not planning > to work on fixing it myself, but if someone proposes a patch which looks > reasonable, I'll try to find time for it. Well, I worked on IMPORT SCHEMA, so I'm fine to do something. After the CF is done though. -- Michael -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers