From aca8c2042a2113b16e29b3d75859e479811505a0 Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <lic@highgo.com>
Date: Wed, 3 Dec 2025 08:44:46 +0800
Subject: [PATCH v8 10/12] cleanup: avoid local variables shadowed by globals
 across time-related modules

This commit renames several local variables in date/time and timezone
code that were shadowed by global identifiers of the same names. The
updated local identifiers ensure clearer separation of scope throughout
the affected modules.

A few additional shadowing fixes in the same code areas are included as
well. These are unrelated to the conn renaming but occur in the same
files, so they are bundled here to keep the commit self-contained.

Author: Chao Li <lic@highgo.com>
Discussion: https://postgr.es/m/CAEoWx2kQ2x5gMaj8tHLJ3=jfC+p5YXHkJyHrDTiQw2nn2FJTmQ@mail.gmail.com
---
 src/backend/utils/adt/date.c       | 20 +++----
 src/backend/utils/adt/datetime.c   | 20 +++----
 src/backend/utils/adt/formatting.c |  8 +--
 src/backend/utils/adt/timestamp.c  | 92 +++++++++++++++---------------
 src/bin/initdb/findtimezone.c      | 38 ++++++------
 src/include/pgtime.h               |  2 +-
 src/include/utils/datetime.h       |  4 +-
 src/timezone/pgtz.c                | 16 +++---
 8 files changed, 100 insertions(+), 100 deletions(-)

diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index c3327440380..2534dba55bb 100644
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -562,16 +562,16 @@ Datum
 date_pli(PG_FUNCTION_ARGS)
 {
 	DateADT		dateVal = PG_GETARG_DATEADT(0);
-	int32		days = PG_GETARG_INT32(1);
+	int32		dayVal = PG_GETARG_INT32(1);
 	DateADT		result;
 
 	if (DATE_NOT_FINITE(dateVal))
 		PG_RETURN_DATEADT(dateVal); /* can't change infinity */
 
-	result = dateVal + days;
+	result = dateVal + dayVal;
 
 	/* Check for integer overflow and out-of-allowed-range */
-	if ((days >= 0 ? (result < dateVal) : (result > dateVal)) ||
+	if ((dayVal >= 0 ? (result < dateVal) : (result > dateVal)) ||
 		!IS_VALID_DATE(result))
 		ereport(ERROR,
 				(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
@@ -586,16 +586,16 @@ Datum
 date_mii(PG_FUNCTION_ARGS)
 {
 	DateADT		dateVal = PG_GETARG_DATEADT(0);
-	int32		days = PG_GETARG_INT32(1);
+	int32		dayVal = PG_GETARG_INT32(1);
 	DateADT		result;
 
 	if (DATE_NOT_FINITE(dateVal))
 		PG_RETURN_DATEADT(dateVal); /* can't change infinity */
 
-	result = dateVal - days;
+	result = dateVal - dayVal;
 
 	/* Check for integer overflow and out-of-allowed-range */
-	if ((days >= 0 ? (result > dateVal) : (result < dateVal)) ||
+	if ((dayVal >= 0 ? (result > dateVal) : (result < dateVal)) ||
 		!IS_VALID_DATE(result))
 		ereport(ERROR,
 				(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
@@ -3152,7 +3152,7 @@ timetz_zone(PG_FUNCTION_ARGS)
 	TimeTzADT  *t = PG_GETARG_TIMETZADT_P(1);
 	TimeTzADT  *result;
 	int			tz;
-	char		tzname[TZ_STRLEN_MAX + 1];
+	char		tz_name[TZ_STRLEN_MAX + 1];
 	int			type,
 				val;
 	pg_tz	   *tzp;
@@ -3160,9 +3160,9 @@ timetz_zone(PG_FUNCTION_ARGS)
 	/*
 	 * Look up the requested timezone.
 	 */
-	text_to_cstring_buffer(zone, tzname, sizeof(tzname));
+	text_to_cstring_buffer(zone, tz_name, sizeof(tz_name));
 
-	type = DecodeTimezoneName(tzname, &val, &tzp);
+	type = DecodeTimezoneName(tz_name, &val, &tzp);
 
 	if (type == TZNAME_FIXED_OFFSET)
 	{
@@ -3175,7 +3175,7 @@ timetz_zone(PG_FUNCTION_ARGS)
 		TimestampTz now = GetCurrentTransactionStartTimestamp();
 		int			isdst;
 
-		tz = DetermineTimeZoneAbbrevOffsetTS(now, tzname, tzp, &isdst);
+		tz = DetermineTimeZoneAbbrevOffsetTS(now, tz_name, tzp, &isdst);
 	}
 	else
 	{
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 8f25c15fcfc..072eda02900 100644
--- a/src/backend/utils/adt/datetime.c
+++ b/src/backend/utils/adt/datetime.c
@@ -643,12 +643,12 @@ AdjustMicroseconds(int64 val, double fval, int64 scale,
 static bool
 AdjustDays(int64 val, int scale, struct pg_itm_in *itm_in)
 {
-	int			days;
+	int			dayVal;
 
 	if (val < INT_MIN || val > INT_MAX)
 		return false;
-	return !pg_mul_s32_overflow((int32) val, scale, &days) &&
-		!pg_add_s32_overflow(itm_in->tm_mday, days, &itm_in->tm_mday);
+	return !pg_mul_s32_overflow((int32) val, scale, &dayVal) &&
+		!pg_add_s32_overflow(itm_in->tm_mday, dayVal, &itm_in->tm_mday);
 }
 
 /*
@@ -3286,7 +3286,7 @@ DecodeSpecial(int field, const char *lowtoken, int *val)
  * the zone name or the abbreviation's underlying zone.
  */
 int
-DecodeTimezoneName(const char *tzname, int *offset, pg_tz **tz)
+DecodeTimezoneName(const char *tz_name, int *offset, pg_tz **tz)
 {
 	char	   *lowzone;
 	int			dterr,
@@ -3303,8 +3303,8 @@ DecodeTimezoneName(const char *tzname, int *offset, pg_tz **tz)
 	 */
 
 	/* DecodeTimezoneAbbrev requires lowercase input */
-	lowzone = downcase_truncate_identifier(tzname,
-										   strlen(tzname),
+	lowzone = downcase_truncate_identifier(tz_name,
+										   strlen(tz_name),
 										   false);
 
 	dterr = DecodeTimezoneAbbrev(0, lowzone, &type, offset, tz, &extra);
@@ -3324,11 +3324,11 @@ DecodeTimezoneName(const char *tzname, int *offset, pg_tz **tz)
 	else
 	{
 		/* try it as a full zone name */
-		*tz = pg_tzset(tzname);
+		*tz = pg_tzset(tz_name);
 		if (*tz == NULL)
 			ereport(ERROR,
 					(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-					 errmsg("time zone \"%s\" not recognized", tzname)));
+					 errmsg("time zone \"%s\" not recognized", tz_name)));
 		return TZNAME_ZONE;
 	}
 }
@@ -3341,12 +3341,12 @@ DecodeTimezoneName(const char *tzname, int *offset, pg_tz **tz)
  * result in all cases.
  */
 pg_tz *
-DecodeTimezoneNameToTz(const char *tzname)
+DecodeTimezoneNameToTz(const char *tz_name)
 {
 	pg_tz	   *result;
 	int			offset;
 
-	if (DecodeTimezoneName(tzname, &offset, &result) == TZNAME_FIXED_OFFSET)
+	if (DecodeTimezoneName(tz_name, &offset, &result) == TZNAME_FIXED_OFFSET)
 	{
 		/* fixed-offset abbreviation, get a pg_tz descriptor for that */
 		result = pg_tzset_offset(-offset);	/* flip to POSIX sign convention */
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index 0716aff22b6..1c0e5566301 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -3034,12 +3034,12 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
 				else
 				{
 					int			mon = 0;
-					const char *const *months;
+					const char *const *pmonths;
 
 					if (n->key->id == DCH_RM)
-						months = rm_months_upper;
+						pmonths = rm_months_upper;
 					else
-						months = rm_months_lower;
+						pmonths = rm_months_lower;
 
 					/*
 					 * Compute the position in the roman-numeral array.  Note
@@ -3074,7 +3074,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
 					}
 
 					sprintf(s, "%*s", IS_SUFFIX_FM(n->suffix) ? 0 : -4,
-							months[mon]);
+							pmonths[mon]);
 					s += strlen(s);
 				}
 				break;
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index 288d696be77..0cd37997014 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -482,11 +482,11 @@ timestamptz_in(PG_FUNCTION_ARGS)
 static int
 parse_sane_timezone(struct pg_tm *tm, text *zone)
 {
-	char		tzname[TZ_STRLEN_MAX + 1];
+	char		tz_name[TZ_STRLEN_MAX + 1];
 	int			dterr;
 	int			tz;
 
-	text_to_cstring_buffer(zone, tzname, sizeof(tzname));
+	text_to_cstring_buffer(zone, tz_name, sizeof(tz_name));
 
 	/*
 	 * Look up the requested timezone.  First we try to interpret it as a
@@ -498,14 +498,14 @@ parse_sane_timezone(struct pg_tm *tm, text *zone)
 	 * as invalid, it's enough to disallow having a digit in the first
 	 * position of our input string.
 	 */
-	if (isdigit((unsigned char) *tzname))
+	if (isdigit((unsigned char) *tz_name))
 		ereport(ERROR,
 				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 				 errmsg("invalid input syntax for type %s: \"%s\"",
-						"numeric time zone", tzname),
+						"numeric time zone", tz_name),
 				 errhint("Numeric time zones must have \"-\" or \"+\" as first character.")));
 
-	dterr = DecodeTimezone(tzname, &tz);
+	dterr = DecodeTimezone(tz_name, &tz);
 	if (dterr != 0)
 	{
 		int			type,
@@ -515,13 +515,13 @@ parse_sane_timezone(struct pg_tm *tm, text *zone)
 		if (dterr == DTERR_TZDISP_OVERFLOW)
 			ereport(ERROR,
 					(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-					 errmsg("numeric time zone \"%s\" out of range", tzname)));
+					 errmsg("numeric time zone \"%s\" out of range", tz_name)));
 		else if (dterr != DTERR_BAD_FORMAT)
 			ereport(ERROR,
 					(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-					 errmsg("time zone \"%s\" not recognized", tzname)));
+					 errmsg("time zone \"%s\" not recognized", tz_name)));
 
-		type = DecodeTimezoneName(tzname, &val, &tzp);
+		type = DecodeTimezoneName(tz_name, &val, &tzp);
 
 		if (type == TZNAME_FIXED_OFFSET)
 		{
@@ -531,7 +531,7 @@ parse_sane_timezone(struct pg_tm *tm, text *zone)
 		else if (type == TZNAME_DYNTZ)
 		{
 			/* dynamic-offset abbreviation, resolve using specified time */
-			tz = DetermineTimeZoneAbbrevOffset(tm, tzname, tzp);
+			tz = DetermineTimeZoneAbbrevOffset(tm, tz_name, tzp);
 		}
 		else
 		{
@@ -551,11 +551,11 @@ parse_sane_timezone(struct pg_tm *tm, text *zone)
 static pg_tz *
 lookup_timezone(text *zone)
 {
-	char		tzname[TZ_STRLEN_MAX + 1];
+	char		tz_name[TZ_STRLEN_MAX + 1];
 
-	text_to_cstring_buffer(zone, tzname, sizeof(tzname));
+	text_to_cstring_buffer(zone, tz_name, sizeof(tz_name));
 
-	return DecodeTimezoneNameToTz(tzname);
+	return DecodeTimezoneNameToTz(tz_name);
 }
 
 /*
@@ -1523,41 +1523,41 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod,
 Datum
 make_interval(PG_FUNCTION_ARGS)
 {
-	int32		years = PG_GETARG_INT32(0);
-	int32		months = PG_GETARG_INT32(1);
-	int32		weeks = PG_GETARG_INT32(2);
-	int32		days = PG_GETARG_INT32(3);
-	int32		hours = PG_GETARG_INT32(4);
-	int32		mins = PG_GETARG_INT32(5);
-	double		secs = PG_GETARG_FLOAT8(6);
+	int32		yearVal = PG_GETARG_INT32(0);
+	int32		monthVal = PG_GETARG_INT32(1);
+	int32		weekVal = PG_GETARG_INT32(2);
+	int32		dayVal = PG_GETARG_INT32(3);
+	int32		hourVal = PG_GETARG_INT32(4);
+	int32		minVal = PG_GETARG_INT32(5);
+	double		secVal = PG_GETARG_FLOAT8(6);
 	Interval   *result;
 
 	/*
 	 * Reject out-of-range inputs.  We reject any input values that cause
 	 * integer overflow of the corresponding interval fields.
 	 */
-	if (isinf(secs) || isnan(secs))
+	if (isinf(secVal) || isnan(secVal))
 		goto out_of_range;
 
 	result = palloc_object(Interval);
 
 	/* years and months -> months */
-	if (pg_mul_s32_overflow(years, MONTHS_PER_YEAR, &result->month) ||
-		pg_add_s32_overflow(result->month, months, &result->month))
+	if (pg_mul_s32_overflow(yearVal, MONTHS_PER_YEAR, &result->month) ||
+		pg_add_s32_overflow(result->month, monthVal, &result->month))
 		goto out_of_range;
 
 	/* weeks and days -> days */
-	if (pg_mul_s32_overflow(weeks, DAYS_PER_WEEK, &result->day) ||
-		pg_add_s32_overflow(result->day, days, &result->day))
+	if (pg_mul_s32_overflow(weekVal, DAYS_PER_WEEK, &result->day) ||
+		pg_add_s32_overflow(result->day, dayVal, &result->day))
 		goto out_of_range;
 
 	/* hours and mins -> usecs (cannot overflow 64-bit) */
-	result->time = hours * USECS_PER_HOUR + mins * USECS_PER_MINUTE;
+	result->time = hourVal * USECS_PER_HOUR + minVal * USECS_PER_MINUTE;
 
 	/* secs -> usecs */
-	secs = rint(float8_mul(secs, USECS_PER_SEC));
-	if (!FLOAT8_FITS_IN_INT64(secs) ||
-		pg_add_s64_overflow(result->time, (int64) secs, &result->time))
+	secVal = rint(float8_mul(secVal, USECS_PER_SEC));
+	if (!FLOAT8_FITS_IN_INT64(secVal) ||
+		pg_add_s64_overflow(result->time, (int64) secVal, &result->time))
 		goto out_of_range;
 
 	/* make sure that the result is finite */
@@ -2125,9 +2125,9 @@ time2t(const int hour, const int min, const int sec, const fsec_t fsec)
 }
 
 static Timestamp
-dt2local(Timestamp dt, int timezone)
+dt2local(Timestamp dt, int tz)
 {
-	dt -= (timezone * USECS_PER_SEC);
+	dt -= (tz * USECS_PER_SEC);
 	return dt;
 }
 
@@ -2518,20 +2518,20 @@ static inline INT128
 interval_cmp_value(const Interval *interval)
 {
 	INT128		span;
-	int64		days;
+	int64		dayVal;
 
 	/*
 	 * Combine the month and day fields into an integral number of days.
 	 * Because the inputs are int32, int64 arithmetic suffices here.
 	 */
-	days = interval->month * INT64CONST(30);
-	days += interval->day;
+	dayVal = interval->month * INT64CONST(30);
+	dayVal += interval->day;
 
 	/* Widen time field to 128 bits */
 	span = int64_to_int128(interval->time);
 
 	/* Scale up days to microseconds, forming a 128-bit product */
-	int128_add_int64_mul_int64(&span, days, USECS_PER_DAY);
+	int128_add_int64_mul_int64(&span, dayVal, USECS_PER_DAY);
 
 	return span;
 }
@@ -6216,7 +6216,7 @@ interval_part_common(PG_FUNCTION_ARGS, bool retnumeric)
 		{
 			Numeric		result;
 			int64		secs_from_day_month;
-			int64		val;
+			int64		value;
 
 			/*
 			 * To do this calculation in integer arithmetic even though
@@ -6239,9 +6239,9 @@ interval_part_common(PG_FUNCTION_ARGS, bool retnumeric)
 			 * numeric (slower).  This overflow happens around 10^9 days, so
 			 * not common in practice.
 			 */
-			if (!pg_mul_s64_overflow(secs_from_day_month, 1000000, &val) &&
-				!pg_add_s64_overflow(val, interval->time, &val))
-				result = int64_div_fast_to_numeric(val, 6);
+			if (!pg_mul_s64_overflow(secs_from_day_month, 1000000, &value) &&
+				!pg_add_s64_overflow(value, interval->time, &value))
+				result = int64_div_fast_to_numeric(value, 6);
 			else
 				result =
 					numeric_add_safe(int64_div_fast_to_numeric(interval->time, 6),
@@ -6305,7 +6305,7 @@ timestamp_zone(PG_FUNCTION_ARGS)
 	Timestamp	timestamp = PG_GETARG_TIMESTAMP(1);
 	TimestampTz result;
 	int			tz;
-	char		tzname[TZ_STRLEN_MAX + 1];
+	char		tz_name[TZ_STRLEN_MAX + 1];
 	int			type,
 				val;
 	pg_tz	   *tzp;
@@ -6318,9 +6318,9 @@ timestamp_zone(PG_FUNCTION_ARGS)
 	/*
 	 * Look up the requested timezone.
 	 */
-	text_to_cstring_buffer(zone, tzname, sizeof(tzname));
+	text_to_cstring_buffer(zone, tz_name, sizeof(tz_name));
 
-	type = DecodeTimezoneName(tzname, &val, &tzp);
+	type = DecodeTimezoneName(tz_name, &val, &tzp);
 
 	if (type == TZNAME_FIXED_OFFSET)
 	{
@@ -6335,7 +6335,7 @@ timestamp_zone(PG_FUNCTION_ARGS)
 			ereport(ERROR,
 					(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
 					 errmsg("timestamp out of range")));
-		tz = -DetermineTimeZoneAbbrevOffset(&tm, tzname, tzp);
+		tz = -DetermineTimeZoneAbbrevOffset(&tm, tz_name, tzp);
 		result = dt2local(timestamp, tz);
 	}
 	else
@@ -6570,7 +6570,7 @@ timestamptz_zone(PG_FUNCTION_ARGS)
 	TimestampTz timestamp = PG_GETARG_TIMESTAMPTZ(1);
 	Timestamp	result;
 	int			tz;
-	char		tzname[TZ_STRLEN_MAX + 1];
+	char		tz_name[TZ_STRLEN_MAX + 1];
 	int			type,
 				val;
 	pg_tz	   *tzp;
@@ -6581,9 +6581,9 @@ timestamptz_zone(PG_FUNCTION_ARGS)
 	/*
 	 * Look up the requested timezone.
 	 */
-	text_to_cstring_buffer(zone, tzname, sizeof(tzname));
+	text_to_cstring_buffer(zone, tz_name, sizeof(tz_name));
 
-	type = DecodeTimezoneName(tzname, &val, &tzp);
+	type = DecodeTimezoneName(tz_name, &val, &tzp);
 
 	if (type == TZNAME_FIXED_OFFSET)
 	{
@@ -6596,7 +6596,7 @@ timestamptz_zone(PG_FUNCTION_ARGS)
 		/* dynamic-offset abbreviation, resolve using specified time */
 		int			isdst;
 
-		tz = DetermineTimeZoneAbbrevOffsetTS(timestamp, tzname, tzp, &isdst);
+		tz = DetermineTimeZoneAbbrevOffsetTS(timestamp, tz_name, tzp, &isdst);
 		result = dt2local(timestamp, tz);
 	}
 	else
diff --git a/src/bin/initdb/findtimezone.c b/src/bin/initdb/findtimezone.c
index 910b97a570b..1c45a4ecd38 100644
--- a/src/bin/initdb/findtimezone.c
+++ b/src/bin/initdb/findtimezone.c
@@ -231,7 +231,7 @@ compare_tm(struct tm *s, struct pg_tm *p)
  * test time.
  */
 static int
-score_timezone(const char *tzname, struct tztry *tt)
+score_timezone(const char *tz_name, struct tztry *tt)
 {
 	int			i;
 	pg_time_t	pgtt;
@@ -241,7 +241,7 @@ score_timezone(const char *tzname, struct tztry *tt)
 	pg_tz	   *tz;
 
 	/* Load timezone definition */
-	tz = pg_load_tz(tzname);
+	tz = pg_load_tz(tz_name);
 	if (!tz)
 		return -1;				/* unrecognized zone name */
 
@@ -249,7 +249,7 @@ score_timezone(const char *tzname, struct tztry *tt)
 	if (!pg_tz_acceptable(tz))
 	{
 #ifdef DEBUG_IDENTIFY_TIMEZONE
-		fprintf(stderr, "Reject TZ \"%s\": uses leap seconds\n", tzname);
+		fprintf(stderr, "Reject TZ \"%s\": uses leap seconds\n", tz_name);
 #endif
 		return -1;
 	}
@@ -266,7 +266,7 @@ score_timezone(const char *tzname, struct tztry *tt)
 		{
 #ifdef DEBUG_IDENTIFY_TIMEZONE
 			fprintf(stderr, "TZ \"%s\" scores %d: at %ld %04d-%02d-%02d %02d:%02d:%02d %s, system had no data\n",
-					tzname, i, (long) pgtt,
+					tz_name, i, (long) pgtt,
 					pgtm->tm_year + 1900, pgtm->tm_mon + 1, pgtm->tm_mday,
 					pgtm->tm_hour, pgtm->tm_min, pgtm->tm_sec,
 					pgtm->tm_isdst ? "dst" : "std");
@@ -277,7 +277,7 @@ score_timezone(const char *tzname, struct tztry *tt)
 		{
 #ifdef DEBUG_IDENTIFY_TIMEZONE
 			fprintf(stderr, "TZ \"%s\" scores %d: at %ld %04d-%02d-%02d %02d:%02d:%02d %s versus %04d-%02d-%02d %02d:%02d:%02d %s\n",
-					tzname, i, (long) pgtt,
+					tz_name, i, (long) pgtt,
 					pgtm->tm_year + 1900, pgtm->tm_mon + 1, pgtm->tm_mday,
 					pgtm->tm_hour, pgtm->tm_min, pgtm->tm_sec,
 					pgtm->tm_isdst ? "dst" : "std",
@@ -298,7 +298,7 @@ score_timezone(const char *tzname, struct tztry *tt)
 			{
 #ifdef DEBUG_IDENTIFY_TIMEZONE
 				fprintf(stderr, "TZ \"%s\" scores %d: at %ld \"%s\" versus \"%s\"\n",
-						tzname, i, (long) pgtt,
+						tz_name, i, (long) pgtt,
 						pgtm->tm_zone, cbuf);
 #endif
 				return i;
@@ -307,7 +307,7 @@ score_timezone(const char *tzname, struct tztry *tt)
 	}
 
 #ifdef DEBUG_IDENTIFY_TIMEZONE
-	fprintf(stderr, "TZ \"%s\" gets max score %d\n", tzname, i);
+	fprintf(stderr, "TZ \"%s\" gets max score %d\n", tz_name, i);
 #endif
 
 	return i;
@@ -317,9 +317,9 @@ score_timezone(const char *tzname, struct tztry *tt)
  * Test whether given zone name is a perfect match to localtime() behavior
  */
 static bool
-perfect_timezone_match(const char *tzname, struct tztry *tt)
+perfect_timezone_match(const char *tz_name, struct tztry *tt)
 {
-	return (score_timezone(tzname, tt) == tt->n_test_times);
+	return (score_timezone(tz_name, tt) == tt->n_test_times);
 }
 
 
@@ -1725,14 +1725,14 @@ identify_system_timezone(void)
  * Return true if the given zone name is valid and is an "acceptable" zone.
  */
 static bool
-validate_zone(const char *tzname)
+validate_zone(const char *zone)
 {
 	pg_tz	   *tz;
 
-	if (!tzname || !tzname[0])
+	if (!zone || !zone[0])
 		return false;
 
-	tz = pg_load_tz(tzname);
+	tz = pg_load_tz(zone);
 	if (!tz)
 		return false;
 
@@ -1756,7 +1756,7 @@ validate_zone(const char *tzname)
 const char *
 select_default_timezone(const char *share_path)
 {
-	const char *tzname;
+	const char *tz;
 
 	/* Initialize timezone directory path, if needed */
 #ifndef SYSTEMTZDIR
@@ -1764,14 +1764,14 @@ select_default_timezone(const char *share_path)
 #endif
 
 	/* Check TZ environment variable */
-	tzname = getenv("TZ");
-	if (validate_zone(tzname))
-		return tzname;
+	tz = getenv("TZ");
+	if (validate_zone(tz))
+		return tz;
 
 	/* Nope, so try to identify the system timezone */
-	tzname = identify_system_timezone();
-	if (validate_zone(tzname))
-		return tzname;
+	tz = identify_system_timezone();
+	if (validate_zone(tz))
+		return tz;
 
 	return NULL;
 }
diff --git a/src/include/pgtime.h b/src/include/pgtime.h
index ba6705f71bd..458b4300a63 100644
--- a/src/include/pgtime.h
+++ b/src/include/pgtime.h
@@ -91,7 +91,7 @@ extern PGDLLIMPORT pg_tz *session_timezone;
 extern PGDLLIMPORT pg_tz *log_timezone;
 
 extern void pg_timezone_initialize(void);
-extern pg_tz *pg_tzset(const char *tzname);
+extern pg_tz *pg_tzset(const char *zone);
 extern pg_tz *pg_tzset_offset(long gmtoffset);
 
 extern pg_tzenum *pg_tzenumerate_start(void);
diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h
index f77c6acd8b6..abdaaaccb45 100644
--- a/src/include/utils/datetime.h
+++ b/src/include/utils/datetime.h
@@ -345,8 +345,8 @@ extern int	DecodeTimezoneAbbrev(int field, const char *lowtoken,
 extern int	DecodeSpecial(int field, const char *lowtoken, int *val);
 extern int	DecodeUnits(int field, const char *lowtoken, int *val);
 
-extern int	DecodeTimezoneName(const char *tzname, int *offset, pg_tz **tz);
-extern pg_tz *DecodeTimezoneNameToTz(const char *tzname);
+extern int	DecodeTimezoneName(const char *tz_name, int *offset, pg_tz **tz);
+extern pg_tz *DecodeTimezoneNameToTz(const char *tz_name);
 
 extern int	DecodeTimezoneAbbrevPrefix(const char *str,
 									   int *offset, pg_tz **tz);
diff --git a/src/timezone/pgtz.c b/src/timezone/pgtz.c
index eac988c21e7..72f41ea42d8 100644
--- a/src/timezone/pgtz.c
+++ b/src/timezone/pgtz.c
@@ -231,7 +231,7 @@ init_timezone_hashtable(void)
  * default timezone setting is later overridden from postgresql.conf.
  */
 pg_tz *
-pg_tzset(const char *tzname)
+pg_tzset(const char *zone)
 {
 	pg_tz_cache *tzp;
 	struct state tzstate;
@@ -239,7 +239,7 @@ pg_tzset(const char *tzname)
 	char		canonname[TZ_STRLEN_MAX + 1];
 	char	   *p;
 
-	if (strlen(tzname) > TZ_STRLEN_MAX)
+	if (strlen(zone) > TZ_STRLEN_MAX)
 		return NULL;			/* not going to fit */
 
 	if (!timezone_cache)
@@ -253,8 +253,8 @@ pg_tzset(const char *tzname)
 	 * a POSIX-style timezone spec.)
 	 */
 	p = uppername;
-	while (*tzname)
-		*p++ = pg_toupper((unsigned char) *tzname++);
+	while (*zone)
+		*p++ = pg_toupper((unsigned char) *zone++);
 	*p = '\0';
 
 	tzp = (pg_tz_cache *) hash_search(timezone_cache,
@@ -321,7 +321,7 @@ pg_tzset_offset(long gmtoffset)
 {
 	long		absoffset = (gmtoffset < 0) ? -gmtoffset : gmtoffset;
 	char		offsetstr[64];
-	char		tzname[128];
+	char		zone[128];
 
 	snprintf(offsetstr, sizeof(offsetstr),
 			 "%02ld", absoffset / SECS_PER_HOUR);
@@ -338,13 +338,13 @@ pg_tzset_offset(long gmtoffset)
 					 ":%02ld", absoffset);
 	}
 	if (gmtoffset > 0)
-		snprintf(tzname, sizeof(tzname), "<-%s>+%s",
+		snprintf(zone, sizeof(zone), "<-%s>+%s",
 				 offsetstr, offsetstr);
 	else
-		snprintf(tzname, sizeof(tzname), "<+%s>-%s",
+		snprintf(zone, sizeof(zone), "<+%s>-%s",
 				 offsetstr, offsetstr);
 
-	return pg_tzset(tzname);
+	return pg_tzset(zone);
 }
 
 
-- 
2.50.1 (Apple Git-155)

