From 99f1a23626991910b2f3baa113813542b7fd33f1 Mon Sep 17 00:00:00 2001
From: Corey Huinker <corey.huinker@gmail.com>
Date: Sat, 27 Jun 2026 12:13:28 -0400
Subject: [PATCH v2 03/13] Rename extended stats enumerations.

Rename extended_stats_argnum and extended_stats_exprs_element
enumerations.

Rename all extended_stats_argnum and extended_stats_exprs_element
enumerated names from foo_ARG to EXTARG_foo, and foo_ELEM to
EXPRELEM_foo.  This change will help distinguish these values from other
enumerations which will be added in future commits.
---
 src/backend/statistics/extended_stats_funcs.c | 308 +++++++++---------
 1 file changed, 154 insertions(+), 154 deletions(-)

diff --git a/src/backend/statistics/extended_stats_funcs.c b/src/backend/statistics/extended_stats_funcs.c
index 2cb3942056f..f96376d58d8 100644
--- a/src/backend/statistics/extended_stats_funcs.c
+++ b/src/backend/statistics/extended_stats_funcs.c
@@ -45,18 +45,18 @@
  */
 enum extended_stats_argnum
 {
-	RELSCHEMA_ARG = 0,
-	RELNAME_ARG,
-	STATSCHEMA_ARG,
-	STATNAME_ARG,
-	INHERITED_ARG,
-	NDISTINCT_ARG,
-	DEPENDENCIES_ARG,
-	MOST_COMMON_VALS_ARG,
-	MOST_COMMON_FREQS_ARG,
-	MOST_COMMON_BASE_FREQS_ARG,
-	EXPRESSIONS_ARG,
-	NUM_EXTENDED_STATS_ARGS,
+	EXTARG_RELSCHEMA = 0,
+	EXTARG_RELNAME,
+	EXTARG_STATSCHEMA,
+	EXTARG_STATNAME,
+	EXTARG_INHERITED,
+	EXTARG_NDISTINCT,
+	EXTARG_DEPENDENCIES,
+	EXTARG_MOST_COMMON_VALS,
+	EXTARG_MOST_COMMON_FREQS,
+	EXTARG_MOST_COMMON_BASE_FREQS,
+	EXTARG_EXPRESSIONS,
+	EXTARG_NUM_EXTARGS,
 };
 
 /*
@@ -65,18 +65,18 @@ enum extended_stats_argnum
  */
 static struct StatsArgInfo extarginfo[] =
 {
-	[RELSCHEMA_ARG] = {"schemaname", TEXTOID},
-	[RELNAME_ARG] = {"relname", TEXTOID},
-	[STATSCHEMA_ARG] = {"statistics_schemaname", TEXTOID},
-	[STATNAME_ARG] = {"statistics_name", TEXTOID},
-	[INHERITED_ARG] = {"inherited", BOOLOID},
-	[NDISTINCT_ARG] = {"n_distinct", PG_NDISTINCTOID},
-	[DEPENDENCIES_ARG] = {"dependencies", PG_DEPENDENCIESOID},
-	[MOST_COMMON_VALS_ARG] = {"most_common_vals", TEXTARRAYOID},
-	[MOST_COMMON_FREQS_ARG] = {"most_common_freqs", FLOAT8ARRAYOID},
-	[MOST_COMMON_BASE_FREQS_ARG] = {"most_common_base_freqs", FLOAT8ARRAYOID},
-	[EXPRESSIONS_ARG] = {"exprs", JSONBOID},
-	[NUM_EXTENDED_STATS_ARGS] = {0},
+	[EXTARG_RELSCHEMA] = {"schemaname", TEXTOID},
+	[EXTARG_RELNAME] = {"relname", TEXTOID},
+	[EXTARG_STATSCHEMA] = {"statistics_schemaname", TEXTOID},
+	[EXTARG_STATNAME] = {"statistics_name", TEXTOID},
+	[EXTARG_INHERITED] = {"inherited", BOOLOID},
+	[EXTARG_NDISTINCT] = {"n_distinct", PG_NDISTINCTOID},
+	[EXTARG_DEPENDENCIES] = {"dependencies", PG_DEPENDENCIESOID},
+	[EXTARG_MOST_COMMON_VALS] = {"most_common_vals", TEXTARRAYOID},
+	[EXTARG_MOST_COMMON_FREQS] = {"most_common_freqs", FLOAT8ARRAYOID},
+	[EXTARG_MOST_COMMON_BASE_FREQS] = {"most_common_base_freqs", FLOAT8ARRAYOID},
+	[EXTARG_EXPRESSIONS] = {"exprs", JSONBOID},
+	[EXTARG_NUM_EXTARGS] = {0},
 };
 
 /*
@@ -85,26 +85,26 @@ static struct StatsArgInfo extarginfo[] =
  */
 enum extended_stats_exprs_element
 {
-	NULL_FRAC_ELEM = 0,
-	AVG_WIDTH_ELEM,
-	N_DISTINCT_ELEM,
-	MOST_COMMON_VALS_ELEM,
-	MOST_COMMON_FREQS_ELEM,
-	HISTOGRAM_BOUNDS_ELEM,
-	CORRELATION_ELEM,
-	MOST_COMMON_ELEMS_ELEM,
-	MOST_COMMON_ELEM_FREQS_ELEM,
-	ELEM_COUNT_HISTOGRAM_ELEM,
-	RANGE_LENGTH_HISTOGRAM_ELEM,
-	RANGE_EMPTY_FRAC_ELEM,
-	RANGE_BOUNDS_HISTOGRAM_ELEM,
-	NUM_ATTRIBUTE_STATS_ELEMS
+	EXPRELEM_NULL_FRAC = 0,
+	EXPRELEM_AVG_WIDTH,
+	EXPRELEM_N_DISTINCT,
+	EXPRELEM_MOST_COMMON_VALS,
+	EXPRELEM_MOST_COMMON_FREQS,
+	EXPRELEM_HISTOGRAM_BOUNDS,
+	EXPRELEM_CORRELATION,
+	EXPRELEM_MOST_COMMON_ELEMS,
+	EXPRELEM_MOST_COMMON_ELEM_FREQS,
+	EXPRELEM_ELEM_COUNT_HISTOGRAM,
+	EXPRELEM_RANGE_LENGTH_HISTOGRAM,
+	EXPRELEM_RANGE_EMPTY_FRAC,
+	EXPRELEM_RANGE_BOUNDS_HISTOGRAM,
+	EXPRELEM_NUM_EXPRELEMS
 };
 
 /*
  * The argument names of the repeating arguments for stxdexpr.
  */
-static const char *extexprargname[NUM_ATTRIBUTE_STATS_ELEMS] =
+static const char *extexprargname[EXPRELEM_NUM_EXPRELEMS] =
 {
 	"null_frac",
 	"avg_width",
@@ -356,12 +356,12 @@ extended_statistics_update(FunctionCallInfo fcinfo)
 	 * Therefore, none of the three array values is meaningful unless the
 	 * other two are also present and in sync in terms of array length.
 	 */
-	has.mcv = (!PG_ARGISNULL(MOST_COMMON_VALS_ARG) &&
-			   !PG_ARGISNULL(MOST_COMMON_FREQS_ARG) &&
-			   !PG_ARGISNULL(MOST_COMMON_BASE_FREQS_ARG));
-	has.ndistinct = !PG_ARGISNULL(NDISTINCT_ARG);
-	has.dependencies = !PG_ARGISNULL(DEPENDENCIES_ARG);
-	has.expressions = !PG_ARGISNULL(EXPRESSIONS_ARG);
+	has.mcv = (!PG_ARGISNULL(EXTARG_MOST_COMMON_VALS) &&
+			   !PG_ARGISNULL(EXTARG_MOST_COMMON_FREQS) &&
+			   !PG_ARGISNULL(EXTARG_MOST_COMMON_BASE_FREQS));
+	has.ndistinct = !PG_ARGISNULL(EXTARG_NDISTINCT);
+	has.dependencies = !PG_ARGISNULL(EXTARG_DEPENDENCIES);
+	has.expressions = !PG_ARGISNULL(EXTARG_EXPRESSIONS);
 
 	if (RecoveryInProgress())
 	{
@@ -373,18 +373,18 @@ extended_statistics_update(FunctionCallInfo fcinfo)
 	}
 
 	/* relation arguments */
-	stats_check_required_arg(fcinfo, extarginfo, RELSCHEMA_ARG);
-	relnspname = TextDatumGetCString(PG_GETARG_DATUM(RELSCHEMA_ARG));
-	stats_check_required_arg(fcinfo, extarginfo, RELNAME_ARG);
-	relname = TextDatumGetCString(PG_GETARG_DATUM(RELNAME_ARG));
+	stats_check_required_arg(fcinfo, extarginfo, EXTARG_RELSCHEMA);
+	relnspname = TextDatumGetCString(PG_GETARG_DATUM(EXTARG_RELSCHEMA));
+	stats_check_required_arg(fcinfo, extarginfo, EXTARG_RELNAME);
+	relname = TextDatumGetCString(PG_GETARG_DATUM(EXTARG_RELNAME));
 
 	/* extended statistics arguments */
-	stats_check_required_arg(fcinfo, extarginfo, STATSCHEMA_ARG);
-	nspname = TextDatumGetCString(PG_GETARG_DATUM(STATSCHEMA_ARG));
-	stats_check_required_arg(fcinfo, extarginfo, STATNAME_ARG);
-	stxname = TextDatumGetCString(PG_GETARG_DATUM(STATNAME_ARG));
-	stats_check_required_arg(fcinfo, extarginfo, INHERITED_ARG);
-	inherited = PG_GETARG_BOOL(INHERITED_ARG);
+	stats_check_required_arg(fcinfo, extarginfo, EXTARG_STATSCHEMA);
+	nspname = TextDatumGetCString(PG_GETARG_DATUM(EXTARG_STATSCHEMA));
+	stats_check_required_arg(fcinfo, extarginfo, EXTARG_STATNAME);
+	stxname = TextDatumGetCString(PG_GETARG_DATUM(EXTARG_STATNAME));
+	stats_check_required_arg(fcinfo, extarginfo, EXTARG_INHERITED);
+	inherited = PG_GETARG_BOOL(EXTARG_INHERITED);
 
 	/*
 	 * First open the relation where we expect to find the statistics.  This
@@ -482,7 +482,7 @@ extended_statistics_update(FunctionCallInfo fcinfo)
 		ereport(WARNING,
 				errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 				errmsg("cannot specify parameter \"%s\"",
-					   extarginfo[NDISTINCT_ARG].argname),
+					   extarginfo[EXTARG_NDISTINCT].argname),
 				errhint("Extended statistics object \"%s.%s\" does not support statistics of this type.",
 						nspname, stxname));
 
@@ -499,7 +499,7 @@ extended_statistics_update(FunctionCallInfo fcinfo)
 		ereport(WARNING,
 				errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 				errmsg("cannot specify parameter \"%s\"",
-					   extarginfo[DEPENDENCIES_ARG].argname),
+					   extarginfo[EXTARG_DEPENDENCIES].argname),
 				errhint("Extended statistics object \"%s.%s\" does not support statistics of this type.",
 						nspname, stxname));
 		has.dependencies = false;
@@ -514,16 +514,16 @@ extended_statistics_update(FunctionCallInfo fcinfo)
 	 */
 	if (!enabled.mcv)
 	{
-		if (!PG_ARGISNULL(MOST_COMMON_VALS_ARG) ||
-			!PG_ARGISNULL(MOST_COMMON_FREQS_ARG) ||
-			!PG_ARGISNULL(MOST_COMMON_BASE_FREQS_ARG))
+		if (!PG_ARGISNULL(EXTARG_MOST_COMMON_VALS) ||
+			!PG_ARGISNULL(EXTARG_MOST_COMMON_FREQS) ||
+			!PG_ARGISNULL(EXTARG_MOST_COMMON_BASE_FREQS))
 		{
 			ereport(WARNING,
 					errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 					errmsg("cannot specify parameters \"%s\", \"%s\", or \"%s\"",
-						   extarginfo[MOST_COMMON_VALS_ARG].argname,
-						   extarginfo[MOST_COMMON_FREQS_ARG].argname,
-						   extarginfo[MOST_COMMON_BASE_FREQS_ARG].argname),
+						   extarginfo[EXTARG_MOST_COMMON_VALS].argname,
+						   extarginfo[EXTARG_MOST_COMMON_FREQS].argname,
+						   extarginfo[EXTARG_MOST_COMMON_BASE_FREQS].argname),
 					errhint("Extended statistics object \"%s.%s\" does not support statistics of this type.",
 							nspname, stxname));
 
@@ -538,16 +538,16 @@ extended_statistics_update(FunctionCallInfo fcinfo)
 		 * statistics object expects something, something is wrong.  This
 		 * issues a WARNING if a partial input has been provided.
 		 */
-		if (!PG_ARGISNULL(MOST_COMMON_VALS_ARG) ||
-			!PG_ARGISNULL(MOST_COMMON_FREQS_ARG) ||
-			!PG_ARGISNULL(MOST_COMMON_BASE_FREQS_ARG))
+		if (!PG_ARGISNULL(EXTARG_MOST_COMMON_VALS) ||
+			!PG_ARGISNULL(EXTARG_MOST_COMMON_FREQS) ||
+			!PG_ARGISNULL(EXTARG_MOST_COMMON_BASE_FREQS))
 		{
 			ereport(WARNING,
 					errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 					errmsg("could not use \"%s\", \"%s\", and \"%s\": missing one or more parameters",
-						   extarginfo[MOST_COMMON_VALS_ARG].argname,
-						   extarginfo[MOST_COMMON_FREQS_ARG].argname,
-						   extarginfo[MOST_COMMON_BASE_FREQS_ARG].argname));
+						   extarginfo[EXTARG_MOST_COMMON_VALS].argname,
+						   extarginfo[EXTARG_MOST_COMMON_FREQS].argname,
+						   extarginfo[EXTARG_MOST_COMMON_BASE_FREQS].argname));
 			success = false;
 		}
 	}
@@ -561,7 +561,7 @@ extended_statistics_update(FunctionCallInfo fcinfo)
 		ereport(WARNING,
 				errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 				errmsg("cannot specify parameter \"%s\"",
-					   extarginfo[EXPRESSIONS_ARG].argname),
+					   extarginfo[EXTARG_EXPRESSIONS].argname),
 				errhint("Extended statistics object \"%s.%s\" does not support statistics of this type.",
 						nspname, stxname));
 
@@ -655,7 +655,7 @@ extended_statistics_update(FunctionCallInfo fcinfo)
 
 	if (has.ndistinct)
 	{
-		Datum		ndistinct_datum = PG_GETARG_DATUM(NDISTINCT_ARG);
+		Datum		ndistinct_datum = PG_GETARG_DATUM(EXTARG_NDISTINCT);
 		bytea	   *data = DatumGetByteaPP(ndistinct_datum);
 		MVNDistinct *ndistinct = statext_ndistinct_deserialize(data);
 
@@ -674,7 +674,7 @@ extended_statistics_update(FunctionCallInfo fcinfo)
 
 	if (has.dependencies)
 	{
-		Datum		dependencies_datum = PG_GETARG_DATUM(DEPENDENCIES_ARG);
+		Datum		dependencies_datum = PG_GETARG_DATUM(EXTARG_DEPENDENCIES);
 		bytea	   *data = DatumGetByteaPP(dependencies_datum);
 		MVDependencies *dependencies = statext_dependencies_deserialize(data);
 
@@ -696,9 +696,9 @@ extended_statistics_update(FunctionCallInfo fcinfo)
 		Datum		datum;
 		bool		val_ok = false;
 
-		datum = import_mcv(PG_GETARG_ARRAYTYPE_P(MOST_COMMON_VALS_ARG),
-						   PG_GETARG_ARRAYTYPE_P(MOST_COMMON_FREQS_ARG),
-						   PG_GETARG_ARRAYTYPE_P(MOST_COMMON_BASE_FREQS_ARG),
+		datum = import_mcv(PG_GETARG_ARRAYTYPE_P(EXTARG_MOST_COMMON_VALS),
+						   PG_GETARG_ARRAYTYPE_P(EXTARG_MOST_COMMON_FREQS),
+						   PG_GETARG_ARRAYTYPE_P(EXTARG_MOST_COMMON_BASE_FREQS),
 						   atttypids, atttypmods, atttypcolls, numattrs,
 						   &val_ok);
 
@@ -733,7 +733,7 @@ extended_statistics_update(FunctionCallInfo fcinfo)
 								   &atttypids[numattnums],
 								   &atttypmods[numattnums],
 								   &atttypcolls[numattnums],
-								   PG_GETARG_JSONB_P(EXPRESSIONS_ARG),
+								   PG_GETARG_JSONB_P(EXTARG_EXPRESSIONS),
 								   &ok);
 
 		table_close(pgsd, RowExclusiveLock);
@@ -797,7 +797,7 @@ check_mcvlist_array(const ArrayType *arr, int argindex, int required_ndims,
 				errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 				errmsg("could not parse array \"%s\": incorrect number of elements (same as \"%s\" required)",
 					   extarginfo[argindex].argname,
-					   extarginfo[MOST_COMMON_VALS_ARG].argname));
+					   extarginfo[EXTARG_MOST_COMMON_VALS].argname));
 		return false;
 	}
 
@@ -831,7 +831,7 @@ import_mcv(const ArrayType *mcv_arr, const ArrayType *freqs_arr,
 		ereport(WARNING,
 				errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 				errmsg("could not parse array \"%s\": incorrect number of dimensions (%d required)",
-					   extarginfo[MOST_COMMON_VALS_ARG].argname, 2));
+					   extarginfo[EXTARG_MOST_COMMON_VALS].argname, 2));
 		goto mcv_error;
 	}
 
@@ -840,7 +840,7 @@ import_mcv(const ArrayType *mcv_arr, const ArrayType *freqs_arr,
 		ereport(WARNING,
 				errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 				errmsg("could not parse array \"%s\": found %d attributes but expected %d",
-					   extarginfo[MOST_COMMON_VALS_ARG].argname,
+					   extarginfo[EXTARG_MOST_COMMON_VALS].argname,
 					   ARR_DIMS(mcv_arr)[1], numattrs));
 		goto mcv_error;
 	}
@@ -861,13 +861,13 @@ import_mcv(const ArrayType *mcv_arr, const ArrayType *freqs_arr,
 		ereport(WARNING,
 				errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 				errmsg("could not parse array \"%s\": number of items (%d) exceeds maximum (%d)",
-					   extarginfo[MOST_COMMON_VALS_ARG].argname,
+					   extarginfo[EXTARG_MOST_COMMON_VALS].argname,
 					   nitems, STATS_MCVLIST_MAX_ITEMS));
 		goto mcv_error;
 	}
 
-	if (!check_mcvlist_array(freqs_arr, MOST_COMMON_FREQS_ARG, 1, nitems) ||
-		!check_mcvlist_array(base_freqs_arr, MOST_COMMON_BASE_FREQS_ARG, 1, nitems))
+	if (!check_mcvlist_array(freqs_arr, EXTARG_MOST_COMMON_FREQS, 1, nitems) ||
+		!check_mcvlist_array(base_freqs_arr, EXTARG_MOST_COMMON_BASE_FREQS, 1, nitems))
 	{
 		/* inconsistent input arrays found */
 		goto mcv_error;
@@ -899,7 +899,7 @@ static bool
 key_in_expr_argnames(JsonbValue *key)
 {
 	Assert(key->type == jbvString);
-	for (int i = 0; i < NUM_ATTRIBUTE_STATS_ELEMS; i++)
+	for (int i = 0; i < EXPRELEM_NUM_EXPRELEMS; i++)
 	{
 		if (strlen(extexprargname[i]) == key->val.string.len &&
 			strncmp(extexprargname[i], key->val.string.val, key->val.string.len) == 0)
@@ -1125,7 +1125,7 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 					Oid typid, int32 typmod, Oid typcoll,
 					bool *pg_statistic_ok)
 {
-	const char *argname = extarginfo[EXPRESSIONS_ARG].argname;
+	const char *argname = extarginfo[EXTARG_EXPRESSIONS].argname;
 	TypeCacheEntry *typcache;
 	Datum		values[Natts_pg_statistic];
 	bool		nulls[Natts_pg_statistic];
@@ -1134,8 +1134,8 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 	Datum		pgstdat = (Datum) 0;
 	Oid			elemtypid = InvalidOid;
 	Oid			elemeqopr = InvalidOid;
-	bool		found[NUM_ATTRIBUTE_STATS_ELEMS] = {0};
-	JsonbValue	val[NUM_ATTRIBUTE_STATS_ELEMS] = {0};
+	bool		found[EXPRELEM_NUM_EXPRELEMS] = {0};
+	JsonbValue	val[EXPRELEM_NUM_EXPRELEMS] = {0};
 
 	/* Assume the worst by default. */
 	*pg_statistic_ok = false;
@@ -1154,7 +1154,7 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 	 * neither a string nor a NULL, there is not much we can do, so just give
 	 * on the entire tuple for this expression.
 	 */
-	for (int i = 0; i < NUM_ATTRIBUTE_STATS_ELEMS; i++)
+	for (int i = 0; i < EXPRELEM_NUM_EXPRELEMS; i++)
 	{
 		const char *s = extexprargname[i];
 		int			len = strlen(s);
@@ -1190,26 +1190,26 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 	 * we have ruled out disagreeing pairs, we can use either found flag as a
 	 * proxy for the other.
 	 */
-	if (found[MOST_COMMON_VALS_ELEM] != found[MOST_COMMON_FREQS_ELEM])
+	if (found[EXPRELEM_MOST_COMMON_VALS] != found[EXPRELEM_MOST_COMMON_FREQS])
 	{
 		ereport(WARNING,
 				errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 				errmsg("could not parse \"%s\": invalid element in expression %d",
 					   argname, exprnum),
 				errhint("\"%s\" and \"%s\" must be both either strings or nulls.",
-						extexprargname[MOST_COMMON_VALS_ELEM],
-						extexprargname[MOST_COMMON_FREQS_ELEM]));
+						extexprargname[EXPRELEM_MOST_COMMON_VALS],
+						extexprargname[EXPRELEM_MOST_COMMON_FREQS]));
 		goto pg_statistic_error;
 	}
-	if (found[MOST_COMMON_ELEMS_ELEM] != found[MOST_COMMON_ELEM_FREQS_ELEM])
+	if (found[EXPRELEM_MOST_COMMON_ELEMS] != found[EXPRELEM_MOST_COMMON_ELEM_FREQS])
 	{
 		ereport(WARNING,
 				errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 				errmsg("could not parse \"%s\": invalid element in expression %d",
 					   argname, exprnum),
 				errhint("\"%s\" and \"%s\" must be both either strings or nulls.",
-						extexprargname[MOST_COMMON_ELEMS_ELEM],
-						extexprargname[MOST_COMMON_ELEM_FREQS_ELEM]));
+						extexprargname[EXPRELEM_MOST_COMMON_ELEMS],
+						extexprargname[EXPRELEM_MOST_COMMON_ELEM_FREQS]));
 		goto pg_statistic_error;
 	}
 
@@ -1217,17 +1217,17 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 	 * Range types may expect three values to be set.  All three of them must
 	 * either be found or not be found.  Any disagreement is a warning.
 	 */
-	if (found[RANGE_LENGTH_HISTOGRAM_ELEM] != found[RANGE_EMPTY_FRAC_ELEM] ||
-		found[RANGE_LENGTH_HISTOGRAM_ELEM] != found[RANGE_BOUNDS_HISTOGRAM_ELEM])
+	if (found[EXPRELEM_RANGE_LENGTH_HISTOGRAM] != found[EXPRELEM_RANGE_EMPTY_FRAC] ||
+		found[EXPRELEM_RANGE_LENGTH_HISTOGRAM] != found[EXPRELEM_RANGE_BOUNDS_HISTOGRAM])
 	{
 		ereport(WARNING,
 				errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 				errmsg("could not parse \"%s\": invalid element in expression %d",
 					   argname, exprnum),
 				errhint("\"%s\", \"%s\", and \"%s\" must be all either strings or all nulls.",
-						extexprargname[RANGE_LENGTH_HISTOGRAM_ELEM],
-						extexprargname[RANGE_EMPTY_FRAC_ELEM],
-						extexprargname[RANGE_BOUNDS_HISTOGRAM_ELEM]));
+						extexprargname[EXPRELEM_RANGE_LENGTH_HISTOGRAM],
+						extexprargname[EXPRELEM_RANGE_EMPTY_FRAC],
+						extexprargname[EXPRELEM_RANGE_BOUNDS_HISTOGRAM]));
 		goto pg_statistic_error;
 	}
 
@@ -1249,7 +1249,7 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 	 * type MCELEM or DECHIST, otherwise the values are unnecessary and not
 	 * meaningful.
 	 */
-	if (found[MOST_COMMON_ELEMS_ELEM] || found[ELEM_COUNT_HISTOGRAM_ELEM])
+	if (found[EXPRELEM_MOST_COMMON_ELEMS] || found[EXPRELEM_ELEM_COUNT_HISTOGRAM])
 	{
 		if (!statatt_get_elem_type(typid, typcache->typtype,
 								   &elemtypid, &elemeqopr))
@@ -1266,9 +1266,9 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 	 * These three fields can only be set if dealing with a range or
 	 * multi-range type.
 	 */
-	if (found[RANGE_LENGTH_HISTOGRAM_ELEM] ||
-		found[RANGE_EMPTY_FRAC_ELEM] ||
-		found[RANGE_BOUNDS_HISTOGRAM_ELEM])
+	if (found[EXPRELEM_RANGE_LENGTH_HISTOGRAM] ||
+		found[EXPRELEM_RANGE_EMPTY_FRAC] ||
+		found[EXPRELEM_RANGE_BOUNDS_HISTOGRAM])
 	{
 		if (typcache->typtype != TYPTYPE_RANGE &&
 			typcache->typtype != TYPTYPE_MULTIRANGE)
@@ -1278,44 +1278,44 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 					errmsg("could not parse \"%s\": invalid data in expression %d",
 						   argname, exprnum),
 					errhint("\"%s\", \"%s\", and \"%s\" can only be set for a range type.",
-							extexprargname[RANGE_LENGTH_HISTOGRAM_ELEM],
-							extexprargname[RANGE_EMPTY_FRAC_ELEM],
-							extexprargname[RANGE_BOUNDS_HISTOGRAM_ELEM]));
+							extexprargname[EXPRELEM_RANGE_LENGTH_HISTOGRAM],
+							extexprargname[EXPRELEM_RANGE_EMPTY_FRAC],
+							extexprargname[EXPRELEM_RANGE_BOUNDS_HISTOGRAM]));
 			goto pg_statistic_error;
 		}
 	}
 
 	/* null_frac */
-	if (found[NULL_FRAC_ELEM])
+	if (found[EXPRELEM_NULL_FRAC])
 	{
 		Datum		datum;
 
-		if (jbv_to_infunc_datum(&val[NULL_FRAC_ELEM], float4in, exprnum,
-								extexprargname[NULL_FRAC_ELEM], &datum))
+		if (jbv_to_infunc_datum(&val[EXPRELEM_NULL_FRAC], float4in, exprnum,
+								extexprargname[EXPRELEM_NULL_FRAC], &datum))
 			values[Anum_pg_statistic_stanullfrac - 1] = datum;
 		else
 			goto pg_statistic_error;
 	}
 
 	/* avg_width */
-	if (found[AVG_WIDTH_ELEM])
+	if (found[EXPRELEM_AVG_WIDTH])
 	{
 		Datum		datum;
 
-		if (jbv_to_infunc_datum(&val[AVG_WIDTH_ELEM], int4in, exprnum,
-								extexprargname[AVG_WIDTH_ELEM], &datum))
+		if (jbv_to_infunc_datum(&val[EXPRELEM_AVG_WIDTH], int4in, exprnum,
+								extexprargname[EXPRELEM_AVG_WIDTH], &datum))
 			values[Anum_pg_statistic_stawidth - 1] = datum;
 		else
 			goto pg_statistic_error;
 	}
 
 	/* n_distinct */
-	if (found[N_DISTINCT_ELEM])
+	if (found[EXPRELEM_N_DISTINCT])
 	{
 		Datum		datum;
 
-		if (jbv_to_infunc_datum(&val[N_DISTINCT_ELEM], float4in, exprnum,
-								extexprargname[N_DISTINCT_ELEM], &datum))
+		if (jbv_to_infunc_datum(&val[EXPRELEM_N_DISTINCT], float4in, exprnum,
+								extexprargname[EXPRELEM_N_DISTINCT], &datum))
 			values[Anum_pg_statistic_stadistinct - 1] = datum;
 		else
 			goto pg_statistic_error;
@@ -1334,7 +1334,7 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 	 * completely.
 	 */
 
-	if (found[MOST_COMMON_VALS_ELEM])
+	if (found[EXPRELEM_MOST_COMMON_VALS])
 	{
 		Datum		stavalues;
 		Datum		stanumbers;
@@ -1342,16 +1342,16 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 		bool		num_ok = false;
 		char	   *s;
 
-		s = jbv_string_get_cstr(&val[MOST_COMMON_VALS_ELEM]);
+		s = jbv_string_get_cstr(&val[EXPRELEM_MOST_COMMON_VALS]);
 		stavalues = array_in_safe(array_in_fn, s, typid, typmod, exprnum,
-								  extexprargname[MOST_COMMON_VALS_ELEM],
+								  extexprargname[EXPRELEM_MOST_COMMON_VALS],
 								  &val_ok);
 
 		pfree(s);
 
-		s = jbv_string_get_cstr(&val[MOST_COMMON_FREQS_ELEM]);
+		s = jbv_string_get_cstr(&val[EXPRELEM_MOST_COMMON_FREQS]);
 		stanumbers = array_in_safe(array_in_fn, s, FLOAT4OID, -1, exprnum,
-								   extexprargname[MOST_COMMON_FREQS_ELEM],
+								   extexprargname[EXPRELEM_MOST_COMMON_FREQS],
 								   &num_ok);
 		pfree(s);
 
@@ -1383,14 +1383,14 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 	}
 
 	/* STATISTIC_KIND_HISTOGRAM */
-	if (found[HISTOGRAM_BOUNDS_ELEM])
+	if (found[EXPRELEM_HISTOGRAM_BOUNDS])
 	{
 		Datum		stavalues;
 		bool		val_ok = false;
-		char	   *s = jbv_string_get_cstr(&val[HISTOGRAM_BOUNDS_ELEM]);
+		char	   *s = jbv_string_get_cstr(&val[EXPRELEM_HISTOGRAM_BOUNDS]);
 
 		stavalues = array_in_safe(array_in_fn, s, typid, typmod, exprnum,
-								  extexprargname[HISTOGRAM_BOUNDS_ELEM],
+								  extexprargname[EXPRELEM_HISTOGRAM_BOUNDS],
 								  &val_ok);
 		pfree(s);
 
@@ -1404,12 +1404,12 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 	}
 
 	/* STATISTIC_KIND_CORRELATION */
-	if (found[CORRELATION_ELEM])
+	if (found[EXPRELEM_CORRELATION])
 	{
 		Datum		corr[] = {(Datum) 0};
 
-		if (jbv_to_infunc_datum(&val[CORRELATION_ELEM], float4in, exprnum,
-								extexprargname[CORRELATION_ELEM], &corr[0]))
+		if (jbv_to_infunc_datum(&val[EXPRELEM_CORRELATION], float4in, exprnum,
+								extexprargname[EXPRELEM_CORRELATION], &corr[0]))
 		{
 			ArrayType  *arry = construct_array_builtin(corr, 1, FLOAT4OID);
 			Datum		stanumbers = PointerGetDatum(arry);
@@ -1424,7 +1424,7 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 	}
 
 	/* STATISTIC_KIND_MCELEM */
-	if (found[MOST_COMMON_ELEMS_ELEM])
+	if (found[EXPRELEM_MOST_COMMON_ELEMS])
 	{
 		Datum		stavalues;
 		Datum		stanumbers;
@@ -1432,16 +1432,16 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 		bool		num_ok = false;
 		char	   *s;
 
-		s = jbv_string_get_cstr(&val[MOST_COMMON_ELEMS_ELEM]);
+		s = jbv_string_get_cstr(&val[EXPRELEM_MOST_COMMON_ELEMS]);
 		stavalues = array_in_safe(array_in_fn, s, elemtypid, typmod, exprnum,
-								  extexprargname[MOST_COMMON_ELEMS_ELEM],
+								  extexprargname[EXPRELEM_MOST_COMMON_ELEMS],
 								  &val_ok);
 		pfree(s);
 
 
-		s = jbv_string_get_cstr(&val[MOST_COMMON_ELEM_FREQS_ELEM]);
+		s = jbv_string_get_cstr(&val[EXPRELEM_MOST_COMMON_ELEM_FREQS]);
 		stanumbers = array_in_safe(array_in_fn, s, FLOAT4OID, -1, exprnum,
-								   extexprargname[MOST_COMMON_ELEM_FREQS_ELEM],
+								   extexprargname[EXPRELEM_MOST_COMMON_ELEM_FREQS],
 								   &num_ok);
 		pfree(s);
 
@@ -1456,15 +1456,15 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 	}
 
 	/* STATISTIC_KIND_DECHIST */
-	if (found[ELEM_COUNT_HISTOGRAM_ELEM])
+	if (found[EXPRELEM_ELEM_COUNT_HISTOGRAM])
 	{
 		Datum		stanumbers;
 		bool		num_ok = false;
 		char	   *s;
 
-		s = jbv_string_get_cstr(&val[ELEM_COUNT_HISTOGRAM_ELEM]);
+		s = jbv_string_get_cstr(&val[EXPRELEM_ELEM_COUNT_HISTOGRAM]);
 		stanumbers = array_in_safe(array_in_fn, s, FLOAT4OID, -1, exprnum,
-								   extexprargname[ELEM_COUNT_HISTOGRAM_ELEM],
+								   extexprargname[EXPRELEM_ELEM_COUNT_HISTOGRAM],
 								   &num_ok);
 		pfree(s);
 
@@ -1482,7 +1482,7 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 	 * though it is numerically greater, and all other stakinds appear in
 	 * numerical order.
 	 */
-	if (found[RANGE_BOUNDS_HISTOGRAM_ELEM])
+	if (found[EXPRELEM_RANGE_BOUNDS_HISTOGRAM])
 	{
 		Datum		stavalues;
 		bool		val_ok = false;
@@ -1496,10 +1496,10 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 		if (type_is_multirange(typid))
 			rtypid = get_multirange_range(typid);
 
-		s = jbv_string_get_cstr(&val[RANGE_BOUNDS_HISTOGRAM_ELEM]);
+		s = jbv_string_get_cstr(&val[EXPRELEM_RANGE_BOUNDS_HISTOGRAM]);
 
 		stavalues = array_in_safe(array_in_fn, s, rtypid, typmod, exprnum,
-								  extexprargname[RANGE_BOUNDS_HISTOGRAM_ELEM],
+								  extexprargname[EXPRELEM_RANGE_BOUNDS_HISTOGRAM],
 								  &val_ok);
 
 		if (val_ok)
@@ -1512,7 +1512,7 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 	}
 
 	/* STATISTIC_KIND_RANGE_LENGTH_HISTOGRAM */
-	if (found[RANGE_LENGTH_HISTOGRAM_ELEM])
+	if (found[EXPRELEM_RANGE_LENGTH_HISTOGRAM])
 	{
 		Datum		empty_frac[] = {(Datum) 0};
 		Datum		stavalues;
@@ -1520,8 +1520,8 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 		bool		val_ok = false;
 		char	   *s;
 
-		if (jbv_to_infunc_datum(&val[RANGE_EMPTY_FRAC_ELEM], float4in, exprnum,
-								extexprargname[RANGE_EMPTY_FRAC_ELEM], &empty_frac[0]))
+		if (jbv_to_infunc_datum(&val[EXPRELEM_RANGE_EMPTY_FRAC], float4in, exprnum,
+								extexprargname[EXPRELEM_RANGE_EMPTY_FRAC], &empty_frac[0]))
 		{
 			ArrayType  *arry = construct_array_builtin(empty_frac, 1, FLOAT4OID);
 
@@ -1530,9 +1530,9 @@ import_pg_statistic(Relation pgsd, JsonbContainer *cont,
 		else
 			goto pg_statistic_error;
 
-		s = jbv_string_get_cstr(&val[RANGE_LENGTH_HISTOGRAM_ELEM]);
+		s = jbv_string_get_cstr(&val[EXPRELEM_RANGE_LENGTH_HISTOGRAM]);
 		stavalues = array_in_safe(array_in_fn, s, FLOAT8OID, -1, exprnum,
-								  extexprargname[RANGE_LENGTH_HISTOGRAM_ELEM],
+								  extexprargname[EXPRELEM_RANGE_LENGTH_HISTOGRAM],
 								  &val_ok);
 
 		if (val_ok)
@@ -1575,7 +1575,7 @@ import_expressions(Relation pgsd, int numexprs,
 				   Oid *atttypcolls, Jsonb *exprs_jsonb,
 				   bool *exprs_is_perfect)
 {
-	const char *argname = extarginfo[EXPRESSIONS_ARG].argname;
+	const char *argname = extarginfo[EXTARG_EXPRESSIONS].argname;
 	Oid			pgstypoid = get_rel_type_id(StatisticRelationId);
 	ArrayBuildState *astate = NULL;
 	Datum		result = (Datum) 0;
@@ -1735,10 +1735,10 @@ delete_pg_statistic_ext_data(Oid stxoid, bool inherited)
 Datum
 pg_restore_extended_stats(PG_FUNCTION_ARGS)
 {
-	LOCAL_FCINFO(positional_fcinfo, NUM_EXTENDED_STATS_ARGS);
+	LOCAL_FCINFO(positional_fcinfo, EXTARG_NUM_EXTARGS);
 	bool		result = true;
 
-	InitFunctionCallInfoData(*positional_fcinfo, NULL, NUM_EXTENDED_STATS_ARGS,
+	InitFunctionCallInfoData(*positional_fcinfo, NULL, EXTARG_NUM_EXTARGS,
 							 InvalidOid, NULL, NULL);
 
 	if (!stats_fill_fcinfo_from_arg_pairs(fcinfo, positional_fcinfo, extarginfo))
@@ -1769,18 +1769,18 @@ pg_clear_extended_stats(PG_FUNCTION_ARGS)
 	Oid			locked_table = InvalidOid;
 
 	/* relation arguments */
-	stats_check_required_arg(fcinfo, extarginfo, RELSCHEMA_ARG);
-	relnspname = TextDatumGetCString(PG_GETARG_DATUM(RELSCHEMA_ARG));
-	stats_check_required_arg(fcinfo, extarginfo, RELNAME_ARG);
-	relname = TextDatumGetCString(PG_GETARG_DATUM(RELNAME_ARG));
+	stats_check_required_arg(fcinfo, extarginfo, EXTARG_RELSCHEMA);
+	relnspname = TextDatumGetCString(PG_GETARG_DATUM(EXTARG_RELSCHEMA));
+	stats_check_required_arg(fcinfo, extarginfo, EXTARG_RELNAME);
+	relname = TextDatumGetCString(PG_GETARG_DATUM(EXTARG_RELNAME));
 
 	/* extended statistics arguments */
-	stats_check_required_arg(fcinfo, extarginfo, STATSCHEMA_ARG);
-	nspname = TextDatumGetCString(PG_GETARG_DATUM(STATSCHEMA_ARG));
-	stats_check_required_arg(fcinfo, extarginfo, STATNAME_ARG);
-	stxname = TextDatumGetCString(PG_GETARG_DATUM(STATNAME_ARG));
-	stats_check_required_arg(fcinfo, extarginfo, INHERITED_ARG);
-	inherited = PG_GETARG_BOOL(INHERITED_ARG);
+	stats_check_required_arg(fcinfo, extarginfo, EXTARG_STATSCHEMA);
+	nspname = TextDatumGetCString(PG_GETARG_DATUM(EXTARG_STATSCHEMA));
+	stats_check_required_arg(fcinfo, extarginfo, EXTARG_STATNAME);
+	stxname = TextDatumGetCString(PG_GETARG_DATUM(EXTARG_STATNAME));
+	stats_check_required_arg(fcinfo, extarginfo, EXTARG_INHERITED);
+	inherited = PG_GETARG_BOOL(EXTARG_INHERITED);
 
 	if (RecoveryInProgress())
 	{
-- 
2.50.1 (Apple Git-155)

