I've implemented IMPORT FOREIGN SCHEMA support for an fdw called ogr_fdw against the PostgreSQL 9.5RC1 code base.
Code is here: https://github.com/robe2/pgsql-ogr-fdw It works great except in the Case of LIMIT TO clause (and possible EXCEPT though I have to retest EXCEPT to see if there is a case it doesn't work). In LIMIT case sometimes works and it sometimes doesn't and when it doesn't no foreign tables are created. Key bit starts here: https://github.com/robe2/pgsql-ogr-fdw/blob/master/ogr_fdw.c#L1389 When it doesn't work, no foreign tables are created, however when I inspect the out list coming from the function, I see the create foreign table statements And the right number as well but for some reason they never get executed. I thought perhaps that I have a memory leak somewhere, but then I discovered that if I take out my logic for LIMIT and EXCEPT handling, It still doesn't work. In the sense that I have a ton of create foreign table statements but none of them ever get run. -- ogr_all is a catchall schema just to say - don't bother checking schema. So I'm guessing there is some other filtering going on that I'm not aware of. Here is basic logic I have to exercise this behavior. I should note: the two laundering options I have in place are used to preserve or not preserve the table name and column names When not specified, the import tries to change the table and column names so that they don't require quoting when used in SQL. DROP SERVER IF EXISTS northwind CASCADE; CREATE SERVER northwind FOREIGN DATA WRAPPER ogr_fdw OPTIONS ( datasource 'C:/fdw_data/northwind.mdb', format 'ODBC' ); CREATE SCHEMA IF NOT EXISTS northwind; -- doesn't work - no tables created, but I see the two create table statements coming out of my import function IMPORT FOREIGN SCHEMA ogr_all LIMIT TO("Orders", "Products") FROM SERVER northwind INTO northwind OPTIONS(launder_table_names 'false', launder_column_names 'false'); -- works and I get the 2 tables created IMPORT FOREIGN SCHEMA ogr_all LIMIT TO("Orders", "Products") FROM SERVER northwind INTO northwind; If I use the EXCEPT clause, it works in both these cases and produces 24 tables (with these two missing) as expected. I tried exercising the same kind of issue with the postgres_fdw wrapper, but was not successful replicating the issue with that one. Thanks, Regina Obe -- Sent via pgsql-hackers mailing list (firstname.lastname@example.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers