pg_set_relation_stats_patch_v1.diff
application/octet-stream
Filename: pg_set_relation_stats_patch_v1.diff
Type: application/octet-stream
Part: 0
Message:
RE: Statistics Import and Export
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
Series: patch v1
| File | + | − |
|---|---|---|
| doc/src/sgml/func.sgml | 2 | 1 |
| src/backend/statistics/relation_stats.c | 6 | 2 |
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
</para>
<para>
The value of <structfield>relpages</structfield> must be greater than
- or equal to <literal>-1</literal>,
+ or equal to <literal>-1</literal> for partitioned table otherwise
+ greater then or equal to <literal>0</literal>,
<structfield>reltuples</structfield> must be greater than or equal to
<literal>-1.0</literal>, and <structfield>relallvisible</structfield>
must be greater than or equal to <literal>0</literal>.
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;
}