v2-0003-Remove-nonsense-bounds-checking-of-relpages-relal.patch
text/x-patch
Filename: v2-0003-Remove-nonsense-bounds-checking-of-relpages-relal.patch
Type: text/x-patch
Part: 2
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: format-patch
Series: patch v2-0003
Subject: Remove nonsense bounds checking of relpages, relallvisible.
| File | + | − |
|---|---|---|
| src/backend/statistics/relation_stats.c | 8 | 41 |
From 02bb2a98e7e290c53e3e130b330073d56af93f53 Mon Sep 17 00:00:00 2001
From: Corey Huinker <corey.huinker@gmail.com>
Date: Mon, 24 Feb 2025 05:01:59 -0500
Subject: [PATCH v2 3/3] Remove nonsense bounds checking of relpages,
relallvisible.
Change both to type BlockNumber and fetch as PG_GETARG_UINT32 while
we're at it.
---
src/backend/statistics/relation_stats.c | 49 ++++---------------------
1 file changed, 8 insertions(+), 41 deletions(-)
diff --git a/src/backend/statistics/relation_stats.c b/src/backend/statistics/relation_stats.c
index 046661d7c3f..e532c1ef6c7 100644
--- a/src/backend/statistics/relation_stats.c
+++ b/src/backend/statistics/relation_stats.c
@@ -62,62 +62,29 @@ relation_statistics_update(FunctionCallInfo fcinfo, int elevel, bool inplace)
{
Oid reloid;
Relation crel;
- int32 relpages = DEFAULT_RELPAGES;
+ BlockNumber relpages = DEFAULT_RELPAGES;
bool update_relpages = false;
float reltuples = DEFAULT_RELTUPLES;
bool update_reltuples = false;
- int32 relallvisible = DEFAULT_RELALLVISIBLE;
+ BlockNumber relallvisible = DEFAULT_RELALLVISIBLE;
bool update_relallvisible = false;
- bool result = true;
if (!PG_ARGISNULL(RELPAGES_ARG))
{
- relpages = PG_GETARG_INT32(RELPAGES_ARG);
-
- /*
- * 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 < -1")));
- result = false;
- }
- else
- update_relpages = true;
+ relpages = PG_GETARG_UINT32(RELPAGES_ARG);
+ update_relpages = true;
}
if (!PG_ARGISNULL(RELTUPLES_ARG))
{
reltuples = PG_GETARG_FLOAT4(RELTUPLES_ARG);
-
- if (reltuples < -1.0)
- {
- ereport(elevel,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("reltuples cannot be < -1.0")));
- result = false;
- }
- else
- update_reltuples = true;
+ update_reltuples = true;
}
if (!PG_ARGISNULL(RELALLVISIBLE_ARG))
{
- relallvisible = PG_GETARG_INT32(RELALLVISIBLE_ARG);
-
- if (relallvisible < 0)
- {
- ereport(elevel,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("relallvisible cannot be < 0")));
- result = false;
- }
- else
- update_relallvisible = true;
+ relallvisible = PG_GETARG_UINT32(RELALLVISIBLE_ARG);
+ update_relallvisible = true;
}
stats_check_required_arg(fcinfo, relarginfo, RELATION_ARG);
@@ -237,7 +204,7 @@ relation_statistics_update(FunctionCallInfo fcinfo, int elevel, bool inplace)
CommandCounterIncrement();
- return result;
+ return true;
}
/*
--
2.48.1