From 4f0c4a950f303645cf989bf3ac0657ac5163c1df Mon Sep 17 00:00:00 2001 From: Corey Huinker Date: Sat, 27 Jun 2026 11:39:04 -0400 Subject: [PATCH v3 01/15] Rename relation_stats_argnum enumeriations. Rename all relation_stats_argnum enumerated names from foo_ARG to RELARG_foo. This change will help distinguish these values from other enumerations which will be added in future commits. --- src/backend/statistics/relation_stats.c | 76 ++++++++++++------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/backend/statistics/relation_stats.c b/src/backend/statistics/relation_stats.c index 9de5d64c384..37b4ab71655 100644 --- a/src/backend/statistics/relation_stats.c +++ b/src/backend/statistics/relation_stats.c @@ -39,24 +39,24 @@ enum relation_stats_argnum { - RELSCHEMA_ARG = 0, - RELNAME_ARG, - RELPAGES_ARG, - RELTUPLES_ARG, - RELALLVISIBLE_ARG, - RELALLFROZEN_ARG, - NUM_RELATION_STATS_ARGS + RELARG_SCHEMA = 0, + RELARG_RELNAME, + RELARG_RELPAGES, + RELARG_RELTUPLES, + RELARG_RELALLVISIBLE, + RELARG_RELALLFROZEN, + RELARG_NUM_RELARGS }; static struct StatsArgInfo relarginfo[] = { - [RELSCHEMA_ARG] = {"schemaname", TEXTOID}, - [RELNAME_ARG] = {"relname", TEXTOID}, - [RELPAGES_ARG] = {"relpages", INT4OID}, - [RELTUPLES_ARG] = {"reltuples", FLOAT4OID}, - [RELALLVISIBLE_ARG] = {"relallvisible", INT4OID}, - [RELALLFROZEN_ARG] = {"relallfrozen", INT4OID}, - [NUM_RELATION_STATS_ARGS] = {0} + [RELARG_SCHEMA] = {"schemaname", TEXTOID}, + [RELARG_RELNAME] = {"relname", TEXTOID}, + [RELARG_RELPAGES] = {"relpages", INT4OID}, + [RELARG_RELTUPLES] = {"reltuples", FLOAT4OID}, + [RELARG_RELALLVISIBLE] = {"relallvisible", INT4OID}, + [RELARG_RELALLFROZEN] = {"relallfrozen", INT4OID}, + [RELARG_NUM_RELARGS] = {0} }; static bool relation_statistics_update(FunctionCallInfo fcinfo); @@ -74,11 +74,11 @@ relation_statistics_update(FunctionCallInfo fcinfo) Oid reloid; Oid locked_table = InvalidOid; - stats_check_required_arg(fcinfo, relarginfo, RELSCHEMA_ARG); - stats_check_required_arg(fcinfo, relarginfo, RELNAME_ARG); + stats_check_required_arg(fcinfo, relarginfo, RELARG_SCHEMA); + stats_check_required_arg(fcinfo, relarginfo, RELARG_RELNAME); - nspname = TextDatumGetCString(PG_GETARG_DATUM(RELSCHEMA_ARG)); - relname = TextDatumGetCString(PG_GETARG_DATUM(RELNAME_ARG)); + nspname = TextDatumGetCString(PG_GETARG_DATUM(RELARG_SCHEMA)); + relname = TextDatumGetCString(PG_GETARG_DATUM(RELARG_RELNAME)); if (RecoveryInProgress()) ereport(ERROR, @@ -116,15 +116,15 @@ relation_statistics_update_internal(Oid reloid, FunctionCallInfo fcinfo) int nreplaces = 0; bool result = true; - if (!PG_ARGISNULL(RELPAGES_ARG)) + if (!PG_ARGISNULL(RELARG_RELPAGES)) { - relpages = PG_GETARG_UINT32(RELPAGES_ARG); + relpages = PG_GETARG_UINT32(RELARG_RELPAGES); update_relpages = true; } - if (!PG_ARGISNULL(RELTUPLES_ARG)) + if (!PG_ARGISNULL(RELARG_RELTUPLES)) { - reltuples = PG_GETARG_FLOAT4(RELTUPLES_ARG); + reltuples = PG_GETARG_FLOAT4(RELARG_RELTUPLES); if (isnan(reltuples) || isinf(reltuples)) { ereport(WARNING, @@ -143,15 +143,15 @@ relation_statistics_update_internal(Oid reloid, FunctionCallInfo fcinfo) update_reltuples = true; } - if (!PG_ARGISNULL(RELALLVISIBLE_ARG)) + if (!PG_ARGISNULL(RELARG_RELALLVISIBLE)) { - relallvisible = PG_GETARG_UINT32(RELALLVISIBLE_ARG); + relallvisible = PG_GETARG_UINT32(RELARG_RELALLVISIBLE); update_relallvisible = true; } - if (!PG_ARGISNULL(RELALLFROZEN_ARG)) + if (!PG_ARGISNULL(RELARG_RELALLFROZEN)) { - relallfrozen = PG_GETARG_UINT32(RELALLFROZEN_ARG); + relallfrozen = PG_GETARG_UINT32(RELARG_RELALLFROZEN); update_relallfrozen = true; } @@ -247,11 +247,11 @@ pg_clear_relation_stats(PG_FUNCTION_ARGS) Datum pg_restore_relation_stats(PG_FUNCTION_ARGS) { - LOCAL_FCINFO(positional_fcinfo, NUM_RELATION_STATS_ARGS); + LOCAL_FCINFO(positional_fcinfo, RELARG_NUM_RELARGS); bool result = true; InitFunctionCallInfoData(*positional_fcinfo, NULL, - NUM_RELATION_STATS_ARGS, + RELARG_NUM_RELARGS, InvalidOid, NULL, NULL); if (!stats_fill_fcinfo_from_arg_pairs(fcinfo, positional_fcinfo, @@ -279,27 +279,27 @@ import_relation_statistics(Relation rel, const NullableDatum *relallvisible, const NullableDatum *relallfrozen) { - LOCAL_FCINFO(newfcinfo, NUM_RELATION_STATS_ARGS); + LOCAL_FCINFO(newfcinfo, RELARG_NUM_RELARGS); Assert(relpages); Assert(reltuples); Assert(relallvisible); Assert(relallfrozen); - InitFunctionCallInfoData(*newfcinfo, NULL, NUM_RELATION_STATS_ARGS, + InitFunctionCallInfoData(*newfcinfo, NULL, RELARG_NUM_RELARGS, InvalidOid, NULL, NULL); - newfcinfo->args[RELSCHEMA_ARG].value = + newfcinfo->args[RELARG_SCHEMA].value = CStringGetTextDatum(get_namespace_name(RelationGetNamespace(rel))); - newfcinfo->args[RELSCHEMA_ARG].isnull = false; - newfcinfo->args[RELNAME_ARG].value = + newfcinfo->args[RELARG_SCHEMA].isnull = false; + newfcinfo->args[RELARG_RELNAME].value = CStringGetTextDatum(RelationGetRelationName(rel)); - newfcinfo->args[RELNAME_ARG].isnull = false; + newfcinfo->args[RELARG_RELNAME].isnull = false; - newfcinfo->args[RELPAGES_ARG] = *relpages; - newfcinfo->args[RELTUPLES_ARG] = *reltuples; - newfcinfo->args[RELALLVISIBLE_ARG] = *relallvisible; - newfcinfo->args[RELALLFROZEN_ARG] = *relallfrozen; + newfcinfo->args[RELARG_RELPAGES] = *relpages; + newfcinfo->args[RELARG_RELTUPLES] = *reltuples; + newfcinfo->args[RELARG_RELALLVISIBLE] = *relallvisible; + newfcinfo->args[RELARG_RELALLFROZEN] = *relallfrozen; return relation_statistics_update_internal(RelationGetRelid(rel), newfcinfo); base-commit: 824d5f6241ea7a0a85c9d2b3d27beb78e42a36ab -- 2.50.1 (Apple Git-155)