On Fri, Sep 4, 2026 at 8:34 PM Fujii Masao <[email protected]> wrote: > After the patch was committed, I observed that stats import could fail with > the following warning even though the remote table is no longer > inherited. Is this behavior intentional? > > WARNING: could not import statistics for foreign table > "public.ft" --- remote table "public.t" is inherited > > Here is the procedure to reproduce this situation. The point is that > the inheritance table is created and then dropped: > > -------------------------------- > CREATE TABLE t AS SELECT i FROM generate_series(1, 100) i; > ANALYZE t; > CREATE TABLE tt () INHERITS (t); > DROP TABLE tt; > > CREATE EXTENSION postgres_fdw; > CREATE SERVER loopback FOREIGN DATA WRAPPER postgres_fdw; > CREATE USER MAPPING FOR public SERVER loopback; > CREATE FOREIGN TABLE ft (i int) SERVER loopback OPTIONS (table_name > 't', import_stats 'true'); > > ANALYZE VERBOSE ft; > WARNING: could not import statistics for foreign table "public.ft" > --- remote table "public.t" is inherited > --------------------------------
This is expected behavior, because postgres_fdw determines whether the remote table is inherited or not, by checking only the table's relhassubclass. We could check pg_inherits as well, to detect false positives like this, but I didn't do so, because I don't think that that is worth complicating the code, as table inheritance is not that popular these days in the first place. Should we? I think another option would be to add a note about this behavior. Thanks for testing this! Best regards, Etsuro Fujita
