diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index ad663c94d7..bb610357c3 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -30197,7 +30197,8 @@ DETAIL: Make sure pg_wal_replay_wait() isn't called within a transaction with a The value of relpages must be greater than - or equal to -1, + or equal to -1 for partitioned table otherwise + greater then or equal to 0, reltuples must be greater than or equal to -1.0, and relallvisible must be greater than or equal to 0. diff --git a/src/backend/statistics/relation_stats.c b/src/backend/statistics/relation_stats.c index 1a6d1640c3..5ad3368463 100644 --- a/src/backend/statistics/relation_stats.c +++ b/src/backend/statistics/relation_stats.c @@ -98,17 +98,21 @@ relation_statistics_update(FunctionCallInfo fcinfo, int elevel) if (!PG_ARGISNULL(RELPAGES_ARG)) { int32 relpages = PG_GETARG_INT32(RELPAGES_ARG); + int32 minpages = 0; /* * Partitioned tables may have relpages=-1. Note: for relations with * no storage, relpages=-1 is not used consistently, but must be * supported here. */ - if (relpages < -1) + if (pgcform->relkind == RELKIND_PARTITIONED_TABLE) + minpages = -1; + + if (relpages < minpages) { ereport(elevel, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("relpages cannot be < -1"))); + errmsg("relpages cannot be < %d", minpages))); table_close(crel, RowExclusiveLock); return false; }