v2-0005-Make-relation_statistics_update-stop-using-fcinfo.patch
application/octet-stream
Filename: v2-0005-Make-relation_statistics_update-stop-using-fcinfo.patch
Type: application/octet-stream
Part: 4
Patch
Format: format-patch
Series: patch v2-0005
Subject: Make relation_statistics_update stop using fcinfo.
| File | + | − |
|---|---|---|
| src/backend/statistics/relation_stats.c | 16 | 16 |
From e933298dfd1ebd7a25346c9d342e093582d1fbd7 Mon Sep 17 00:00:00 2001
From: Corey Huinker <corey.huinker@gmail.com>
Date: Sun, 28 Jun 2026 16:09:49 -0500
Subject: [PATCH v2 05/13] Make relation_statistics_update stop using fcinfo.
Change the function signature of relation_statistics_update to use a
NullableDatum array instead of a full FunctionCallInfo.
---
src/backend/statistics/relation_stats.c | 32 ++++++++++++-------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/backend/statistics/relation_stats.c b/src/backend/statistics/relation_stats.c
index 4cfee157be1..1ee23612ae1 100644
--- a/src/backend/statistics/relation_stats.c
+++ b/src/backend/statistics/relation_stats.c
@@ -56,13 +56,13 @@ static struct StatsArgInfo relarginfo[] =
[RELARG_NUM_RELARGS] = {0}
};
-static bool relation_statistics_update(FunctionCallInfo fcinfo);
+static bool relation_statistics_update(const NullableDatum *args);
/*
* Internal function for modifying statistics for a relation.
*/
static bool
-relation_statistics_update(FunctionCallInfo fcinfo)
+relation_statistics_update(const NullableDatum *args)
{
bool result = true;
char *nspname;
@@ -85,11 +85,11 @@ relation_statistics_update(FunctionCallInfo fcinfo)
int nreplaces = 0;
Oid locked_table = InvalidOid;
- stats_check_required_arg(fcinfo->args, relarginfo, RELARG_SCHEMA);
- stats_check_required_arg(fcinfo->args, relarginfo, RELARG_RELNAME);
+ stats_check_required_arg(args, relarginfo, RELARG_SCHEMA);
+ stats_check_required_arg(args, relarginfo, RELARG_RELNAME);
- nspname = TextDatumGetCString(PG_GETARG_DATUM(RELARG_SCHEMA));
- relname = TextDatumGetCString(PG_GETARG_DATUM(RELARG_RELNAME));
+ nspname = TextDatumGetCString(args[RELARG_SCHEMA].value);
+ relname = TextDatumGetCString(args[RELARG_RELNAME].value);
if (RecoveryInProgress())
ereport(ERROR,
@@ -101,15 +101,15 @@ relation_statistics_update(FunctionCallInfo fcinfo)
ShareUpdateExclusiveLock, 0,
RangeVarCallbackForStats, &locked_table);
- if (!PG_ARGISNULL(RELARG_RELPAGES))
+ if (!args[RELARG_RELPAGES].isnull)
{
- relpages = PG_GETARG_UINT32(RELARG_RELPAGES);
+ relpages = DatumGetUInt32(args[RELARG_RELPAGES].value);
update_relpages = true;
}
- if (!PG_ARGISNULL(RELARG_RELTUPLES))
+ if (!args[RELARG_RELTUPLES].isnull)
{
- reltuples = PG_GETARG_FLOAT4(RELARG_RELTUPLES);
+ reltuples = DatumGetFloat4(args[RELARG_RELTUPLES].value);
if (reltuples < -1.0)
{
ereport(WARNING,
@@ -121,15 +121,15 @@ relation_statistics_update(FunctionCallInfo fcinfo)
update_reltuples = true;
}
- if (!PG_ARGISNULL(RELARG_RELALLVISIBLE))
+ if (!args[RELARG_RELALLVISIBLE].isnull)
{
- relallvisible = PG_GETARG_UINT32(RELARG_RELALLVISIBLE);
+ relallvisible = DatumGetUInt32(args[RELARG_RELALLVISIBLE].value);
update_relallvisible = true;
}
- if (!PG_ARGISNULL(RELARG_RELALLFROZEN))
+ if (!args[RELARG_RELALLFROZEN].isnull)
{
- relallfrozen = PG_GETARG_UINT32(RELARG_RELALLFROZEN);
+ relallfrozen = DatumGetUInt32(args[RELARG_RELALLFROZEN].value);
update_relallfrozen = true;
}
@@ -218,7 +218,7 @@ pg_clear_relation_stats(PG_FUNCTION_ARGS)
newfcinfo->args[5].value = UInt32GetDatum(0);
newfcinfo->args[5].isnull = false;
- relation_statistics_update(newfcinfo);
+ relation_statistics_update(newfcinfo->args);
PG_RETURN_VOID();
}
@@ -236,7 +236,7 @@ pg_restore_relation_stats(PG_FUNCTION_ARGS)
relarginfo))
result = false;
- if (!relation_statistics_update(positional_fcinfo))
+ if (!relation_statistics_update(positional_fcinfo->args))
result = false;
PG_RETURN_BOOL(result);
--
2.50.1 (Apple Git-155)