diff options
author | Jeff Davis <jdavis@postgresql.org> | 2024-10-18 10:44:15 -0700 |
---|---|---|
committer | Jeff Davis <jdavis@postgresql.org> | 2024-10-18 10:44:15 -0700 |
commit | b391d882ff38da423dc99fc6224bde4be4100212 (patch) | |
tree | 52cf96bce34458187f3db45405e7ccedc1aa6f47 /src/backend/statistics/relation_stats.c | |
parent | 1bd4bc85cac2b23484a6b568a752de0351c2cc5b (diff) | |
download | postgresql-b391d882ff38da423dc99fc6224bde4be4100212.tar.gz postgresql-b391d882ff38da423dc99fc6224bde4be4100212.zip |
Allow pg_set_relation_stats() to set relpages to -1.
While the default value for relpages is 0, if a partitioned table with
at least one child has been analyzed, then the partititoned table will
have a relpages value of -1.
Author: Corey Huinker
Discussion: https://postgr.es/m/CADkLM=fajh1Lpcyr_XsMmq-9Z=SGk-u+_Zeac7Pt0RAN3uiVCg@mail.gmail.com
Diffstat (limited to 'src/backend/statistics/relation_stats.c')
-rw-r--r-- | src/backend/statistics/relation_stats.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/backend/statistics/relation_stats.c b/src/backend/statistics/relation_stats.c index 26f15061e89..1a6d1640c30 100644 --- a/src/backend/statistics/relation_stats.c +++ b/src/backend/statistics/relation_stats.c @@ -99,11 +99,16 @@ relation_statistics_update(FunctionCallInfo fcinfo, int elevel) { int32 relpages = PG_GETARG_INT32(RELPAGES_ARG); - if (relpages < 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) { ereport(elevel, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("relpages cannot be < 0"))); + errmsg("relpages cannot be < -1"))); table_close(crel, RowExclusiveLock); return false; } |