diff --git a/doc/src/sgml/ref/create_statistics.sgml b/doc/src/sgml/ref/create_statistics.sgml index dbe28d6..edbcf58 100644 --- a/doc/src/sgml/ref/create_statistics.sgml +++ b/doc/src/sgml/ref/create_statistics.sgml @@ -34,7 +34,7 @@ CREATE STATISTICS [ IF NOT EXISTS ] statistics_na CREATE STATISTICS will create a new extended statistics - object on the specified table. + object on the specified table, foreign table or materialized view. The statistics will be created in the current database and will be owned by the user issuing the command. diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c index 46abadc..2355e0e 100644 --- a/src/backend/commands/statscmds.c +++ b/src/backend/commands/statscmds.c @@ -106,10 +106,12 @@ CreateStatistics(CreateStatsStmt *stmt) relid = RelationGetRelid(rel); if (rel->rd_rel->relkind != RELKIND_RELATION && - rel->rd_rel->relkind != RELKIND_MATVIEW) + rel->rd_rel->relkind != RELKIND_MATVIEW && + rel->rd_rel->relkind != RELKIND_FOREIGN_TABLE && + rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("relation \"%s\" is not a table or materialized view", + errmsg("relation \"%s\" is not a table, foreign table, or materialized view", RelationGetRelationName(rel)))); /* diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 65a2f23..57d034f 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -6626,9 +6626,14 @@ getExtendedStatistics(Archive *fout, TableInfo tblinfo[], int numTables) { TableInfo *tbinfo = &tblinfo[i]; - /* Only plain tables and materialized views can have extended statistics. */ + /* + * Only plain tables, materialized views, foreign tables and + * partitioned tables can have extended statistics. + */ if (tbinfo->relkind != RELKIND_RELATION && - tbinfo->relkind != RELKIND_MATVIEW) + tbinfo->relkind != RELKIND_MATVIEW && + tbinfo->relkind != RELKIND_FOREIGN_TABLE && + tbinfo->relkind != RELKIND_PARTITIONED_TABLE) continue; /*