public inbox for [email protected]
help / color / mirror / Atom feedFrom: Chao Li <[email protected]>
To: Postgres hackers <[email protected]>
Subject: Cleanup shadows variable warnings, round 1
Date: Fri, 28 Nov 2025 16:16:59 +0800
Message-ID: <CAEoWx2kQ2x5gMaj8tHLJ3=jfC+p5YXHkJyHrDTiQw2nn2FJTmQ@mail.gmail.com> (raw)
Hi Hackers,
While reviewing [1], it makes me recall an experience where I had a patch
ready locally, but CommitFest CI failed with a shadows-variable warning.
Now I understand that -Wall doesn't by default enable -Wshadows with some
compilers like clang.
I did a clean build with manually enabling -Wshadow and surprisingly found
there are a lot of such warnings in the current code base, roughly ~200
occurrences.
As there are too many, I plan to fix them all in 3-4 rounds. For round 1
patch, I'd see any objection, then decide if to proceed more rounds.
[1] https://postgr.es/m/CAHut+PsF8R0Bt4J3c92+T2F0mun0rRfK=-
[email protected]
Best regards,
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/
Attachments:
[application/octet-stream] v1-0001-Cleanup-shadows-variable-warnings-round-1.patch (55.0K, 3-v1-0001-Cleanup-shadows-variable-warnings-round-1.patch)
download | inline diff:
From 38b3ca4610fae4dc222e2aa10dc5d065163722f8 Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <[email protected]>
Date: Fri, 28 Nov 2025 16:04:40 +0800
Subject: [PATCH v1] Cleanup shadows variable warnings, round 1
Author: Chao Li <[email protected]>
---
src/backend/access/brin/brin.c | 8 +--
src/backend/access/gist/gistbuild.c | 10 +--
src/backend/access/rmgrdesc/xlogdesc.c | 12 ++--
src/backend/access/transam/xlogrecovery.c | 74 ++++++++++-----------
src/backend/backup/basebackup_incremental.c | 5 +-
src/backend/bootstrap/bootstrap.c | 8 +--
src/backend/catalog/objectaddress.c | 18 ++---
src/backend/catalog/pg_constraint.c | 32 ++++-----
src/backend/commands/extension.c | 6 +-
src/backend/commands/schemacmds.c | 4 +-
src/backend/commands/statscmds.c | 6 +-
src/backend/commands/tablecmds.c | 28 ++++----
src/backend/commands/trigger.c | 14 ++--
src/backend/commands/wait.c | 12 ++--
src/backend/executor/execExprInterp.c | 6 +-
src/backend/executor/nodeAgg.c | 16 ++---
src/backend/executor/nodeValuesscan.c | 4 +-
src/backend/libpq/be-secure-common.c | 12 ++--
src/backend/main/main.c | 14 ++--
src/backend/optimizer/path/equivclass.c | 10 +--
src/backend/optimizer/plan/createplan.c | 44 ++++++------
src/backend/parser/parse_target.c | 10 ++-
src/backend/partitioning/partdesc.c | 6 +-
src/backend/statistics/dependencies.c | 26 ++++----
src/backend/statistics/extended_stats.c | 8 +--
src/backend/storage/aio/read_stream.c | 14 ++--
src/backend/storage/buffer/bufmgr.c | 6 +-
src/backend/utils/adt/date.c | 18 ++---
src/backend/utils/adt/datetime.c | 20 +++---
src/backend/utils/adt/formatting.c | 8 +--
src/common/controldata_utils.c | 8 +--
src/timezone/pgtz.c | 16 ++---
32 files changed, 240 insertions(+), 243 deletions(-)
diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c
index cb3331921cb..0aee0c013ff 100644
--- a/src/backend/access/brin/brin.c
+++ b/src/backend/access/brin/brin.c
@@ -694,15 +694,15 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
*/
if (consistentFn[keyattno - 1].fn_oid == InvalidOid)
{
- FmgrInfo *tmp;
+ FmgrInfo *tmpfi;
/* First time we see this attribute, so no key/null keys. */
Assert(nkeys[keyattno - 1] == 0);
Assert(nnullkeys[keyattno - 1] == 0);
- tmp = index_getprocinfo(idxRel, keyattno,
- BRIN_PROCNUM_CONSISTENT);
- fmgr_info_copy(&consistentFn[keyattno - 1], tmp,
+ tmpfi = index_getprocinfo(idxRel, keyattno,
+ BRIN_PROCNUM_CONSISTENT);
+ fmgr_info_copy(&consistentFn[keyattno - 1], tmpfi,
CurrentMemoryContext);
}
diff --git a/src/backend/access/gist/gistbuild.c b/src/backend/access/gist/gistbuild.c
index be0fd5b753d..7d975652ad3 100644
--- a/src/backend/access/gist/gistbuild.c
+++ b/src/backend/access/gist/gistbuild.c
@@ -1158,7 +1158,7 @@ gistbufferinginserttuples(GISTBuildState *buildstate, Buffer buffer, int level,
i = 0;
foreach(lc, splitinfo)
{
- GISTPageSplitInfo *splitinfo = lfirst(lc);
+ GISTPageSplitInfo *si = lfirst(lc);
/*
* Remember the parent of each new child page in our parent map.
@@ -1169,7 +1169,7 @@ gistbufferinginserttuples(GISTBuildState *buildstate, Buffer buffer, int level,
*/
if (level > 0)
gistMemorizeParent(buildstate,
- BufferGetBlockNumber(splitinfo->buf),
+ BufferGetBlockNumber(si->buf),
BufferGetBlockNumber(parentBuffer));
/*
@@ -1179,14 +1179,14 @@ gistbufferinginserttuples(GISTBuildState *buildstate, Buffer buffer, int level,
* harm).
*/
if (level > 1)
- gistMemorizeAllDownlinks(buildstate, splitinfo->buf);
+ gistMemorizeAllDownlinks(buildstate, si->buf);
/*
* Since there's no concurrent access, we can release the lower
* level buffers immediately. This includes the original page.
*/
- UnlockReleaseBuffer(splitinfo->buf);
- downlinks[i++] = splitinfo->downlink;
+ UnlockReleaseBuffer(si->buf);
+ downlinks[i++] = si->downlink;
}
/* Insert them into parent. */
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index cd6c2a2f650..689e05174ed 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -34,17 +34,17 @@ const struct config_enum_entry wal_level_options[] = {
};
/*
- * Find a string representation for wal_level
+ * Find a string representation for wallevel
*/
static const char *
-get_wal_level_string(int wal_level)
+get_wal_level_string(int wallevel)
{
const struct config_enum_entry *entry;
const char *wal_level_str = "?";
for (entry = wal_level_options; entry->name; entry++)
{
- if (entry->val == wal_level)
+ if (entry->val == wallevel)
{
wal_level_str = entry->name;
break;
@@ -162,10 +162,10 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
}
else if (info == XLOG_CHECKPOINT_REDO)
{
- int wal_level;
+ int wallevel;
- memcpy(&wal_level, rec, sizeof(int));
- appendStringInfo(buf, "wal_level %s", get_wal_level_string(wal_level));
+ memcpy(&wallevel, rec, sizeof(int));
+ appendStringInfo(buf, "wal_level %s", get_wal_level_string(wallevel));
}
}
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 21b8f179ba0..93db9f19590 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -1208,7 +1208,7 @@ validateRecoveryParameters(void)
* Returns true if a backup_label was found (and fills the checkpoint
* location and TLI into *checkPointLoc and *backupLabelTLI, respectively);
* returns false if not. If this backup_label came from a streamed backup,
- * *backupEndRequired is set to true. If this backup_label was created during
+ * *backupEndNeeded is set to true. If this backup_label was created during
* recovery, *backupFromStandby is set to true.
*
* Also sets the global variables RedoStartLSN and RedoStartTLI with the LSN
@@ -1216,7 +1216,7 @@ validateRecoveryParameters(void)
*/
static bool
read_backup_label(XLogRecPtr *checkPointLoc, TimeLineID *backupLabelTLI,
- bool *backupEndRequired, bool *backupFromStandby)
+ bool *backupEndNeeded, bool *backupFromStandby)
{
char startxlogfilename[MAXFNAMELEN];
TimeLineID tli_from_walseg,
@@ -1233,7 +1233,7 @@ read_backup_label(XLogRecPtr *checkPointLoc, TimeLineID *backupLabelTLI,
/* suppress possible uninitialized-variable warnings */
*checkPointLoc = InvalidXLogRecPtr;
*backupLabelTLI = 0;
- *backupEndRequired = false;
+ *backupEndNeeded = false;
*backupFromStandby = false;
/*
@@ -1277,13 +1277,13 @@ read_backup_label(XLogRecPtr *checkPointLoc, TimeLineID *backupLabelTLI,
* other option today being from pg_rewind). If this was a streamed
* backup then we know that we need to play through until we get to the
* end of the WAL which was generated during the backup (at which point we
- * will have reached consistency and backupEndRequired will be reset to be
+ * will have reached consistency and backupEndNeeded will be reset to be
* false).
*/
if (fscanf(lfp, "BACKUP METHOD: %19s\n", backuptype) == 1)
{
if (strcmp(backuptype, "streamed") == 0)
- *backupEndRequired = true;
+ *backupEndNeeded = true;
}
/*
@@ -1927,14 +1927,14 @@ PerformWalRecovery(void)
* Subroutine of PerformWalRecovery, to apply one WAL record.
*/
static void
-ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *replayTLI)
+ApplyWalRecord(XLogReaderState *xlogReader, XLogRecord *record, TimeLineID *replayTLI)
{
ErrorContextCallback errcallback;
bool switchedTLI = false;
/* Setup error traceback support for ereport() */
errcallback.callback = rm_redo_error_callback;
- errcallback.arg = xlogreader;
+ errcallback.arg = xlogReader;
errcallback.previous = error_context_stack;
error_context_stack = &errcallback;
@@ -1961,7 +1961,7 @@ ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *repl
{
CheckPoint checkPoint;
- memcpy(&checkPoint, XLogRecGetData(xlogreader), sizeof(CheckPoint));
+ memcpy(&checkPoint, XLogRecGetData(xlogReader), sizeof(CheckPoint));
newReplayTLI = checkPoint.ThisTimeLineID;
prevReplayTLI = checkPoint.PrevTimeLineID;
}
@@ -1969,7 +1969,7 @@ ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *repl
{
xl_end_of_recovery xlrec;
- memcpy(&xlrec, XLogRecGetData(xlogreader), sizeof(xl_end_of_recovery));
+ memcpy(&xlrec, XLogRecGetData(xlogReader), sizeof(xl_end_of_recovery));
newReplayTLI = xlrec.ThisTimeLineID;
prevReplayTLI = xlrec.PrevTimeLineID;
}
@@ -1977,7 +1977,7 @@ ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *repl
if (newReplayTLI != *replayTLI)
{
/* Check that it's OK to switch to this TLI */
- checkTimeLineSwitch(xlogreader->EndRecPtr,
+ checkTimeLineSwitch(xlogReader->EndRecPtr,
newReplayTLI, prevReplayTLI, *replayTLI);
/* Following WAL records should be run with new TLI */
@@ -3152,19 +3152,19 @@ ConfirmRecoveryPaused(void)
* record is available.
*/
static XLogRecord *
-ReadRecord(XLogPrefetcher *xlogprefetcher, int emode,
+ReadRecord(XLogPrefetcher *xlogPrefetcher, int emode,
bool fetching_ckpt, TimeLineID replayTLI)
{
XLogRecord *record;
- XLogReaderState *xlogreader = XLogPrefetcherGetReader(xlogprefetcher);
- XLogPageReadPrivate *private = (XLogPageReadPrivate *) xlogreader->private_data;
+ XLogReaderState *xlogReader = XLogPrefetcherGetReader(xlogPrefetcher);
+ XLogPageReadPrivate *private = (XLogPageReadPrivate *) xlogReader->private_data;
Assert(AmStartupProcess() || !IsUnderPostmaster);
/* Pass through parameters to XLogPageRead */
private->fetching_ckpt = fetching_ckpt;
private->emode = emode;
- private->randAccess = !XLogRecPtrIsValid(xlogreader->ReadRecPtr);
+ private->randAccess = !XLogRecPtrIsValid(xlogReader->ReadRecPtr);
private->replayTLI = replayTLI;
/* This is the first attempt to read this page. */
@@ -3174,7 +3174,7 @@ ReadRecord(XLogPrefetcher *xlogprefetcher, int emode,
{
char *errormsg;
- record = XLogPrefetcherReadRecord(xlogprefetcher, &errormsg);
+ record = XLogPrefetcherReadRecord(xlogPrefetcher, &errormsg);
if (record == NULL)
{
/*
@@ -3190,10 +3190,10 @@ ReadRecord(XLogPrefetcher *xlogprefetcher, int emode,
* overwrite contrecord in the wrong place, breaking everything.
*/
if (!ArchiveRecoveryRequested &&
- XLogRecPtrIsValid(xlogreader->abortedRecPtr))
+ XLogRecPtrIsValid(xlogReader->abortedRecPtr))
{
- abortedRecPtr = xlogreader->abortedRecPtr;
- missingContrecPtr = xlogreader->missingContrecPtr;
+ abortedRecPtr = xlogReader->abortedRecPtr;
+ missingContrecPtr = xlogReader->missingContrecPtr;
}
if (readFile >= 0)
@@ -3209,29 +3209,29 @@ ReadRecord(XLogPrefetcher *xlogprefetcher, int emode,
* shouldn't loop anymore in that case.
*/
if (errormsg)
- ereport(emode_for_corrupt_record(emode, xlogreader->EndRecPtr),
+ ereport(emode_for_corrupt_record(emode, xlogReader->EndRecPtr),
(errmsg_internal("%s", errormsg) /* already translated */ ));
}
/*
* Check page TLI is one of the expected values.
*/
- else if (!tliInHistory(xlogreader->latestPageTLI, expectedTLEs))
+ else if (!tliInHistory(xlogReader->latestPageTLI, expectedTLEs))
{
char fname[MAXFNAMELEN];
XLogSegNo segno;
int32 offset;
- XLByteToSeg(xlogreader->latestPagePtr, segno, wal_segment_size);
- offset = XLogSegmentOffset(xlogreader->latestPagePtr,
+ XLByteToSeg(xlogReader->latestPagePtr, segno, wal_segment_size);
+ offset = XLogSegmentOffset(xlogReader->latestPagePtr,
wal_segment_size);
- XLogFileName(fname, xlogreader->seg.ws_tli, segno,
+ XLogFileName(fname, xlogReader->seg.ws_tli, segno,
wal_segment_size);
- ereport(emode_for_corrupt_record(emode, xlogreader->EndRecPtr),
+ ereport(emode_for_corrupt_record(emode, xlogReader->EndRecPtr),
errmsg("unexpected timeline ID %u in WAL segment %s, LSN %X/%08X, offset %u",
- xlogreader->latestPageTLI,
+ xlogReader->latestPageTLI,
fname,
- LSN_FORMAT_ARGS(xlogreader->latestPagePtr),
+ LSN_FORMAT_ARGS(xlogReader->latestPagePtr),
offset));
record = NULL;
}
@@ -3267,8 +3267,8 @@ ReadRecord(XLogPrefetcher *xlogprefetcher, int emode,
if (StandbyModeRequested)
EnableStandbyMode();
- SwitchIntoArchiveRecovery(xlogreader->EndRecPtr, replayTLI);
- minRecoveryPoint = xlogreader->EndRecPtr;
+ SwitchIntoArchiveRecovery(xlogReader->EndRecPtr, replayTLI);
+ minRecoveryPoint = xlogReader->EndRecPtr;
minRecoveryPointTLI = replayTLI;
CheckRecoveryConsistency();
@@ -3321,11 +3321,11 @@ ReadRecord(XLogPrefetcher *xlogprefetcher, int emode,
* sleep and retry.
*/
static int
-XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen,
+XLogPageRead(XLogReaderState *xlogReader, XLogRecPtr targetPagePtr, int reqLen,
XLogRecPtr targetRecPtr, char *readBuf)
{
XLogPageReadPrivate *private =
- (XLogPageReadPrivate *) xlogreader->private_data;
+ (XLogPageReadPrivate *) xlogReader->private_data;
int emode = private->emode;
uint32 targetPageOff;
XLogSegNo targetSegNo PG_USED_FOR_ASSERTS_ONLY;
@@ -3372,7 +3372,7 @@ retry:
flushedUpto < targetPagePtr + reqLen))
{
if (readFile >= 0 &&
- xlogreader->nonblocking &&
+ xlogReader->nonblocking &&
readSource == XLOG_FROM_STREAM &&
flushedUpto < targetPagePtr + reqLen)
return XLREAD_WOULDBLOCK;
@@ -3382,8 +3382,8 @@ retry:
private->fetching_ckpt,
targetRecPtr,
private->replayTLI,
- xlogreader->EndRecPtr,
- xlogreader->nonblocking))
+ xlogReader->EndRecPtr,
+ xlogReader->nonblocking))
{
case XLREAD_WOULDBLOCK:
return XLREAD_WOULDBLOCK;
@@ -3467,7 +3467,7 @@ retry:
Assert(targetPageOff == readOff);
Assert(reqLen <= readLen);
- xlogreader->seg.ws_tli = curFileTLI;
+ xlogReader->seg.ws_tli = curFileTLI;
/*
* Check the page header immediately, so that we can retry immediately if
@@ -4104,7 +4104,7 @@ emode_for_corrupt_record(int emode, XLogRecPtr RecPtr)
* Subroutine to try to fetch and validate a prior checkpoint record.
*/
static XLogRecord *
-ReadCheckpointRecord(XLogPrefetcher *xlogprefetcher, XLogRecPtr RecPtr,
+ReadCheckpointRecord(XLogPrefetcher *xlogPrefetcher, XLogRecPtr RecPtr,
TimeLineID replayTLI)
{
XLogRecord *record;
@@ -4119,8 +4119,8 @@ ReadCheckpointRecord(XLogPrefetcher *xlogprefetcher, XLogRecPtr RecPtr,
return NULL;
}
- XLogPrefetcherBeginRead(xlogprefetcher, RecPtr);
- record = ReadRecord(xlogprefetcher, LOG, true, replayTLI);
+ XLogPrefetcherBeginRead(xlogPrefetcher, RecPtr);
+ record = ReadRecord(xlogPrefetcher, LOG, true, replayTLI);
if (record == NULL)
{
diff --git a/src/backend/backup/basebackup_incremental.c b/src/backend/backup/basebackup_incremental.c
index 852ab577045..cb96b8915ec 100644
--- a/src/backend/backup/basebackup_incremental.c
+++ b/src/backend/backup/basebackup_incremental.c
@@ -596,16 +596,15 @@ PrepareForIncrementalBackup(IncrementalBackupInfo *ib,
while (1)
{
unsigned nblocks;
- unsigned i;
nblocks = BlockRefTableReaderGetBlocks(reader, blocks,
BLOCKS_PER_READ);
if (nblocks == 0)
break;
- for (i = 0; i < nblocks; ++i)
+ for (unsigned n = 0; n < nblocks; ++n)
BlockRefTableMarkBlockModified(ib->brtab, &rlocator,
- forknum, blocks[i]);
+ forknum, blocks[n]);
}
}
DestroyBlockRefTableReader(reader);
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index fc8638c1b61..83dc275d1ce 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -200,7 +200,7 @@ void
BootstrapModeMain(int argc, char *argv[], bool check_only)
{
int i;
- char *progname = argv[0];
+ char *progName = argv[0];
int flag;
char *userDoption = NULL;
uint32 bootstrap_data_checksum_version = 0; /* No checksum */
@@ -296,7 +296,7 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
break;
default:
write_stderr("Try \"%s --help\" for more information.\n",
- progname);
+ progName);
proc_exit(1);
break;
}
@@ -304,12 +304,12 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
if (argc != optind)
{
- write_stderr("%s: invalid command-line arguments\n", progname);
+ write_stderr("%s: invalid command-line arguments\n", progName);
proc_exit(1);
}
/* Acquire configuration parameters */
- if (!SelectConfigFiles(userDoption, progname))
+ if (!SelectConfigFiles(userDoption, progName))
proc_exit(1);
/*
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index c75b7131ed7..bbf59418f5f 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -2118,8 +2118,8 @@ pg_get_object_address(PG_FUNCTION_ARGS)
Node *objnode = NULL;
ObjectAddress addr;
TupleDesc tupdesc;
- Datum values[3];
- bool nulls[3];
+ Datum values3[3];
+ bool nulls3[3];
HeapTuple htup;
Relation relation;
@@ -2371,14 +2371,14 @@ pg_get_object_address(PG_FUNCTION_ARGS)
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
elog(ERROR, "return type must be a row type");
- values[0] = ObjectIdGetDatum(addr.classId);
- values[1] = ObjectIdGetDatum(addr.objectId);
- values[2] = Int32GetDatum(addr.objectSubId);
- nulls[0] = false;
- nulls[1] = false;
- nulls[2] = false;
+ values3[0] = ObjectIdGetDatum(addr.classId);
+ values3[1] = ObjectIdGetDatum(addr.objectId);
+ values3[2] = Int32GetDatum(addr.objectSubId);
+ nulls3[0] = false;
+ nulls3[1] = false;
+ nulls3[2] = false;
- htup = heap_form_tuple(tupdesc, values, nulls);
+ htup = heap_form_tuple(tupdesc, values3, nulls3);
PG_RETURN_DATUM(HeapTupleGetDatum(htup));
}
diff --git a/src/backend/catalog/pg_constraint.c b/src/backend/catalog/pg_constraint.c
index 9944e4bd2d1..ee44de9ae86 100644
--- a/src/backend/catalog/pg_constraint.c
+++ b/src/backend/catalog/pg_constraint.c
@@ -844,22 +844,22 @@ RelationGetNotNullConstraints(Oid relid, bool cooked, bool include_noinh)
if (cooked)
{
- CookedConstraint *cooked;
-
- cooked = (CookedConstraint *) palloc(sizeof(CookedConstraint));
-
- cooked->contype = CONSTR_NOTNULL;
- cooked->conoid = conForm->oid;
- cooked->name = pstrdup(NameStr(conForm->conname));
- cooked->attnum = colnum;
- cooked->expr = NULL;
- cooked->is_enforced = true;
- cooked->skip_validation = !conForm->convalidated;
- cooked->is_local = true;
- cooked->inhcount = 0;
- cooked->is_no_inherit = conForm->connoinherit;
-
- notnulls = lappend(notnulls, cooked);
+ CookedConstraint *cc;
+
+ cc = (CookedConstraint *) palloc(sizeof(CookedConstraint));
+
+ cc->contype = CONSTR_NOTNULL;
+ cc->conoid = conForm->oid;
+ cc->name = pstrdup(NameStr(conForm->conname));
+ cc->attnum = colnum;
+ cc->expr = NULL;
+ cc->is_enforced = true;
+ cc->skip_validation = !conForm->convalidated;
+ cc->is_local = true;
+ cc->inhcount = 0;
+ cc->is_no_inherit = conForm->connoinherit;
+
+ notnulls = lappend(notnulls, cc);
}
else
{
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index ebc204c4462..948a939f667 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -1274,8 +1274,8 @@ execute_extension_script(Oid extensionOid, ExtensionControlFile *control,
Datum old = t_sql;
char *reqextname = (char *) lfirst(lc);
Oid reqschema = lfirst_oid(lc2);
- char *schemaName = get_namespace_name(reqschema);
- const char *qSchemaName = quote_identifier(schemaName);
+ char *schemaname = get_namespace_name(reqschema);
+ const char *qSchemaName = quote_identifier(schemaname);
char *repltoken;
repltoken = psprintf("@extschema:%s@", reqextname);
@@ -1284,7 +1284,7 @@ execute_extension_script(Oid extensionOid, ExtensionControlFile *control,
t_sql,
CStringGetTextDatum(repltoken),
CStringGetTextDatum(qSchemaName));
- if (t_sql != old && strpbrk(schemaName, quoting_relevant_chars))
+ if (t_sql != old && strpbrk(schemaname, quoting_relevant_chars))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid character in extension \"%s\" schema: must not contain any of \"%s\"",
diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c
index 3cc1472103a..01a3f98275c 100644
--- a/src/backend/commands/schemacmds.c
+++ b/src/backend/commands/schemacmds.c
@@ -205,14 +205,14 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString,
*/
foreach(parsetree_item, parsetree_list)
{
- Node *stmt = (Node *) lfirst(parsetree_item);
+ Node *pstmt = (Node *) lfirst(parsetree_item);
PlannedStmt *wrapper;
/* need to make a wrapper PlannedStmt */
wrapper = makeNode(PlannedStmt);
wrapper->commandType = CMD_UTILITY;
wrapper->canSetTag = false;
- wrapper->utilityStmt = stmt;
+ wrapper->utilityStmt = pstmt;
wrapper->stmt_location = stmt_location;
wrapper->stmt_len = stmt_len;
wrapper->planOrigin = PLAN_STMT_INTERNAL;
diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c
index 77b1a6e2dc5..9b113839108 100644
--- a/src/backend/commands/statscmds.c
+++ b/src/backend/commands/statscmds.c
@@ -319,15 +319,15 @@ CreateStatistics(CreateStatsStmt *stmt, bool check_rights)
Node *expr = selem->expr;
Oid atttype;
TypeCacheEntry *type;
- Bitmapset *attnums = NULL;
+ Bitmapset *attnumsbms = NULL;
int k;
Assert(expr != NULL);
- pull_varattnos(expr, 1, &attnums);
+ pull_varattnos(expr, 1, &attnumsbms);
k = -1;
- while ((k = bms_next_member(attnums, k)) >= 0)
+ while ((k = bms_next_member(attnumsbms, k)) >= 0)
{
AttrNumber attnum = k + FirstLowInvalidHeapAttributeNumber;
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 23ebaa3f230..348d414a1dd 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -15708,14 +15708,14 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
foreach(lcmd, stmt->cmds)
{
- AlterTableCmd *cmd = lfirst_node(AlterTableCmd, lcmd);
+ AlterTableCmd *c = lfirst_node(AlterTableCmd, lcmd);
- if (cmd->subtype == AT_AddIndex)
+ if (c->subtype == AT_AddIndex)
{
IndexStmt *indstmt;
Oid indoid;
- indstmt = castNode(IndexStmt, cmd->def);
+ indstmt = castNode(IndexStmt, c->def);
indoid = get_constraint_index(oldId);
if (!rewrite)
@@ -15725,9 +15725,9 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
RelationRelationId, 0);
indstmt->reset_default_tblspc = true;
- cmd->subtype = AT_ReAddIndex;
+ c->subtype = AT_ReAddIndex;
tab->subcmds[AT_PASS_OLD_INDEX] =
- lappend(tab->subcmds[AT_PASS_OLD_INDEX], cmd);
+ lappend(tab->subcmds[AT_PASS_OLD_INDEX], c);
/* recreate any comment on the constraint */
RebuildConstraintComment(tab,
@@ -15737,9 +15737,9 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
NIL,
indstmt->idxname);
}
- else if (cmd->subtype == AT_AddConstraint)
+ else if (c->subtype == AT_AddConstraint)
{
- Constraint *con = castNode(Constraint, cmd->def);
+ Constraint *con = castNode(Constraint, c->def);
con->old_pktable_oid = refRelId;
/* rewriting neither side of a FK */
@@ -15747,9 +15747,9 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
!rewrite && tab->rewrite == 0)
TryReuseForeignKey(oldId, con);
con->reset_default_tblspc = true;
- cmd->subtype = AT_ReAddConstraint;
+ c->subtype = AT_ReAddConstraint;
tab->subcmds[AT_PASS_OLD_CONSTR] =
- lappend(tab->subcmds[AT_PASS_OLD_CONSTR], cmd);
+ lappend(tab->subcmds[AT_PASS_OLD_CONSTR], c);
/*
* Recreate any comment on the constraint. If we have
@@ -15769,7 +15769,7 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
}
else
elog(ERROR, "unexpected statement subtype: %d",
- (int) cmd->subtype);
+ (int) c->subtype);
}
}
else if (IsA(stm, AlterDomainStmt))
@@ -15779,12 +15779,12 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
if (stmt->subtype == AD_AddConstraint)
{
Constraint *con = castNode(Constraint, stmt->def);
- AlterTableCmd *cmd = makeNode(AlterTableCmd);
+ AlterTableCmd *c = makeNode(AlterTableCmd);
- cmd->subtype = AT_ReAddDomainConstraint;
- cmd->def = (Node *) stmt;
+ c->subtype = AT_ReAddDomainConstraint;
+ c->def = (Node *) stmt;
tab->subcmds[AT_PASS_OLD_CONSTR] =
- lappend(tab->subcmds[AT_PASS_OLD_CONSTR], cmd);
+ lappend(tab->subcmds[AT_PASS_OLD_CONSTR], c);
/* recreate any comment on the constraint */
RebuildConstraintComment(tab,
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 579ac8d76ae..faf1fb4b5be 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -1165,7 +1165,7 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
{
CreateTrigStmt *childStmt;
Relation childTbl;
- Node *qual;
+ Node *pqual;
childTbl = table_open(partdesc->oids[i], ShareRowExclusiveLock);
@@ -1178,18 +1178,18 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
childStmt->whenClause = NULL;
/* If there is a WHEN clause, create a modified copy of it */
- qual = copyObject(whenClause);
- qual = (Node *)
- map_partition_varattnos((List *) qual, PRS2_OLD_VARNO,
+ pqual = copyObject(whenClause);
+ pqual = (Node *)
+ map_partition_varattnos((List *) pqual, PRS2_OLD_VARNO,
childTbl, rel);
- qual = (Node *)
- map_partition_varattnos((List *) qual, PRS2_NEW_VARNO,
+ pqual = (Node *)
+ map_partition_varattnos((List *) pqual, PRS2_NEW_VARNO,
childTbl, rel);
CreateTriggerFiringOn(childStmt, queryString,
partdesc->oids[i], refRelOid,
InvalidOid, InvalidOid,
- funcoid, trigoid, qual,
+ funcoid, trigoid, pqual,
isInternal, true, trigger_fires_when);
table_close(childTbl, NoLock);
diff --git a/src/backend/commands/wait.c b/src/backend/commands/wait.c
index a37bddaefb2..50369c8e0d2 100644
--- a/src/backend/commands/wait.c
+++ b/src/backend/commands/wait.c
@@ -51,7 +51,7 @@ ExecWaitStmt(ParseState *pstate, WaitStmt *stmt, DestReceiver *dest)
{
char *timeout_str;
const char *hintmsg;
- double result;
+ double d;
if (timeout_specified)
errorConflictingDefElem(defel, pstate);
@@ -59,7 +59,7 @@ ExecWaitStmt(ParseState *pstate, WaitStmt *stmt, DestReceiver *dest)
timeout_str = defGetString(defel);
- if (!parse_real(timeout_str, &result, GUC_UNIT_MS, &hintmsg))
+ if (!parse_real(timeout_str, &d, GUC_UNIT_MS, &hintmsg))
{
ereport(ERROR,
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@@ -72,20 +72,20 @@ ExecWaitStmt(ParseState *pstate, WaitStmt *stmt, DestReceiver *dest)
* don't fail on just-out-of-range values that would round into
* range.
*/
- result = rint(result);
+ d = rint(d);
/* Range check */
- if (unlikely(isnan(result) || !FLOAT8_FITS_IN_INT64(result)))
+ if (unlikely(isnan(d) || !FLOAT8_FITS_IN_INT64(d)))
ereport(ERROR,
errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("timeout value is out of range"));
- if (result < 0)
+ if (d < 0)
ereport(ERROR,
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("timeout cannot be negative"));
- timeout = (int64) result;
+ timeout = (int64) d;
}
else if (strcmp(defel->defname, "no_throw") == 0)
{
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
index 0e1a74976f7..478b9be5839 100644
--- a/src/backend/executor/execExprInterp.c
+++ b/src/backend/executor/execExprInterp.c
@@ -471,7 +471,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
* This array has to be in the same order as enum ExprEvalOp.
*/
#if defined(EEO_USE_COMPUTED_GOTO)
- static const void *const dispatch_table[] = {
+ static const void *const dispatchtable[] = {
&&CASE_EEOP_DONE_RETURN,
&&CASE_EEOP_DONE_NO_RETURN,
&&CASE_EEOP_INNER_FETCHSOME,
@@ -595,11 +595,11 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
&&CASE_EEOP_LAST
};
- StaticAssertDecl(lengthof(dispatch_table) == EEOP_LAST + 1,
+ StaticAssertDecl(lengthof(dispatchtable) == EEOP_LAST + 1,
"dispatch_table out of whack with ExprEvalOp");
if (unlikely(state == NULL))
- return PointerGetDatum(dispatch_table);
+ return PointerGetDatum(dispatchtable);
#else
Assert(state != NULL);
#endif /* EEO_USE_COMPUTED_GOTO */
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 0b02fd32107..f09a29b66b4 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -4070,12 +4070,12 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
*/
for (phaseidx = 0; phaseidx < aggstate->numphases; phaseidx++)
{
- AggStatePerPhase phase = &aggstate->phases[phaseidx];
+ AggStatePerPhase phs = &aggstate->phases[phaseidx];
bool dohash = false;
bool dosort = false;
/* phase 0 doesn't necessarily exist */
- if (!phase->aggnode)
+ if (!phs->aggnode)
continue;
if (aggstate->aggstrategy == AGG_MIXED && phaseidx == 1)
@@ -4096,13 +4096,13 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
*/
continue;
}
- else if (phase->aggstrategy == AGG_PLAIN ||
- phase->aggstrategy == AGG_SORTED)
+ else if (phs->aggstrategy == AGG_PLAIN ||
+ phs->aggstrategy == AGG_SORTED)
{
dohash = false;
dosort = true;
}
- else if (phase->aggstrategy == AGG_HASHED)
+ else if (phs->aggstrategy == AGG_HASHED)
{
dohash = true;
dosort = false;
@@ -4110,11 +4110,11 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
else
Assert(false);
- phase->evaltrans = ExecBuildAggTrans(aggstate, phase, dosort, dohash,
- false);
+ phs->evaltrans = ExecBuildAggTrans(aggstate, phs, dosort, dohash,
+ false);
/* cache compiled expression for outer slot without NULL check */
- phase->evaltrans_cache[0][0] = phase->evaltrans;
+ phs->evaltrans_cache[0][0] = phs->evaltrans;
}
return aggstate;
diff --git a/src/backend/executor/nodeValuesscan.c b/src/backend/executor/nodeValuesscan.c
index 8e85a5f2e9a..0d366546966 100644
--- a/src/backend/executor/nodeValuesscan.c
+++ b/src/backend/executor/nodeValuesscan.c
@@ -141,11 +141,11 @@ ValuesNext(ValuesScanState *node)
resind = 0;
foreach(lc, exprstatelist)
{
- ExprState *estate = (ExprState *) lfirst(lc);
+ ExprState *exprstate = (ExprState *) lfirst(lc);
CompactAttribute *attr = TupleDescCompactAttr(slot->tts_tupleDescriptor,
resind);
- values[resind] = ExecEvalExpr(estate,
+ values[resind] = ExecEvalExpr(exprstate,
econtext,
&isnull[resind]);
diff --git a/src/backend/libpq/be-secure-common.c b/src/backend/libpq/be-secure-common.c
index e8b837d1fa7..8b674435bd2 100644
--- a/src/backend/libpq/be-secure-common.c
+++ b/src/backend/libpq/be-secure-common.c
@@ -111,17 +111,17 @@ error:
* Check permissions for SSL key files.
*/
bool
-check_ssl_key_file_permissions(const char *ssl_key_file, bool isServerStart)
+check_ssl_key_file_permissions(const char *sslKeyFile, bool isServerStart)
{
int loglevel = isServerStart ? FATAL : LOG;
struct stat buf;
- if (stat(ssl_key_file, &buf) != 0)
+ if (stat(sslKeyFile, &buf) != 0)
{
ereport(loglevel,
(errcode_for_file_access(),
errmsg("could not access private key file \"%s\": %m",
- ssl_key_file)));
+ sslKeyFile)));
return false;
}
@@ -131,7 +131,7 @@ check_ssl_key_file_permissions(const char *ssl_key_file, bool isServerStart)
ereport(loglevel,
(errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("private key file \"%s\" is not a regular file",
- ssl_key_file)));
+ sslKeyFile)));
return false;
}
@@ -157,7 +157,7 @@ check_ssl_key_file_permissions(const char *ssl_key_file, bool isServerStart)
ereport(loglevel,
(errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("private key file \"%s\" must be owned by the database user or root",
- ssl_key_file)));
+ sslKeyFile)));
return false;
}
@@ -167,7 +167,7 @@ check_ssl_key_file_permissions(const char *ssl_key_file, bool isServerStart)
ereport(loglevel,
(errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("private key file \"%s\" has group or world access",
- ssl_key_file),
+ sslKeyFile),
errdetail("File must have permissions u=rw (0600) or less if owned by the database user, or permissions u=rw,g=r (0640) or less if owned by root.")));
return false;
}
diff --git a/src/backend/main/main.c b/src/backend/main/main.c
index 72aaee36a68..13f13393acc 100644
--- a/src/backend/main/main.c
+++ b/src/backend/main/main.c
@@ -281,7 +281,7 @@ parse_dispatch_option(const char *name)
* without help. Avoid adding more here, if you can.
*/
static void
-startup_hacks(const char *progname)
+startup_hacks(const char *progName)
{
/*
* Windows-specific execution environment hacking.
@@ -300,7 +300,7 @@ startup_hacks(const char *progname)
if (err != 0)
{
write_stderr("%s: WSAStartup failed: %d\n",
- progname, err);
+ progName, err);
exit(1);
}
@@ -385,10 +385,10 @@ init_locale(const char *categoryname, int category, const char *locale)
* Messages emitted in write_console() do not exhibit this problem.
*/
static void
-help(const char *progname)
+help(const char *progName)
{
- printf(_("%s is the PostgreSQL server.\n\n"), progname);
- printf(_("Usage:\n %s [OPTION]...\n\n"), progname);
+ printf(_("%s is the PostgreSQL server.\n\n"), progName);
+ printf(_("Usage:\n %s [OPTION]...\n\n"), progName);
printf(_("Options:\n"));
printf(_(" -B NBUFFERS number of shared buffers\n"));
printf(_(" -c NAME=VALUE set run-time parameter\n"));
@@ -444,7 +444,7 @@ help(const char *progname)
static void
-check_root(const char *progname)
+check_root(const char *progName)
{
#ifndef WIN32
if (geteuid() == 0)
@@ -467,7 +467,7 @@ check_root(const char *progname)
if (getuid() != geteuid())
{
write_stderr("%s: real and effective user IDs must match\n",
- progname);
+ progName);
exit(1);
}
#else /* WIN32 */
diff --git a/src/backend/optimizer/path/equivclass.c b/src/backend/optimizer/path/equivclass.c
index 441f12f6c50..385179f147c 100644
--- a/src/backend/optimizer/path/equivclass.c
+++ b/src/backend/optimizer/path/equivclass.c
@@ -876,22 +876,22 @@ get_eclass_for_sort_expr(PlannerInfo *root,
while ((i = bms_next_member(newec->ec_relids, i)) > 0)
{
- RelOptInfo *rel = root->simple_rel_array[i];
+ RelOptInfo *relinfo = root->simple_rel_array[i];
/* ignore the RTE_GROUP RTE */
if (i == root->group_rtindex)
continue;
- if (rel == NULL) /* must be an outer join */
+ if (relinfo == NULL) /* must be an outer join */
{
Assert(bms_is_member(i, root->outer_join_rels));
continue;
}
- Assert(rel->reloptkind == RELOPT_BASEREL);
+ Assert(relinfo->reloptkind == RELOPT_BASEREL);
- rel->eclass_indexes = bms_add_member(rel->eclass_indexes,
- ec_index);
+ relinfo->eclass_indexes = bms_add_member(relinfo->eclass_indexes,
+ ec_index);
}
}
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index 8af091ba647..4372135a8f5 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -1236,16 +1236,16 @@ create_append_plan(PlannerInfo *root, AppendPath *best_path, int flags)
if (best_path->subpaths == NIL)
{
/* Generate a Result plan with constant-FALSE gating qual */
- Plan *plan;
+ Plan *pplan;
- plan = (Plan *) make_one_row_result(tlist,
- (Node *) list_make1(makeBoolConst(false,
- false)),
- best_path->path.parent);
+ pplan = (Plan *) make_one_row_result(tlist,
+ (Node *) list_make1(makeBoolConst(false,
+ false)),
+ best_path->path.parent);
- copy_generic_path_info(plan, (Path *) best_path);
+ copy_generic_path_info(pplan, (Path *) best_path);
- return plan;
+ return pplan;
}
/*
@@ -2406,7 +2406,7 @@ create_minmaxagg_plan(PlannerInfo *root, MinMaxAggPath *best_path)
MinMaxAggInfo *mminfo = (MinMaxAggInfo *) lfirst(lc);
PlannerInfo *subroot = mminfo->subroot;
Query *subparse = subroot->parse;
- Plan *plan;
+ Plan *pplan;
/*
* Generate the plan for the subquery. We already have a Path, but we
@@ -2414,25 +2414,25 @@ create_minmaxagg_plan(PlannerInfo *root, MinMaxAggPath *best_path)
* Since we are entering a different planner context (subroot),
* recurse to create_plan not create_plan_recurse.
*/
- plan = create_plan(subroot, mminfo->path);
+ pplan = create_plan(subroot, mminfo->path);
- plan = (Plan *) make_limit(plan,
- subparse->limitOffset,
- subparse->limitCount,
- subparse->limitOption,
- 0, NULL, NULL, NULL);
+ pplan = (Plan *) make_limit(pplan,
+ subparse->limitOffset,
+ subparse->limitCount,
+ subparse->limitOption,
+ 0, NULL, NULL, NULL);
/* Must apply correct cost/width data to Limit node */
- plan->disabled_nodes = mminfo->path->disabled_nodes;
- plan->startup_cost = mminfo->path->startup_cost;
- plan->total_cost = mminfo->pathcost;
- plan->plan_rows = 1;
- plan->plan_width = mminfo->path->pathtarget->width;
- plan->parallel_aware = false;
- plan->parallel_safe = mminfo->path->parallel_safe;
+ pplan->disabled_nodes = mminfo->path->disabled_nodes;
+ pplan->startup_cost = mminfo->path->startup_cost;
+ pplan->total_cost = mminfo->pathcost;
+ pplan->plan_rows = 1;
+ pplan->plan_width = mminfo->path->pathtarget->width;
+ pplan->parallel_aware = false;
+ pplan->parallel_safe = mminfo->path->parallel_safe;
/* Convert the plan into an InitPlan in the outer query. */
- SS_make_initplan_from_plan(root, subroot, plan, mminfo->param);
+ SS_make_initplan_from_plan(root, subroot, pplan, mminfo->param);
}
/* Generate the output plan --- basically just a Result */
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c
index 905c975d83b..6249b9e86f2 100644
--- a/src/backend/parser/parse_target.c
+++ b/src/backend/parser/parse_target.c
@@ -1609,10 +1609,9 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
* subselect must have that outer level as parent.
*/
ParseState mypstate = {0};
- Index levelsup;
/* this loop must work, since GetRTEByRangeTablePosn did */
- for (levelsup = 0; levelsup < netlevelsup; levelsup++)
+ for (Index lvlsup = 0; lvlsup < netlevelsup; lvlsup++)
pstate = pstate->parentParseState;
mypstate.parentParseState = pstate;
mypstate.p_rtable = rte->subquery->rtable;
@@ -1667,12 +1666,11 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
* could be an outer CTE (compare SUBQUERY case above).
*/
ParseState mypstate = {0};
- Index levelsup;
/* this loop must work, since GetCTEForRTE did */
- for (levelsup = 0;
- levelsup < rte->ctelevelsup + netlevelsup;
- levelsup++)
+ for (Index lvlsup = 0;
+ lvlsup < rte->ctelevelsup + netlevelsup;
+ lvlsup++)
pstate = pstate->parentParseState;
mypstate.parentParseState = pstate;
mypstate.p_rtable = ((Query *) cte->ctequery)->rtable;
diff --git a/src/backend/partitioning/partdesc.c b/src/backend/partitioning/partdesc.c
index 328b4d450e4..7bed0127676 100644
--- a/src/backend/partitioning/partdesc.c
+++ b/src/backend/partitioning/partdesc.c
@@ -226,15 +226,15 @@ retry:
{
Relation pg_class;
SysScanDesc scan;
- ScanKeyData key[1];
+ ScanKeyData k[1];
pg_class = table_open(RelationRelationId, AccessShareLock);
- ScanKeyInit(&key[0],
+ ScanKeyInit(&k[0],
Anum_pg_class_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(inhrelid));
scan = systable_beginscan(pg_class, ClassOidIndexId, true,
- NULL, 1, key);
+ NULL, 1, k);
/*
* We could get one tuple from the scan (the normal case), or zero
diff --git a/src/backend/statistics/dependencies.c b/src/backend/statistics/dependencies.c
index 6f63b4f3ffb..5c224bd4817 100644
--- a/src/backend/statistics/dependencies.c
+++ b/src/backend/statistics/dependencies.c
@@ -1098,17 +1098,17 @@ dependency_is_compatible_expression(Node *clause, Index relid, List *statlist, N
if (is_opclause(clause))
{
/* If it's an opclause, check for Var = Const or Const = Var. */
- OpExpr *expr = (OpExpr *) clause;
+ OpExpr *opexpr = (OpExpr *) clause;
/* Only expressions with two arguments are candidates. */
- if (list_length(expr->args) != 2)
+ if (list_length(opexpr->args) != 2)
return false;
/* Make sure non-selected argument is a pseudoconstant. */
- if (is_pseudo_constant_clause(lsecond(expr->args)))
- clause_expr = linitial(expr->args);
- else if (is_pseudo_constant_clause(linitial(expr->args)))
- clause_expr = lsecond(expr->args);
+ if (is_pseudo_constant_clause(lsecond(opexpr->args)))
+ clause_expr = linitial(opexpr->args);
+ else if (is_pseudo_constant_clause(linitial(opexpr->args)))
+ clause_expr = lsecond(opexpr->args);
else
return false;
@@ -1124,7 +1124,7 @@ dependency_is_compatible_expression(Node *clause, Index relid, List *statlist, N
* selectivity functions, and to be more consistent with decisions
* elsewhere in the planner.
*/
- if (get_oprrest(expr->opno) != F_EQSEL)
+ if (get_oprrest(opexpr->opno) != F_EQSEL)
return false;
/* OK to proceed with checking "var" */
@@ -1132,7 +1132,7 @@ dependency_is_compatible_expression(Node *clause, Index relid, List *statlist, N
else if (IsA(clause, ScalarArrayOpExpr))
{
/* If it's a scalar array operator, check for Var IN Const. */
- ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) clause;
+ ScalarArrayOpExpr *opexpr = (ScalarArrayOpExpr *) clause;
/*
* Reject ALL() variant, we only care about ANY/IN.
@@ -1140,21 +1140,21 @@ dependency_is_compatible_expression(Node *clause, Index relid, List *statlist, N
* FIXME Maybe we should check if all the values are the same, and
* allow ALL in that case? Doesn't seem very practical, though.
*/
- if (!expr->useOr)
+ if (!opexpr->useOr)
return false;
/* Only expressions with two arguments are candidates. */
- if (list_length(expr->args) != 2)
+ if (list_length(opexpr->args) != 2)
return false;
/*
* We know it's always (Var IN Const), so we assume the var is the
* first argument, and pseudoconstant is the second one.
*/
- if (!is_pseudo_constant_clause(lsecond(expr->args)))
+ if (!is_pseudo_constant_clause(lsecond(opexpr->args)))
return false;
- clause_expr = linitial(expr->args);
+ clause_expr = linitial(opexpr->args);
/*
* If it's not an "=" operator, just ignore the clause, as it's not
@@ -1163,7 +1163,7 @@ dependency_is_compatible_expression(Node *clause, Index relid, List *statlist, N
* selectivity. That's a bit strange, but it's what other similar
* places do.
*/
- if (get_oprrest(expr->opno) != F_EQSEL)
+ if (get_oprrest(opexpr->opno) != F_EQSEL)
return false;
/* OK to proceed with checking "var" */
diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c
index 3c3d2d315c6..0d93b0af7e2 100644
--- a/src/backend/statistics/extended_stats.c
+++ b/src/backend/statistics/extended_stats.c
@@ -1041,7 +1041,7 @@ build_sorted_items(StatsBuildData *data, int *nitems,
for (j = 0; j < numattrs; j++)
{
Datum value;
- bool isnull;
+ bool is_null;
int attlen;
AttrNumber attnum = attnums[j];
@@ -1057,7 +1057,7 @@ build_sorted_items(StatsBuildData *data, int *nitems,
Assert(idx < data->nattnums);
value = data->values[idx][i];
- isnull = data->nulls[idx][i];
+ is_null = data->nulls[idx][i];
attlen = typlen[idx];
/*
@@ -1069,7 +1069,7 @@ build_sorted_items(StatsBuildData *data, int *nitems,
* on the assumption that those are small (below WIDTH_THRESHOLD)
* and will be discarded at the end of analyze.
*/
- if ((!isnull) && (attlen == -1))
+ if ((!is_null) && (attlen == -1))
{
if (toast_raw_datum_size(value) > WIDTH_THRESHOLD)
{
@@ -1081,7 +1081,7 @@ build_sorted_items(StatsBuildData *data, int *nitems,
}
items[nrows].values[j] = value;
- items[nrows].isnull[j] = isnull;
+ items[nrows].isnull[j] = is_null;
}
if (toowide)
diff --git a/src/backend/storage/aio/read_stream.c b/src/backend/storage/aio/read_stream.c
index 031fde9f4cb..89408e8f428 100644
--- a/src/backend/storage/aio/read_stream.c
+++ b/src/backend/storage/aio/read_stream.c
@@ -961,19 +961,19 @@ read_stream_next_buffer(ReadStream *stream, void **per_buffer_data)
*/
if (stream->per_buffer_data)
{
- void *per_buffer_data;
+ void *data;
- per_buffer_data = get_per_buffer_data(stream,
- oldest_buffer_index == 0 ?
- stream->queue_size - 1 :
- oldest_buffer_index - 1);
+ data = get_per_buffer_data(stream,
+ oldest_buffer_index == 0 ?
+ stream->queue_size - 1 :
+ oldest_buffer_index - 1);
#if defined(CLOBBER_FREED_MEMORY)
/* This also tells Valgrind the memory is "noaccess". */
- wipe_mem(per_buffer_data, stream->per_buffer_data_size);
+ wipe_mem(data, stream->per_buffer_data_size);
#elif defined(USE_VALGRIND)
/* Tell it ourselves. */
- VALGRIND_MAKE_MEM_NOACCESS(per_buffer_data,
+ VALGRIND_MAKE_MEM_NOACCESS(data,
stream->per_buffer_data_size);
#endif
}
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index f373cead95f..ad7d721e639 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -1188,7 +1188,7 @@ ReadBuffer_common(Relation rel, SMgrRelation smgr, char smgr_persistence,
*/
if (unlikely(blockNum == P_NEW))
{
- uint32 flags = EB_SKIP_EXTENSION_LOCK;
+ uint32 flag = EB_SKIP_EXTENSION_LOCK;
/*
* Since no-one else can be looking at the page contents yet, there is
@@ -1196,9 +1196,9 @@ ReadBuffer_common(Relation rel, SMgrRelation smgr, char smgr_persistence,
* lock.
*/
if (mode == RBM_ZERO_AND_LOCK || mode == RBM_ZERO_AND_CLEANUP_LOCK)
- flags |= EB_LOCK_FIRST;
+ flag |= EB_LOCK_FIRST;
- return ExtendBufferedRel(BMR_REL(rel), forkNum, strategy, flags);
+ return ExtendBufferedRel(BMR_REL(rel), forkNum, strategy, flag);
}
if (rel)
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index 344f58b92f7..af6c1ec8dbe 100644
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -569,16 +569,16 @@ Datum
date_pli(PG_FUNCTION_ARGS)
{
DateADT dateVal = PG_GETARG_DATEADT(0);
- int32 days = PG_GETARG_INT32(1);
+ int32 nday = PG_GETARG_INT32(1);
DateADT result;
if (DATE_NOT_FINITE(dateVal))
PG_RETURN_DATEADT(dateVal); /* can't change infinity */
- result = dateVal + days;
+ result = dateVal + nday;
/* Check for integer overflow and out-of-allowed-range */
- if ((days >= 0 ? (result < dateVal) : (result > dateVal)) ||
+ if ((nday >= 0 ? (result < dateVal) : (result > dateVal)) ||
!IS_VALID_DATE(result))
ereport(ERROR,
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
@@ -593,13 +593,13 @@ Datum
date_mii(PG_FUNCTION_ARGS)
{
DateADT dateVal = PG_GETARG_DATEADT(0);
- int32 days = PG_GETARG_INT32(1);
+ int32 nday = PG_GETARG_INT32(1);
DateADT result;
if (DATE_NOT_FINITE(dateVal))
PG_RETURN_DATEADT(dateVal); /* can't change infinity */
- result = dateVal - days;
+ result = dateVal - nday;
/* Check for integer overflow and out-of-allowed-range */
if ((days >= 0 ? (result > dateVal) : (result < dateVal)) ||
@@ -3210,7 +3210,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;
@@ -3218,9 +3218,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)
{
@@ -3233,7 +3233,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 680fee2a844..c54f1507b59 100644
--- a/src/backend/utils/adt/datetime.c
+++ b/src/backend/utils/adt/datetime.c
@@ -642,12 +642,12 @@ AdjustMicroseconds(int64 val, double fval, int64 scale,
static bool
AdjustDays(int64 val, int scale, struct pg_itm_in *itm_in)
{
- int days;
+ int nday;
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, &nday) &&
+ !pg_add_s32_overflow(itm_in->tm_mday, nday, &itm_in->tm_mday);
}
/*
@@ -3285,7 +3285,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,
@@ -3302,8 +3302,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);
@@ -3323,11 +3323,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;
}
}
@@ -3340,12 +3340,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 5bfeda2ffde..7a8c7aaf742 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -3041,12 +3041,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 *nmonth;
if (n->key->id == DCH_RM)
- months = rm_months_upper;
+ nmonth = rm_months_upper;
else
- months = rm_months_lower;
+ nmonth = rm_months_lower;
/*
* Compute the position in the roman-numeral array. Note
@@ -3081,7 +3081,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]);
+ nmonth[mon]);
s += strlen(s);
}
break;
diff --git a/src/common/controldata_utils.c b/src/common/controldata_utils.c
index fa375dc9129..78464e8237f 100644
--- a/src/common/controldata_utils.c
+++ b/src/common/controldata_utils.c
@@ -49,11 +49,11 @@
* file data is correct.
*/
ControlFileData *
-get_controlfile(const char *DataDir, bool *crc_ok_p)
+get_controlfile(const char *data_dir, bool *crc_ok_p)
{
char ControlFilePath[MAXPGPATH];
- snprintf(ControlFilePath, MAXPGPATH, "%s/%s", DataDir, XLOG_CONTROL_FILE);
+ snprintf(ControlFilePath, MAXPGPATH, "%s/%s", data_dir, XLOG_CONTROL_FILE);
return get_controlfile_by_exact_path(ControlFilePath, crc_ok_p);
}
@@ -186,7 +186,7 @@ retry:
* routine in the backend.
*/
void
-update_controlfile(const char *DataDir,
+update_controlfile(const char *data_dir,
ControlFileData *ControlFile, bool do_sync)
{
int fd;
@@ -211,7 +211,7 @@ update_controlfile(const char *DataDir,
memset(buffer, 0, PG_CONTROL_FILE_SIZE);
memcpy(buffer, ControlFile, sizeof(ControlFileData));
- snprintf(ControlFilePath, sizeof(ControlFilePath), "%s/%s", DataDir, XLOG_CONTROL_FILE);
+ snprintf(ControlFilePath, sizeof(ControlFilePath), "%s/%s", data_dir, XLOG_CONTROL_FILE);
#ifndef FRONTEND
diff --git a/src/timezone/pgtz.c b/src/timezone/pgtz.c
index 504c0235ffb..3a9006b2116 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 *tz_name)
{
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(tz_name) > 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 (*tz_name)
+ *p++ = pg_toupper((unsigned char) *tz_name++);
*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 tz_name[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(tz_name, sizeof(tz_name), "<-%s>+%s",
offsetstr, offsetstr);
else
- snprintf(tzname, sizeof(tzname), "<+%s>-%s",
+ snprintf(tz_name, sizeof(tz_name), "<+%s>-%s",
offsetstr, offsetstr);
- return pg_tzset(tzname);
+ return pg_tzset(tz_name);
}
--
2.39.5 (Apple Git-154)
view thread (30+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Cleanup shadows variable warnings, round 1
In-Reply-To: <CAEoWx2kQ2x5gMaj8tHLJ3=jfC+p5YXHkJyHrDTiQw2nn2FJTmQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox