Search code examples
postgresqldatabase-partitioningforeign-data-wrapperpostgres-fdw

Postgres 11 FDW can't find partitioned table


Trying to access a partitioned table using postgres 11 foreign data wrapper. I can access the underlying tables but not the table.

create schema foo;

CREATE TABLE foo.test1 (
    city_id         int not null,
    logdate         date not null,
    peaktemp        int,
    unitsales       int
) PARTITION BY RANGE (logdate);

CREATE TABLE foo.measurement1_y2006m02 PARTITION OF foo.test1
    FOR VALUES FROM ('2006-02-01') TO ('2006-03-01');

CREATE TABLE foo.measurement1_y2006m03 PARTITION OF foo.test1
    FOR VALUES FROM ('2006-03-01') TO ('2006-04-01');

insert into foo.measurement1_y2006m02 values (1,'2006-02-15',1,1);
insert into foo.measurement1_y2006m03 values (2,'2006-03-15',2,2);

select * from foo.test1;

This seems to be fine. Then I create a link to this:

DROP SCHEMA IF EXISTS fdw_foo CASCADE;
CREATE SCHEMA fdw_foo;
IMPORT FOREIGN SCHEMA foo
    FROM SERVER myserver INTO fdw_foo;

This works:

select * from fdw_foo.measurement1_y2006m02;

This doesn't

select * from fdw_foo.test1;

ERROR: relation "fdw_foo.test1" does not exist

Any thoughts?


Solution

  • That is a bug that you should report.

    As a workaround, you can create the foreign table yourself:

    CREATE FOREIGN TABLE fdw_foo.test1 (
        city_id         int not null,
        logdate         date not null,
        peaktemp        int,
        unitsales       int
    ) SERVER myserver
    OPTIONS (schema_name 'foo', table_name 'test1');