I bumped into some variable shadowings that to my slight surprise the
current warning option -Wshadow=compatible-local does not catch. For
example
const char *p;
char *p;
or
bool skipped;
int64 skipped;
These are not "compatible" in the technical C language sense, but they
are mutually assignable, so IMO just as confusing and fragile.
Also, there are things like
EState *estate;
ExprState *estate;
which are not mutually assignable, but almost as dangerous given the
propensity to cast node types around.
These can be caught if we dial up the warning one notch to
-Wshadow=local. This then flags all shadowing of a local variable by
another local variable. I have fixed all the warnings in the attached
patch. I think everything this catches is obviously bad, so this seems
well worth fixing. (And if we buy into the idea of
-Wshadow=compatible-local, then this is obviously better and more complete.)
So the first patch fixes all the warnings, but doesn't turn up the
compiler flag yet. There is a hiccup with the LLVM headers, because
they themselves trigger these warnings. So the second patch provides a
workaround to silence warnings from those headers. It's a bit different
from what we have done before, but I think it works better for this
case. Alternative ideas welcome. In the third patch, the warning
option is then changed.
From c044af96583d48b7d560d32e47ab5e60979abc13 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 1 Sep 2026 16:38:31 +0200
Subject: [PATCH 1/3] Fix -Wshadow=local warnings
This fixes issues with the same variable name being used in the same
function for two different variables. (In some cases, one of the uses
is a function argument.) The fix is in most cases to rename one or
both of them. The individual choice depends on conventions in the
surrounding code. Often, making both variable names more specific is
the best choice. In a few cases, the fix is to move one of the
variables to a lower scope, so that it no longer conflicts with the
other.
Since these are all local-variable conflicts, the changes in different
files in this patch are independent of each other.
These issues correspond to the gcc warning option -Wshadow=local,
which is not currently used but could be activated after this.
---
contrib/postgres_fdw/postgres_fdw.c | 22 ++--
src/backend/access/brin/brin.c | 8 +-
src/backend/access/gist/gistbuild.c | 16 +--
src/backend/catalog/objectaddress.c | 30 ++---
src/backend/catalog/pg_constraint.c | 32 +++---
src/backend/commands/extension.c | 8 +-
src/backend/commands/schemacmds.c | 4 +-
src/backend/commands/statscmds.c | 6 +-
src/backend/commands/tablecmds.c | 14 +--
src/backend/commands/trigger.c | 12 +-
src/backend/executor/nodeAgg.c | 16 +--
src/backend/executor/nodeValuesscan.c | 4 +-
src/backend/optimizer/path/equivclass.c | 6 +-
src/backend/optimizer/plan/createplan.c | 44 ++++----
src/backend/partitioning/partdesc.c | 12 +-
src/backend/statistics/dependencies.c | 28 ++---
src/backend/statistics/extended_stats.c | 6 +-
src/backend/storage/aio/read_stream.c | 14 +--
src/backend/storage/buffer/bufmgr.c | 14 +--
src/backend/utils/adt/jsonpath_exec.c | 48 ++++----
src/backend/utils/adt/pg_upgrade_support.c | 6 +-
src/backend/utils/adt/timestamp.c | 20 ++--
src/backend/utils/adt/varlena.c | 20 ++--
src/backend/utils/cache/inval.c | 48 ++++----
src/backend/utils/mmgr/freepage.c | 42 +++----
src/bin/pg_basebackup/pg_receivewal.c | 6 +-
src/bin/pgbench/pgbench.c | 62 +++++------
src/bin/psql/describe.c | 18 +--
src/bin/psql/prompt.c | 39 ++++---
src/bin/psql/prompt.h | 2 +-
src/fe_utils/print.c | 22 ++--
src/include/lib/radixtree.h | 16 +--
src/include/optimizer/paths.h | 2 +-
src/include/storage/sinval.h | 4 +-
.../ecpg/test/expected/pgtypeslib-num_test2.c | 3 +-
.../ecpg/test/pgtypeslib/num_test2.pgc | 3 +-
src/interfaces/libpq/fe-connect.c | 12 +-
src/interfaces/libpq/fe-secure-openssl.c | 104 +++++++++---------
38 files changed, 392 insertions(+), 381 deletions(-)
diff --git a/contrib/postgres_fdw/postgres_fdw.c
b/contrib/postgres_fdw/postgres_fdw.c
index 9269418a074..d5b2300a281 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -2001,7 +2001,7 @@ postgresPlanForeignModify(PlannerInfo *root,
{
CmdType operation = plan->operation;
RangeTblEntry *rte = planner_rt_fetch(resultRelation, root);
- Relation rel;
+ Relation targetrel;
StringInfoData sql;
List *targetAttrs = NIL;
List *withCheckOptionList = NIL;
@@ -2016,7 +2016,7 @@ postgresPlanForeignModify(PlannerInfo *root,
* Core code already has some lock on each rel being planned, so we can
* use NoLock here.
*/
- rel = table_open(rte->relid, NoLock);
+ targetrel = table_open(rte->relid, NoLock);
/*
* In an INSERT, we transmit all columns that are defined in the foreign
@@ -2031,10 +2031,10 @@ postgresPlanForeignModify(PlannerInfo *root,
*/
if (operation == CMD_INSERT ||
(operation == CMD_UPDATE &&
- rel->trigdesc &&
- rel->trigdesc->trig_update_before_row))
+ targetrel->trigdesc &&
+ targetrel->trigdesc->trig_update_before_row))
{
- TupleDesc tupdesc = RelationGetDescr(rel);
+ TupleDesc tupdesc = RelationGetDescr(targetrel);
int attnum;
for (attnum = 1; attnum <= tupdesc->natts; attnum++)
@@ -2048,8 +2048,8 @@ postgresPlanForeignModify(PlannerInfo *root,
else if (operation == CMD_UPDATE)
{
int col;
- RelOptInfo *rel = find_base_rel(root, resultRelation);
- Bitmapset *allUpdatedCols = get_rel_all_updated_cols(root,
rel);
+ RelOptInfo *baserel = find_base_rel(root, resultRelation);
+ Bitmapset *allUpdatedCols = get_rel_all_updated_cols(root,
baserel);
col = -1;
while ((col = bms_next_member(allUpdatedCols, col)) >= 0)
@@ -2094,19 +2094,19 @@ postgresPlanForeignModify(PlannerInfo *root,
switch (operation)
{
case CMD_INSERT:
- deparseInsertSql(&sql, rte, resultRelation, rel,
+ deparseInsertSql(&sql, rte, resultRelation, targetrel,
targetAttrs, doNothing,
withCheckOptionList,
returningList,
&retrieved_attrs,
&values_end_len);
break;
case CMD_UPDATE:
- deparseUpdateSql(&sql, rte, resultRelation, rel,
+ deparseUpdateSql(&sql, rte, resultRelation, targetrel,
targetAttrs,
withCheckOptionList,
returningList,
&retrieved_attrs);
break;
case CMD_DELETE:
- deparseDeleteSql(&sql, rte, resultRelation, rel,
+ deparseDeleteSql(&sql, rte, resultRelation, targetrel,
returningList,
&retrieved_attrs);
break;
@@ -2115,7 +2115,7 @@ postgresPlanForeignModify(PlannerInfo *root,
break;
}
- table_close(rel, NoLock);
+ table_close(targetrel, NoLock);
/*
* Build the fdw_private list that will be available to the executor.
diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c
index bdb30752e09..5059da8dce7 100644
--- a/src/backend/access/brin/brin.c
+++ b/src/backend/access/brin/brin.c
@@ -699,15 +699,15 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
*/
if (consistentFn[keyattno - 1].fn_oid == InvalidOid)
{
- FmgrInfo *tmp;
+ FmgrInfo *consistentFI;
/* 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,
+ consistentFI = index_getprocinfo(idxRel, keyattno,
+
BRIN_PROCNUM_CONSISTENT);
+ fmgr_info_copy(&consistentFn[keyattno - 1],
consistentFI,
CurrentMemoryContext);
}
diff --git a/src/backend/access/gist/gistbuild.c
b/src/backend/access/gist/gistbuild.c
index 7f57c787f4c..07bad403b2d 100644
--- a/src/backend/access/gist/gistbuild.c
+++ b/src/backend/access/gist/gistbuild.c
@@ -1058,7 +1058,7 @@ gistbufferinginserttuples(GISTBuildState *buildstate,
Buffer buffer, int level,
BlockNumber parentblk,
OffsetNumber downlinkoffnum)
{
GISTBuildBuffers *gfbb = buildstate->gfbb;
- List *splitinfo;
+ List *splitinfos;
bool is_split;
BlockNumber placed_to_blk = InvalidBlockNumber;
@@ -1068,7 +1068,7 @@ gistbufferinginserttuples(GISTBuildState *buildstate,
Buffer buffer, int level,
buffer,
itup, ntup,
oldoffnum, &placed_to_blk,
InvalidBuffer,
- &splitinfo,
+ &splitinfos,
false,
buildstate->heaprel,
true);
@@ -1117,7 +1117,7 @@ gistbufferinginserttuples(GISTBuildState *buildstate,
Buffer buffer, int level,
}
}
- if (splitinfo)
+ if (splitinfos)
{
/*
* Insert the downlinks to the parent. This is analogous with
@@ -1142,7 +1142,7 @@ gistbufferinginserttuples(GISTBuildState *buildstate,
Buffer buffer, int level,
/*
* If there's a buffer associated with this page, that needs to
be
* split too. gistRelocateBuildBuffersOnSplit() will also
adjust the
- * downlinks in 'splitinfo', to make sure they're consistent
not only
+ * downlinks in 'splitinfos', to make sure they're consistent
not only
* with the tuples already on the pages, but also the tuples in
the
* buffers that will eventually be inserted to them.
*/
@@ -1150,13 +1150,13 @@ gistbufferinginserttuples(GISTBuildState *buildstate,
Buffer buffer, int level,
buildstate->giststate,
buildstate->indexrel,
level,
-
buffer, splitinfo);
+
buffer, splitinfos);
/* Create an array of all the downlink tuples */
- ndownlinks = list_length(splitinfo);
+ ndownlinks = list_length(splitinfos);
downlinks = palloc_array(IndexTuple, ndownlinks);
i = 0;
- foreach(lc, splitinfo)
+ foreach(lc, splitinfos)
{
GISTPageSplitInfo *splitinfo = lfirst(lc);
@@ -1194,7 +1194,7 @@ gistbufferinginserttuples(GISTBuildState *buildstate,
Buffer buffer, int level,
downlinks,
ndownlinks, downlinkoffnum,
InvalidBlockNumber, InvalidOffsetNumber);
- list_free_deep(splitinfo); /* we don't need this anymore */
+ list_free_deep(splitinfos); /* we don't need this anymore */
}
else
UnlockReleaseBuffer(buffer);
diff --git a/src/backend/catalog/objectaddress.c
b/src/backend/catalog/objectaddress.c
index 703754a8123..1de79d8fb58 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -2241,37 +2241,37 @@ pg_get_object_address(PG_FUNCTION_ARGS)
if (type == OBJECT_TYPE || type == OBJECT_DOMAIN || type == OBJECT_CAST
||
type == OBJECT_TRANSFORM || type == OBJECT_DOMCONSTRAINT)
{
- Datum *elems;
- bool *nulls;
+ Datum *arr_elems;
+ bool *arr_nulls;
int nelems;
- deconstruct_array_builtin(namearr, TEXTOID, &elems, &nulls,
&nelems);
+ deconstruct_array_builtin(namearr, TEXTOID, &arr_elems,
&arr_nulls, &nelems);
if (nelems != 1)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("name list length must be
exactly %d", 1)));
- if (nulls[0])
+ if (arr_nulls[0])
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("name or argument lists may not
contain nulls")));
- typename = typeStringToTypeName(TextDatumGetCString(elems[0]),
NULL);
+ typename =
typeStringToTypeName(TextDatumGetCString(arr_elems[0]), NULL);
}
else if (type == OBJECT_LARGEOBJECT)
{
- Datum *elems;
- bool *nulls;
+ Datum *arr_elems;
+ bool *arr_nulls;
int nelems;
- deconstruct_array_builtin(namearr, TEXTOID, &elems, &nulls,
&nelems);
+ deconstruct_array_builtin(namearr, TEXTOID, &arr_elems,
&arr_nulls, &nelems);
if (nelems != 1)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("name list length must be
exactly %d", 1)));
- if (nulls[0])
+ if (arr_nulls[0])
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("large object OID may not be
null")));
- objnode = (Node *) makeFloat(TextDatumGetCString(elems[0]));
+ objnode = (Node *) makeFloat(TextDatumGetCString(arr_elems[0]));
}
else
{
@@ -2295,22 +2295,22 @@ pg_get_object_address(PG_FUNCTION_ARGS)
type == OBJECT_AMPROC)
{
/* in these cases, the args list must be of TypeName */
- Datum *elems;
- bool *nulls;
+ Datum *arr_elems;
+ bool *arr_nulls;
int nelems;
int i;
- deconstruct_array_builtin(argsarr, TEXTOID, &elems, &nulls,
&nelems);
+ deconstruct_array_builtin(argsarr, TEXTOID, &arr_elems,
&arr_nulls, &nelems);
args = NIL;
for (i = 0; i < nelems; i++)
{
- if (nulls[i])
+ if (arr_nulls[i])
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("name or argument lists
may not contain nulls")));
args = lappend(args,
-
typeStringToTypeName(TextDatumGetCString(elems[i]),
+
typeStringToTypeName(TextDatumGetCString(arr_elems[i]),
NULL));
}
}
diff --git a/src/backend/catalog/pg_constraint.c
b/src/backend/catalog/pg_constraint.c
index 48ede21007e..12c50f8b14a 100644
--- a/src/backend/catalog/pg_constraint.c
+++ b/src/backend/catalog/pg_constraint.c
@@ -864,22 +864,22 @@ RelationGetNotNullConstraints(Oid relid, bool cooked,
bool include_noinh)
if (cooked)
{
- CookedConstraint *cooked;
-
- cooked = palloc_object(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 *cooked_constr;
+
+ cooked_constr = palloc_object(CookedConstraint);
+
+ cooked_constr->contype = CONSTR_NOTNULL;
+ cooked_constr->conoid = conForm->oid;
+ cooked_constr->name =
pstrdup(NameStr(conForm->conname));
+ cooked_constr->attnum = colnum;
+ cooked_constr->expr = NULL;
+ cooked_constr->is_enforced = true;
+ cooked_constr->skip_validation = !conForm->convalidated;
+ cooked_constr->is_local = true;
+ cooked_constr->inhcount = 0;
+ cooked_constr->is_no_inherit = conForm->connoinherit;
+
+ notnulls = lappend(notnulls, cooked_constr);
}
else
{
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index f7e7395c173..5855668c5ca 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -1455,8 +1455,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 *reqSchemaName =
get_namespace_name(reqschema);
+ const char *qReqSchemaName =
quote_identifier(reqSchemaName);
char *repltoken;
repltoken = psprintf("@extschema:%s@", reqextname);
@@ -1464,8 +1464,8 @@ execute_extension_script(Oid extensionOid,
ExtensionControlFile *control,
C_COLLATION_OID,
t_sql,
CStringGetTextDatum(repltoken),
-
CStringGetTextDatum(qSchemaName));
- if (t_sql != old && strpbrk(schemaName,
quoting_relevant_chars))
+
CStringGetTextDatum(qReqSchemaName));
+ if (t_sql != old && strpbrk(reqSchemaName,
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 bfaa4743cd8..de5bbd5662c 100644
--- a/src/backend/commands/schemacmds.c
+++ b/src/backend/commands/schemacmds.c
@@ -205,14 +205,14 @@ CreateSchemaCommand(ParseState *pstate, CreateSchemaStmt
*stmt,
*/
foreach(parsetree_item, parsetree_list)
{
- Node *stmt = (Node *) lfirst(parsetree_item);
+ Node *node = (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 = node;
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 c4b5b478644..545678bc35c 100644
--- a/src/backend/commands/statscmds.c
+++ b/src/backend/commands/statscmds.c
@@ -359,15 +359,15 @@ CreateStatistics(List *relids, CreateStatsStmt *stmt,
bool check_rights)
Node *expr = selem->expr;
Oid atttype;
TypeCacheEntry *type;
- Bitmapset *attnums = NULL;
+ Bitmapset *expr_attrs = NULL;
int k;
Assert(expr != NULL);
- pull_varattnos(expr, 1, &attnums);
+ pull_varattnos(expr, 1, &expr_attrs);
k = -1;
- while ((k = bms_next_member(attnums, k)) >= 0)
+ while ((k = bms_next_member(expr_attrs, k)) >= 0)
{
AttrNumber attnum = k +
FirstLowInvalidHeapAttributeNumber;
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index fd144d783d9..07676967261 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -678,8 +678,8 @@ static void RememberStatisticsForRebuilding(Oid stxoid,
AlteredTableInfo *tab);
static void ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab,
LOCKMODE
lockmode);
static void ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, Oid
ownerId,
- char *cmd,
List **wqueue, LOCKMODE lockmode,
- bool rewrite);
+ const char
*cmdstring, List **wqueue,
+ LOCKMODE
lockmode, bool rewrite);
static void RebuildConstraintComment(AlteredTableInfo *tab, AlterTablePass
pass,
Oid
objid, Relation rel, List *domname,
const
char *conname);
@@ -16296,7 +16296,7 @@ ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo
*tab, LOCKMODE lockmode)
*/
static void
ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, Oid ownerId,
- char *cmd, List **wqueue, LOCKMODE
lockmode,
+ const char *cmdstring, List **wqueue,
LOCKMODE lockmode,
bool rewrite)
{
List *raw_parsetree_list;
@@ -16310,7 +16310,7 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid
refRelId, Oid ownerId,
* parse_analyze_*() or the rewriter, but instead we need to pass them
* through parse_utilcmd.c to make them ready for execution.
*/
- raw_parsetree_list = raw_parser(cmd, RAW_PARSE_DEFAULT);
+ raw_parsetree_list = raw_parser(cmdstring, RAW_PARSE_DEFAULT);
querytree_list = NIL;
foreach(list_item, raw_parsetree_list)
{
@@ -16321,7 +16321,7 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid
refRelId, Oid ownerId,
querytree_list = lappend(querytree_list,
transformIndexStmt(oldRelId,
(IndexStmt *) stmt,
-
cmd));
+
cmdstring));
else if (IsA(stmt, AlterTableStmt))
{
List *beforeStmts;
@@ -16329,7 +16329,7 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid
refRelId, Oid ownerId,
stmt = (Node *) transformAlterTableStmt(oldRelId,
(AlterTableStmt *) stmt,
-
cmd,
+
cmdstring,
&beforeStmts,
&afterStmts);
querytree_list = list_concat(querytree_list,
beforeStmts);
@@ -16340,7 +16340,7 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid
refRelId, Oid ownerId,
{
CreateStatsStmt *csstmt;
- csstmt = transformStatsStmt(oldRelId, (CreateStatsStmt
*) stmt, cmd);
+ csstmt = transformStatsStmt(oldRelId, (CreateStatsStmt
*) stmt, cmdstring);
csstmt->owner = ownerId;
querytree_list = lappend(querytree_list, csstmt);
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 79ffd2cada6..20acae69866 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -187,7 +187,7 @@ CreateTriggerFiringOn(const CreateTrigStmt *stmt, const
char *queryString,
int16 *columns;
int2vector *tgattr;
List *whenRtable;
- char *qual;
+ char *tgqual;
Datum values[Natts_pg_trigger];
bool nulls[Natts_pg_trigger];
Relation rel;
@@ -684,7 +684,7 @@ CreateTriggerFiringOn(const CreateTrigStmt *stmt, const
char *queryString,
/* we'll need the rtable for recordDependencyOnExpr */
whenRtable = pstate->p_rtable;
- qual = nodeToString(whenClause);
+ tgqual = nodeToString(whenClause);
free_parsestate(pstate);
}
@@ -692,11 +692,11 @@ CreateTriggerFiringOn(const CreateTrigStmt *stmt, const
char *queryString,
{
whenClause = NULL;
whenRtable = NIL;
- qual = NULL;
+ tgqual = NULL;
}
else
{
- qual = nodeToString(whenClause);
+ tgqual = nodeToString(whenClause);
whenRtable = NIL;
}
@@ -985,8 +985,8 @@ CreateTriggerFiringOn(const CreateTrigStmt *stmt, const
char *queryString,
values[Anum_pg_trigger_tgattr - 1] = PointerGetDatum(tgattr);
/* set tgqual if trigger has WHEN clause */
- if (qual)
- values[Anum_pg_trigger_tgqual - 1] = CStringGetTextDatum(qual);
+ if (tgqual)
+ values[Anum_pg_trigger_tgqual - 1] =
CStringGetTextDatum(tgqual);
else
nulls[Anum_pg_trigger_tgqual - 1] = true;
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 962cd9c8255..29037cf3122 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -4065,12 +4065,12 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
*/
for (phaseidx = 0; phaseidx < aggstate->numphases; phaseidx++)
{
- AggStatePerPhase phase = &aggstate->phases[phaseidx];
+ AggStatePerPhase phasedata = &aggstate->phases[phaseidx];
bool dohash = false;
bool dosort = false;
/* phase 0 doesn't necessarily exist */
- if (!phase->aggnode)
+ if (!phasedata->aggnode)
continue;
if (aggstate->aggstrategy == AGG_MIXED && phaseidx == 1)
@@ -4091,13 +4091,13 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
*/
continue;
}
- else if (phase->aggstrategy == AGG_PLAIN ||
- phase->aggstrategy == AGG_SORTED)
+ else if (phasedata->aggstrategy == AGG_PLAIN ||
+ phasedata->aggstrategy == AGG_SORTED)
{
dohash = false;
dosort = true;
}
- else if (phase->aggstrategy == AGG_HASHED)
+ else if (phasedata->aggstrategy == AGG_HASHED)
{
dohash = true;
dosort = false;
@@ -4105,11 +4105,11 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
else
Assert(false);
- phase->evaltrans = ExecBuildAggTrans(aggstate, phase, dosort,
dohash,
-
false);
+ phasedata->evaltrans = ExecBuildAggTrans(aggstate, phasedata,
dosort, dohash,
+
false);
/* cache compiled expression for outer slot without NULL check
*/
- phase->evaltrans_cache[0][0] = phase->evaltrans;
+ phasedata->evaltrans_cache[0][0] = phasedata->evaltrans;
}
return aggstate;
diff --git a/src/backend/executor/nodeValuesscan.c
b/src/backend/executor/nodeValuesscan.c
index 51c32979481..08d1e95309b 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/optimizer/path/equivclass.c
b/src/backend/optimizer/path/equivclass.c
index 393a7a69742..ca8a0f69b00 100644
--- a/src/backend/optimizer/path/equivclass.c
+++ b/src/backend/optimizer/path/equivclass.c
@@ -740,7 +740,7 @@ get_eclass_for_sort_expr(PlannerInfo *root,
Oid opcintype,
Oid collation,
Index sortref,
- Relids rel,
+ Relids relids,
bool create_it)
{
JoinDomain *jdomain;
@@ -783,14 +783,14 @@ get_eclass_for_sort_expr(PlannerInfo *root,
if (!equal(opfamilies, cur_ec->ec_opfamilies))
continue;
- setup_eclass_member_iterator(&it, cur_ec, rel);
+ setup_eclass_member_iterator(&it, cur_ec, relids);
while ((cur_em = eclass_member_iterator_next(&it)) != NULL)
{
/*
* Ignore child members unless they match the request.
*/
if (cur_em->em_is_child &&
- !bms_equal(cur_em->em_relids, rel))
+ !bms_equal(cur_em->em_relids, relids))
continue;
/*
diff --git a/src/backend/optimizer/plan/createplan.c
b/src/backend/optimizer/plan/createplan.c
index 02a888c5996..a7cba39e20b 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -1242,16 +1242,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 *resultplan;
- plan = (Plan *) make_one_row_result(tlist,
-
(Node *) list_make1(makeBoolConst(false,
-
false)),
-
best_path->path.parent);
+ resultplan = (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(resultplan, (Path *) best_path);
- return plan;
+ return resultplan;
}
/*
@@ -2415,7 +2415,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 *sqplan;
/*
* Generate the plan for the subquery. We already have a Path,
but we
@@ -2423,25 +2423,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);
+ sqplan = create_plan(subroot, mminfo->path);
- plan = (Plan *) make_limit(plan,
-
subparse->limitOffset,
-
subparse->limitCount,
-
subparse->limitOption,
- 0, NULL,
NULL, NULL);
+ sqplan = (Plan *) make_limit(sqplan,
+
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;
+ sqplan->disabled_nodes = mminfo->path->disabled_nodes;
+ sqplan->startup_cost = mminfo->path->startup_cost;
+ sqplan->total_cost = mminfo->pathcost;
+ sqplan->plan_rows = 1;
+ sqplan->plan_width = mminfo->path->pathtarget->width;
+ sqplan->parallel_aware = false;
+ sqplan->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, sqplan,
mminfo->param);
}
/* Generate the output plan --- basically just a Result */
diff --git a/src/backend/partitioning/partdesc.c
b/src/backend/partitioning/partdesc.c
index f29e5a323a1..4399fe9a3a0 100644
--- a/src/backend/partitioning/partdesc.c
+++ b/src/backend/partitioning/partdesc.c
@@ -146,7 +146,7 @@ RelationBuildPartitionDesc(Relation rel, bool omit_detached)
int i,
nparts;
bool retried = false;
- PartitionKey key = RelationGetPartitionKey(rel);
+ PartitionKey partkey = RelationGetPartitionKey(rel);
MemoryContext new_pdcxt;
MemoryContext oldcxt;
int *mapping;
@@ -226,15 +226,15 @@ RelationBuildPartitionDesc(Relation rel, bool
omit_detached)
{
Relation pg_class;
SysScanDesc scan;
- ScanKeyData key[1];
+ ScanKeyData skey[1];
pg_class = table_open(RelationRelationId,
AccessShareLock);
- ScanKeyInit(&key[0],
+ ScanKeyInit(&skey[0],
Anum_pg_class_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(inhrelid));
scan = systable_beginscan(pg_class, ClassOidIndexId,
true,
- NULL,
1, key);
+ NULL,
1, skey);
/*
* We could get one tuple from the scan (the normal
case), or zero
@@ -308,7 +308,7 @@ RelationBuildPartitionDesc(Relation rel, bool omit_detached)
* This could fail, but we haven't done any damage if so.
*/
if (nparts > 0)
- boundinfo = partition_bounds_create(boundspecs, nparts, key,
&mapping);
+ boundinfo = partition_bounds_create(boundspecs, nparts,
partkey, &mapping);
/*
* Now build the actual relcache partition descriptor, copying all the
@@ -329,7 +329,7 @@ RelationBuildPartitionDesc(Relation rel, bool omit_detached)
if (nparts > 0)
{
oldcxt = MemoryContextSwitchTo(new_pdcxt);
- partdesc->boundinfo = partition_bounds_copy(boundinfo, key);
+ partdesc->boundinfo = partition_bounds_copy(boundinfo, partkey);
/* Initialize caching fields for speeding up ExecFindPartition
*/
partdesc->last_found_datum_index = -1;
diff --git a/src/backend/statistics/dependencies.c
b/src/backend/statistics/dependencies.c
index 81bcf76cc1c..a26b254a6f8 100644
--- a/src/backend/statistics/dependencies.c
+++ b/src/backend/statistics/dependencies.c
@@ -70,7 +70,7 @@ static bool dependency_is_fully_matched(MVDependency
*dependency,
static bool dependency_is_compatible_clause(Node *clause, Index relid,
AttrNumber *attnum);
static bool dependency_is_compatible_expression(Node *clause, Index relid,
-
List *statlist, Node **expr);
+
List *statlist, Node **stat_expr_p);
static MVDependency *find_strongest_dependency(MVDependencies **dependencies,
int ndependencies, Bitmapset *attnums);
static Selectivity clauselist_apply_dependencies(PlannerInfo *root, List
*clauses,
@@ -1146,7 +1146,7 @@ clauselist_apply_dependencies(PlannerInfo *root, List
*clauses,
* expression into *expr.
*/
static bool
-dependency_is_compatible_expression(Node *clause, Index relid, List *statlist,
Node **expr)
+dependency_is_compatible_expression(Node *clause, Index relid, List *statlist,
Node **stat_expr_p)
{
ListCell *lc,
*lc2;
@@ -1170,17 +1170,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;
@@ -1196,7 +1196,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" */
@@ -1245,7 +1245,7 @@ dependency_is_compatible_expression(Node *clause, Index
relid, List *statlist, N
BoolExpr *bool_expr = (BoolExpr *) clause;
/* start with no expression (we'll use the first match) */
- *expr = NULL;
+ *stat_expr_p = NULL;
foreach(lc, bool_expr->args)
{
@@ -1259,11 +1259,11 @@ dependency_is_compatible_expression(Node *clause, Index
relid, List *statlist, N
statlist, &or_expr))
return false;
- if (*expr == NULL)
- *expr = or_expr;
+ if (*stat_expr_p == NULL)
+ *stat_expr_p = or_expr;
/* ensure all the expressions are the same */
- if (!equal(or_expr, *expr))
+ if (!equal(or_expr, *stat_expr_p))
return false;
}
@@ -1311,7 +1311,7 @@ dependency_is_compatible_expression(Node *clause, Index
relid, List *statlist, N
if (equal(clause_expr, stat_expr))
{
- *expr = stat_expr;
+ *stat_expr_p = stat_expr;
return true;
}
}
diff --git a/src/backend/statistics/extended_stats.c
b/src/backend/statistics/extended_stats.c
index f0d90f09b07..515095faa4b 100644
--- a/src/backend/statistics/extended_stats.c
+++ b/src/backend/statistics/extended_stats.c
@@ -1040,7 +1040,7 @@ build_sorted_items(StatsBuildData *data, int *nitems,
Size len;
SortItem *items;
Datum *values;
- bool *isnull;
+ bool *nulls;
char *ptr;
int *typlen;
@@ -1060,7 +1060,7 @@ build_sorted_items(StatsBuildData *data, int *nitems,
values = (Datum *) ptr;
ptr += nvalues * sizeof(Datum);
- isnull = (bool *) ptr;
+ nulls = (bool *) ptr;
ptr += nvalues * sizeof(bool);
/* make sure we consumed the whole buffer exactly */
@@ -1071,7 +1071,7 @@ build_sorted_items(StatsBuildData *data, int *nitems,
for (i = 0; i < data->numrows; i++)
{
items[nrows].values = &values[nrows * numattrs];
- items[nrows].isnull = &isnull[nrows * numattrs];
+ items[nrows].isnull = &nulls[nrows * numattrs];
nrows++;
}
diff --git a/src/backend/storage/aio/read_stream.c
b/src/backend/storage/aio/read_stream.c
index e7dbbe03326..c865fbc2c9f 100644
--- a/src/backend/storage/aio/read_stream.c
+++ b/src/backend/storage/aio/read_stream.c
@@ -1304,19 +1304,19 @@ read_stream_next_buffer(ReadStream *stream, void
**per_buffer_data)
*/
if (stream->per_buffer_data)
{
- void *per_buffer_data;
+ void *prev_per_buffer_data;
- per_buffer_data = get_per_buffer_data(stream,
-
oldest_buffer_index == 0 ?
-
stream->queue_size - 1 :
-
oldest_buffer_index - 1);
+ prev_per_buffer_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(prev_per_buffer_data, stream->per_buffer_data_size);
#elif defined(USE_VALGRIND)
/* Tell it ourselves. */
- VALGRIND_MAKE_MEM_NOACCESS(per_buffer_data,
+ VALGRIND_MAKE_MEM_NOACCESS(prev_per_buffer_data,
stream->per_buffer_data_size);
#endif
}
diff --git a/src/backend/storage/buffer/bufmgr.c
b/src/backend/storage/buffer/bufmgr.c
index 17f142e4c5b..7492bd89d10 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -1280,7 +1280,7 @@ ReadBuffer_common(Relation rel, SMgrRelation smgr, char
smgr_persistence,
{
ReadBuffersOperation operation;
Buffer buffer;
- int flags;
+ int readflags;
char persistence;
/*
@@ -1302,7 +1302,7 @@ ReadBuffer_common(Relation rel, SMgrRelation smgr, char
smgr_persistence,
*/
if (unlikely(blockNum == P_NEW))
{
- uint32 flags = EB_SKIP_EXTENSION_LOCK;
+ uint32 ebflags = EB_SKIP_EXTENSION_LOCK;
/*
* Since no-one else can be looking at the page contents yet,
there is
@@ -1310,9 +1310,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;
+ ebflags |= EB_LOCK_FIRST;
- return ExtendBufferedRel(BMR_REL(rel), forkNum, strategy,
flags);
+ return ExtendBufferedRel(BMR_REL(rel), forkNum, strategy,
ebflags);
}
if (rel)
@@ -1350,9 +1350,9 @@ ReadBuffer_common(Relation rel, SMgrRelation smgr, char
smgr_persistence,
* waiting, there is no benefit in actually executing the IO
* asynchronously, it would just add dispatch overhead.
*/
- flags = READ_BUFFERS_SYNCHRONOUSLY;
+ readflags = READ_BUFFERS_SYNCHRONOUSLY;
if (mode == RBM_ZERO_ON_ERROR)
- flags |= READ_BUFFERS_ZERO_ON_ERROR;
+ readflags |= READ_BUFFERS_ZERO_ON_ERROR;
operation.smgr = smgr;
operation.rel = rel;
operation.persistence = persistence;
@@ -1361,7 +1361,7 @@ ReadBuffer_common(Relation rel, SMgrRelation smgr, char
smgr_persistence,
if (StartReadBuffer(&operation,
&buffer,
blockNum,
- flags))
+ readflags))
WaitReadBuffers(&operation);
return buffer;
diff --git a/src/backend/utils/adt/jsonpath_exec.c
b/src/backend/utils/adt/jsonpath_exec.c
index 9a37e6fe663..18021d60af1 100644
--- a/src/backend/utils/adt/jsonpath_exec.c
+++ b/src/backend/utils/adt/jsonpath_exec.c
@@ -388,7 +388,7 @@ static int compareDatetime(Datum val1, Oid typid1, Datum
val2, Oid typid2,
static void checkTimezoneIsUsedForCast(bool useTz, const char *type1,
const char *type2);
-static void JsonTableInitOpaque(TableFuncScanState *state, int natts);
+static void JsonTableInitOpaque(TableFuncScanState *tscanstate, int natts);
static JsonTablePlanState *JsonTableInitPlan(JsonTableExecContext *cxt,
JsonTablePlan *plan,
JsonTablePlanState *parentstate,
@@ -1921,32 +1921,32 @@ executeBoolItem(JsonPathExecContext *cxt, JsonPathItem
*jsp,
* check that there are no errors at all.
*/
JsonValueList vals;
- JsonPathExecResult res;
+ JsonPathExecResult jper;
bool isempty;
JsonValueListInit(&vals);
- res = executeItemOptUnwrapResultNoThrow(cxt,
&larg, jb,
-
false, &vals);
+ jper = executeItemOptUnwrapResultNoThrow(cxt,
&larg, jb,
+
false, &vals);
isempty = JsonValueListIsEmpty(&vals);
JsonValueListClear(&vals);
- if (jperIsError(res))
+ if (jperIsError(jper))
return jpbUnknown;
return isempty ? jpbFalse : jpbTrue;
}
else
{
- JsonPathExecResult res =
+ JsonPathExecResult jper =
executeItemOptUnwrapResultNoThrow(cxt,
&larg, jb,
false, NULL);
- if (jperIsError(res))
+ if (jperIsError(jper))
return jpbUnknown;
- return res == jperOk ? jpbTrue : jpbFalse;
+ return jper == jperOk ? jpbTrue : jpbFalse;
}
default:
@@ -2077,7 +2077,7 @@ executePredicate(JsonPathExecContext *cxt, JsonPathItem
*pred,
bool unwrapRightArg, JsonPathPredicateCallback
exec,
void *param)
{
- JsonPathExecResult res;
+ JsonPathExecResult jper;
JsonValueListIterator lseqit;
JsonValueList lseq;
JsonValueList rseq;
@@ -2089,8 +2089,8 @@ executePredicate(JsonPathExecContext *cxt, JsonPathItem
*pred,
JsonValueListInit(&rseq);
/* Left argument is always auto-unwrapped. */
- res = executeItemOptUnwrapResultNoThrow(cxt, larg, jb, true, &lseq);
- if (jperIsError(res))
+ jper = executeItemOptUnwrapResultNoThrow(cxt, larg, jb, true, &lseq);
+ if (jperIsError(jper))
{
error = true;
goto exit;
@@ -2099,9 +2099,9 @@ executePredicate(JsonPathExecContext *cxt, JsonPathItem
*pred,
if (rarg)
{
/* Right argument is conditionally auto-unwrapped. */
- res = executeItemOptUnwrapResultNoThrow(cxt, rarg, jb,
-
unwrapRightArg, &rseq);
- if (jperIsError(res))
+ jper = executeItemOptUnwrapResultNoThrow(cxt, rarg, jb,
+
unwrapRightArg, &rseq);
+ if (jperIsError(jper))
{
error = true;
goto exit;
@@ -4425,10 +4425,10 @@ GetJsonTableExecContext(TableFuncScanState *state,
const char *fname)
* JsonTablePlan given in TableFunc.
*/
static void
-JsonTableInitOpaque(TableFuncScanState *state, int natts)
+JsonTableInitOpaque(TableFuncScanState *tscanstate, int natts)
{
JsonTableExecContext *cxt;
- PlanState *ps = &state->ss.ps;
+ PlanState *ps = &tscanstate->ss.ps;
TableFuncScan *tfs = castNode(TableFuncScan, ps->plan);
TableFunc *tf = tfs->tablefunc;
JsonTablePlan *rootplan = (JsonTablePlan *) tf->plan;
@@ -4442,30 +4442,30 @@ JsonTableInitOpaque(TableFuncScanState *state, int
natts)
* Evaluate JSON_TABLE() PASSING arguments to be passed to the jsonpath
* executor via JsonPathVariables.
*/
- if (state->passingvalexprs)
+ if (tscanstate->passingvalexprs)
{
ListCell *exprlc;
ListCell *namelc;
- Assert(list_length(state->passingvalexprs) ==
+ Assert(list_length(tscanstate->passingvalexprs) ==
list_length(je->passing_names));
- forboth(exprlc, state->passingvalexprs,
+ forboth(exprlc, tscanstate->passingvalexprs,
namelc, je->passing_names)
{
- ExprState *state = lfirst_node(ExprState, exprlc);
+ ExprState *exprstate = lfirst_node(ExprState, exprlc);
String *name = lfirst_node(String, namelc);
JsonPathVariable *var = palloc_object(JsonPathVariable);
var->name = pstrdup(name->sval);
var->namelen = strlen(var->name);
- var->typid = exprType((Node *) state->expr);
- var->typmod = exprTypmod((Node *) state->expr);
+ var->typid = exprType((Node *) exprstate->expr);
+ var->typmod = exprTypmod((Node *) exprstate->expr);
/*
* Evaluate the expression and save the value to be
returned by
* GetJsonPathVar().
*/
- var->value = ExecEvalExpr(state, ps->ps_ExprContext,
+ var->value = ExecEvalExpr(exprstate, ps->ps_ExprContext,
&var->isnull);
args = lappend(args, var);
@@ -4481,7 +4481,7 @@ JsonTableInitOpaque(TableFuncScanState *state, int natts)
cxt->rootplanstate = JsonTableInitPlan(cxt, rootplan, NULL, args,
CurrentMemoryContext);
- state->opaque = cxt;
+ tscanstate->opaque = cxt;
}
/*
diff --git a/src/backend/utils/adt/pg_upgrade_support.c
b/src/backend/utils/adt/pg_upgrade_support.c
index b505a6b4fee..760991f1adc 100644
--- a/src/backend/utils/adt/pg_upgrade_support.c
+++ b/src/backend/utils/adt/pg_upgrade_support.c
@@ -227,10 +227,10 @@ binary_upgrade_create_empty_extension(PG_FUNCTION_ARGS)
deconstruct_array_builtin(textArray, TEXTOID, &textDatums,
NULL, &ndatums);
for (i = 0; i < ndatums; i++)
{
- char *extName =
TextDatumGetCString(textDatums[i]);
- Oid extOid =
get_extension_oid(extName, false);
+ char *reqExtName =
TextDatumGetCString(textDatums[i]);
+ Oid reqExtOid =
get_extension_oid(reqExtName, false);
- requiredExtensions = lappend_oid(requiredExtensions,
extOid);
+ requiredExtensions = lappend_oid(requiredExtensions,
reqExtOid);
}
}
diff --git a/src/backend/utils/adt/timestamp.c
b/src/backend/utils/adt/timestamp.c
index 9c17ba2f905..8ef16c9ad4c 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -6127,7 +6127,7 @@ interval_part_common(PG_FUNCTION_ARGS, bool retnumeric)
Interval *interval = PG_GETARG_INTERVAL_P(1);
int64 intresult;
int type,
- val;
+ fieldval;
char *lowunits;
struct pg_itm tt,
*tm = &tt;
@@ -6136,13 +6136,13 @@ interval_part_common(PG_FUNCTION_ARGS, bool retnumeric)
VARSIZE_ANY_EXHDR(units),
false);
- type = DecodeUnits(0, lowunits, &val);
+ type = DecodeUnits(0, lowunits, &fieldval);
if (type == UNKNOWN_FIELD)
- type = DecodeSpecial(0, lowunits, &val);
+ type = DecodeSpecial(0, lowunits, &fieldval);
if (INTERVAL_NOT_FINITE(interval))
{
- double r = NonFiniteIntervalPart(type, val, lowunits,
+ double r = NonFiniteIntervalPart(type, fieldval,
lowunits,
INTERVAL_IS_NOBEGIN(interval));
if (r != 0.0)
@@ -6170,7 +6170,7 @@ interval_part_common(PG_FUNCTION_ARGS, bool retnumeric)
if (type == UNITS)
{
interval2itm(*interval, tm);
- switch (val)
+ switch (fieldval)
{
case DTK_MICROSEC:
intresult = tm->tm_sec * INT64CONST(1000000) +
tm->tm_usec;
@@ -6260,13 +6260,13 @@ interval_part_common(PG_FUNCTION_ARGS, bool retnumeric)
intresult = 0;
}
}
- else if (type == RESERV && val == DTK_EPOCH)
+ else if (type == RESERV && fieldval == DTK_EPOCH)
{
if (retnumeric)
{
Numeric result;
int64 secs_from_day_month;
- int64 val;
+ int64 tmpval;
/*
* To do this calculation in integer arithmetic even
though
@@ -6289,9 +6289,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,
&tmpval) &&
+ !pg_add_s64_overflow(tmpval, interval->time,
&tmpval))
+ result = int64_div_fast_to_numeric(tmpval, 6);
else
result =
numeric_add_safe(int64_div_fast_to_numeric(interval->time, 6),
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 8b2ebb42332..bf02692f237 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -3253,7 +3253,7 @@ appendStringInfoRegexpSubstr(StringInfo str, text
*replace_text,
while (p < p_end)
{
- const char *chunk_start = p;
+ const char *replace_start = p;
int so;
int eo;
@@ -3263,8 +3263,8 @@ appendStringInfoRegexpSubstr(StringInfo str, text
*replace_text,
p = p_end;
/* Copy the text we just scanned over, if any. */
- if (p > chunk_start)
- appendBinaryStringInfo(str, chunk_start, p -
chunk_start);
+ if (p > replace_start)
+ appendBinaryStringInfo(str, replace_start, p -
replace_start);
/* Done if at end of string, else advance over escape char. */
if (p >= p_end)
@@ -4794,7 +4794,7 @@ Datum
text_format(PG_FUNCTION_ARGS)
{
text *fmt;
- StringInfoData str;
+ StringInfoData result_str;
const char *cp;
const char *start_ptr;
const char *end_ptr;
@@ -4867,7 +4867,7 @@ text_format(PG_FUNCTION_ARGS)
fmt = PG_GETARG_TEXT_PP(0);
start_ptr = VARDATA_ANY(fmt);
end_ptr = start_ptr + VARSIZE_ANY_EXHDR(fmt);
- initStringInfo(&str);
+ initStringInfo(&result_str);
arg = 1; /* next argument
position to print */
/* Scan format string, looking for conversion specifiers. */
@@ -4887,7 +4887,7 @@ text_format(PG_FUNCTION_ARGS)
*/
if (*cp != '%')
{
- appendStringInfoCharMacro(&str, *cp);
+ appendStringInfoCharMacro(&result_str, *cp);
continue;
}
@@ -4896,7 +4896,7 @@ text_format(PG_FUNCTION_ARGS)
/* Easy case: %% outputs a single % */
if (*cp == '%')
{
- appendStringInfoCharMacro(&str, *cp);
+ appendStringInfoCharMacro(&result_str, *cp);
continue;
}
@@ -5029,7 +5029,7 @@ text_format(PG_FUNCTION_ARGS)
case 's':
case 'I':
case 'L':
- text_format_string_conversion(&str, *cp,
&typoutputfinfo,
+ text_format_string_conversion(&result_str, *cp,
&typoutputfinfo,
value, isNull,
flags, width);
break;
@@ -5051,8 +5051,8 @@ text_format(PG_FUNCTION_ARGS)
pfree(nulls);
/* Generate results. */
- result = cstring_to_text_with_len(str.data, str.len);
- pfree(str.data);
+ result = cstring_to_text_with_len(result_str.data, result_str.len);
+ pfree(result_str.data);
PG_RETURN_TEXT_P(result);
}
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c
index a46b0ae70e2..81a5d433bc7 100644
--- a/src/backend/utils/cache/inval.c
+++ b/src/backend/utils/cache/inval.c
@@ -469,7 +469,7 @@ static void
AddRelcacheInvalidationMessage(InvalidationMsgsGroup *group,
Oid dbId, Oid relId)
{
- SharedInvalidationMessage msg;
+ SharedInvalidationMessage invalmsg;
/*
* Don't add a duplicate item. We assume dbId need not be checked
because
@@ -483,13 +483,13 @@ AddRelcacheInvalidationMessage(InvalidationMsgsGroup
*group,
return);
/* OK, add the item */
- msg.rc.id = SHAREDINVALRELCACHE_ID;
- msg.rc.dbId = dbId;
- msg.rc.relId = relId;
+ invalmsg.rc.id = SHAREDINVALRELCACHE_ID;
+ invalmsg.rc.dbId = dbId;
+ invalmsg.rc.relId = relId;
/* check AddCatcacheInvalidationMessage() for an explanation */
- VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg));
+ VALGRIND_MAKE_MEM_DEFINED(&invalmsg, sizeof(invalmsg));
- AddInvalidationMessage(group, RelCacheMsgs, &msg);
+ AddInvalidationMessage(group, RelCacheMsgs, &invalmsg);
}
/*
@@ -503,7 +503,7 @@ static void
AddRelsyncInvalidationMessage(InvalidationMsgsGroup *group,
Oid dbId, Oid relId)
{
- SharedInvalidationMessage msg;
+ SharedInvalidationMessage invalmsg;
/* Don't add a duplicate item. */
ProcessMessageSubGroup(group, RelCacheMsgs,
@@ -513,13 +513,13 @@ AddRelsyncInvalidationMessage(InvalidationMsgsGroup
*group,
return);
/* OK, add the item */
- msg.rs.id = SHAREDINVALRELSYNC_ID;
- msg.rs.dbId = dbId;
- msg.rs.relid = relId;
+ invalmsg.rs.id = SHAREDINVALRELSYNC_ID;
+ invalmsg.rs.dbId = dbId;
+ invalmsg.rs.relid = relId;
/* check AddCatcacheInvalidationMessage() for an explanation */
- VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg));
+ VALGRIND_MAKE_MEM_DEFINED(&invalmsg, sizeof(invalmsg));
- AddInvalidationMessage(group, RelCacheMsgs, &msg);
+ AddInvalidationMessage(group, RelCacheMsgs, &invalmsg);
}
/*
@@ -531,7 +531,7 @@ static void
AddSnapshotInvalidationMessage(InvalidationMsgsGroup *group,
Oid dbId, Oid relId)
{
- SharedInvalidationMessage msg;
+ SharedInvalidationMessage invalmsg;
/* Don't add a duplicate item */
/* We assume dbId need not be checked because it will never change */
@@ -541,13 +541,13 @@ AddSnapshotInvalidationMessage(InvalidationMsgsGroup
*group,
return);
/* OK, add the item */
- msg.sn.id = SHAREDINVALSNAPSHOT_ID;
- msg.sn.dbId = dbId;
- msg.sn.relId = relId;
+ invalmsg.sn.id = SHAREDINVALSNAPSHOT_ID;
+ invalmsg.sn.dbId = dbId;
+ invalmsg.sn.relId = relId;
/* check AddCatcacheInvalidationMessage() for an explanation */
- VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg));
+ VALGRIND_MAKE_MEM_DEFINED(&invalmsg, sizeof(invalmsg));
- AddInvalidationMessage(group, RelCacheMsgs, &msg);
+ AddInvalidationMessage(group, RelCacheMsgs, &invalmsg);
}
/*
@@ -1007,7 +1007,7 @@ PostPrepare_Inval(void)
* see also xact_redo_commit() and xact_desc_commit()
*/
int
-xactGetCommittedInvalidationMessages(SharedInvalidationMessage **msgs,
+xactGetCommittedInvalidationMessages(SharedInvalidationMessage **invalmsgs,
bool
*RelcacheInitFileInval)
{
SharedInvalidationMessage *msgarray;
@@ -1018,7 +1018,7 @@
xactGetCommittedInvalidationMessages(SharedInvalidationMessage **msgs,
if (transInvalInfo == NULL)
{
*RelcacheInitFileInval = false;
- *msgs = NULL;
+ *invalmsgs = NULL;
return 0;
}
@@ -1043,7 +1043,7 @@
xactGetCommittedInvalidationMessages(SharedInvalidationMessage **msgs,
nummsgs = NumMessagesInGroup(&transInvalInfo->PriorCmdInvalidMsgs) +
NumMessagesInGroup(&transInvalInfo->ii.CurrentCmdInvalidMsgs);
- *msgs = msgarray = (SharedInvalidationMessage *)
+ *invalmsgs = msgarray = (SharedInvalidationMessage *)
MemoryContextAlloc(CurTransactionContext,
nummsgs *
sizeof(SharedInvalidationMessage));
@@ -1083,7 +1083,7 @@
xactGetCommittedInvalidationMessages(SharedInvalidationMessage **msgs,
* function, we might still fail.
*/
int
-inplaceGetInvalidationMessages(SharedInvalidationMessage **msgs,
+inplaceGetInvalidationMessages(SharedInvalidationMessage **invalmsgs,
bool
*RelcacheInitFileInval)
{
SharedInvalidationMessage *msgarray;
@@ -1094,13 +1094,13 @@
inplaceGetInvalidationMessages(SharedInvalidationMessage **msgs,
if (inplaceInvalInfo == NULL)
{
*RelcacheInitFileInval = false;
- *msgs = NULL;
+ *invalmsgs = NULL;
return 0;
}
*RelcacheInitFileInval = inplaceInvalInfo->RelcacheInitFileInval;
nummsgs = NumMessagesInGroup(&inplaceInvalInfo->CurrentCmdInvalidMsgs);
- *msgs = msgarray = palloc_array(SharedInvalidationMessage, nummsgs);
+ *invalmsgs = msgarray = palloc_array(SharedInvalidationMessage,
nummsgs);
nmsgs = 0;
ProcessMessageSubGroupMulti(&inplaceInvalInfo->CurrentCmdInvalidMsgs,
diff --git a/src/backend/utils/mmgr/freepage.c
b/src/backend/utils/mmgr/freepage.c
index d7195685f69..71a50741e43 100644
--- a/src/backend/utils/mmgr/freepage.c
+++ b/src/backend/utils/mmgr/freepage.c
@@ -1477,7 +1477,7 @@ FreePageManagerPutInternal(FreePageManager *fpm, Size
first_page, Size npages,
bool soft)
{
char *base = fpm_segment_base(fpm);
- FreePageBtreeSearchResult result;
+ FreePageBtreeSearchResult searchresult;
FreePageBtreeLeafKey *prevkey = NULL;
FreePageBtreeLeafKey *nextkey = NULL;
FreePageBtree *np;
@@ -1564,19 +1564,19 @@ FreePageManagerPutInternal(FreePageManager *fpm, Size
first_page, Size npages,
}
/* Search the btree. */
- FreePageBtreeSearch(fpm, first_page, &result);
- Assert(!result.found);
- if (result.index > 0)
- prevkey = &result.page->u.leaf_key[result.index - 1];
- if (result.index < result.page->hdr.nused)
+ FreePageBtreeSearch(fpm, first_page, &searchresult);
+ Assert(!searchresult.found);
+ if (searchresult.index > 0)
+ prevkey = &searchresult.page->u.leaf_key[searchresult.index -
1];
+ if (searchresult.index < searchresult.page->hdr.nused)
{
- np = result.page;
- nindex = result.index;
- nextkey = &result.page->u.leaf_key[result.index];
+ np = searchresult.page;
+ nindex = searchresult.index;
+ nextkey = &searchresult.page->u.leaf_key[searchresult.index];
}
else
{
- np = FreePageBtreeFindRightSibling(base, result.page);
+ np = FreePageBtreeFindRightSibling(base, searchresult.page);
nindex = 0;
if (np != NULL)
nextkey = &np->u.leaf_key[0];
@@ -1649,7 +1649,7 @@ FreePageManagerPutInternal(FreePageManager *fpm, Size
first_page, Size npages,
}
/* Split leaf page and as many of its ancestors as necessary. */
- if (result.split_pages > 0)
+ if (searchresult.split_pages > 0)
{
/*
* NB: We could consider various coping strategies here to
avoid a
@@ -1667,7 +1667,7 @@ FreePageManagerPutInternal(FreePageManager *fpm, Size
first_page, Size npages,
return 0;
/* Check whether we need to allocate more btree pages to split.
*/
- if (result.split_pages > fpm->btree_recycle_count)
+ if (searchresult.split_pages > fpm->btree_recycle_count)
{
Size pages_needed;
Size recycle_page;
@@ -1682,7 +1682,7 @@ FreePageManagerPutInternal(FreePageManager *fpm, Size
first_page, Size npages,
* ever use a tiny number of pages compared to the
number under
* management. If it does, something's badly screwed
up.
*/
- pages_needed = result.split_pages -
fpm->btree_recycle_count;
+ pages_needed = searchresult.split_pages -
fpm->btree_recycle_count;
for (i = 0; i < pages_needed; ++i)
{
if (!FreePageManagerGetInternal(fpm, 1,
&recycle_page))
@@ -1698,7 +1698,7 @@ FreePageManagerPutInternal(FreePageManager *fpm, Size
first_page, Size npages,
* we don't bother. Consolidation can't be possible now
if it
* wasn't previously.)
*/
- FreePageBtreeSearch(fpm, first_page, &result);
+ FreePageBtreeSearch(fpm, first_page, &searchresult);
/*
* The act of allocating pages for use in constructing
our btree
@@ -1707,13 +1707,13 @@ FreePageManagerPutInternal(FreePageManager *fpm, Size
first_page, Size npages,
* less if we fortuitously allocated a chunk that freed
up a slot
* on the page we need to update.
*/
- Assert(result.split_pages <= fpm->btree_recycle_count);
+ Assert(searchresult.split_pages <=
fpm->btree_recycle_count);
}
/* If we still need to perform a split, do it. */
- if (result.split_pages > 0)
+ if (searchresult.split_pages > 0)
{
- FreePageBtree *split_target = result.page;
+ FreePageBtree *split_target = searchresult.page;
FreePageBtree *child = NULL;
Size key = first_page;
@@ -1822,12 +1822,12 @@ FreePageManagerPutInternal(FreePageManager *fpm, Size
first_page, Size npages,
}
/* Physically add the key to the page. */
- Assert(result.page->hdr.nused < FPM_ITEMS_PER_LEAF_PAGE);
- FreePageBtreeInsertLeaf(result.page, result.index, first_page, npages);
+ Assert(searchresult.page->hdr.nused < FPM_ITEMS_PER_LEAF_PAGE);
+ FreePageBtreeInsertLeaf(searchresult.page, searchresult.index,
first_page, npages);
/* If new first key on page, ancestors might need adjustment. */
- if (result.index == 0)
- FreePageBtreeAdjustAncestorKeys(fpm, result.page);
+ if (searchresult.index == 0)
+ FreePageBtreeAdjustAncestorKeys(fpm, searchresult.page);
/* Put it on the free list. */
FreePagePushSpanLeader(fpm, first_page, npages);
diff --git a/src/bin/pg_basebackup/pg_receivewal.c
b/src/bin/pg_basebackup/pg_receivewal.c
index 13bd318f672..85f3616beb4 100644
--- a/src/bin/pg_basebackup/pg_receivewal.c
+++ b/src/bin/pg_basebackup/pg_receivewal.c
@@ -60,7 +60,7 @@ static XLogRecPtr endpos = InvalidXLogRecPtr;
static void usage(void);
static DIR *get_destination_dir(char *dest_folder);
static void close_destination_dir(DIR *dest_dir, char *dest_folder);
-static XLogRecPtr FindStreamingStart(uint32 *tli);
+static XLogRecPtr FindStreamingStart(uint32 *tli_p);
static void StreamLog(void);
static bool stop_streaming(XLogRecPtr xlogpos, uint32 timeline,
bool segment_finished);
@@ -266,7 +266,7 @@ close_destination_dir(DIR *dest_dir, char *dest_folder)
* If there are no WAL files in the directory, returns InvalidXLogRecPtr.
*/
static XLogRecPtr
-FindStreamingStart(uint32 *tli)
+FindStreamingStart(uint32 *tli_p)
{
DIR *dir;
struct dirent *dirent;
@@ -487,7 +487,7 @@ FindStreamingStart(uint32 *tli)
XLogSegNoOffsetToRecPtr(high_segno, 0, WalSegSz, high_ptr);
- *tli = high_tli;
+ *tli_p = high_tli;
return high_ptr;
}
else
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 5862758427f..0e6df3fd570 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -387,7 +387,7 @@ typedef struct StatsData
* possibly after some retries when --max-tries is not one. Thus
*
* the number of all transactions =
- * 'skipped' (it was too late to execute them) +
+ * 'cnt_skipped' (it was too late to execute them) +
* 'cnt' (the number of successful transactions) +
* 'failed' (the number of failed transactions).
*
@@ -426,8 +426,8 @@ typedef struct StatsData
*----------
*/
int64 cnt; /* number of successful
transactions, not
- * including
'skipped' */
- int64 skipped; /* number of transactions
skipped under --rate
+ * including
'cnt_skipped' */
+ int64 cnt_skipped; /* number of transactions skipped under
--rate
* and
--latency-limit */
int64 retries; /* number of retries after a
serialization or
* a deadlock
error in all the transactions */
@@ -835,9 +835,9 @@ static bool evaluateExpr(CState *st, PgBenchExpr *expr,
PgBenchValue *retval);
static ConnectionStateEnum executeMetaCommand(CState *st, pg_time_usec_t *now);
static void doLog(TState *thread, CState *st,
- StatsData *agg, bool skipped, double latency,
double lag);
+ StatsData *agg, bool tx_skipped, double
latency, double lag);
static void processXactStats(TState *thread, CState *st, pg_time_usec_t *now,
- bool skipped,
StatsData *agg);
+ bool tx_skipped,
StatsData *agg);
static void addScript(const ParsedScript *script);
static THREAD_FUNC_RETURN_TYPE THREAD_FUNC_CC threadRun(void *arg);
static void finishCon(CState *st);
@@ -1426,7 +1426,7 @@ initStats(StatsData *sd, pg_time_usec_t start)
{
sd->start_time = start;
sd->cnt = 0;
- sd->skipped = 0;
+ sd->cnt_skipped = 0;
sd->retries = 0;
sd->retried = 0;
sd->serialization_failures = 0;
@@ -1440,14 +1440,14 @@ initStats(StatsData *sd, pg_time_usec_t start)
* Accumulate one additional item into the given stats object.
*/
static void
-accumStats(StatsData *stats, bool skipped, double lat, double lag,
+accumStats(StatsData *stats, bool tx_skipped, double lat, double lag,
EStatus estatus, int64 tries)
{
/* Record the skipped transaction */
- if (skipped)
+ if (tx_skipped)
{
/* no latency to record on skipped transactions */
- stats->skipped++;
+ stats->cnt_skipped++;
return;
}
@@ -4594,9 +4594,9 @@ getFailures(const StatsData *stats)
* that is not successfully processed.
*/
static const char *
-getResultString(bool skipped, EStatus estatus)
+getResultString(bool tx_skipped, EStatus estatus)
{
- if (skipped)
+ if (tx_skipped)
return "skipped";
else if (failures_detailed)
{
@@ -4628,7 +4628,7 @@ getResultString(bool skipped, EStatus estatus)
*/
static void
doLog(TState *thread, CState *st,
- StatsData *agg, bool skipped, double latency, double lag)
+ StatsData *agg, bool tx_skipped, double latency, double lag)
{
FILE *logfile = thread->logfile;
pg_time_usec_t now = pg_time_now() + epoch_shift;
@@ -4660,7 +4660,7 @@ doLog(TState *thread, CState *st,
double lag_sum2 = 0.0;
double lag_min = 0.0;
double lag_max = 0.0;
- int64 skipped = 0;
+ int64 cnt_skipped = 0;
int64 serialization_failures = 0;
int64 deadlock_failures = 0;
int64 other_sql_failures = 0;
@@ -4690,8 +4690,8 @@ doLog(TState *thread, CState *st,
lag_max);
if (latency_limit)
- skipped = agg->skipped;
- fprintf(logfile, " " INT64_FORMAT, skipped);
+ cnt_skipped = agg->cnt_skipped;
+ fprintf(logfile, " " INT64_FORMAT, cnt_skipped);
if (max_tries != 1)
{
@@ -4718,12 +4718,12 @@ doLog(TState *thread, CState *st,
}
/* accumulate the current transaction */
- accumStats(agg, skipped, latency, lag, st->estatus, st->tries);
+ accumStats(agg, tx_skipped, latency, lag, st->estatus,
st->tries);
}
else
{
/* no, print raw transactions */
- if (!skipped && st->estatus == ESTATUS_NO_ERROR)
+ if (!tx_skipped && st->estatus == ESTATUS_NO_ERROR)
fprintf(logfile, "%d " INT64_FORMAT " %.0f %d "
INT64_FORMAT " "
INT64_FORMAT,
st->id, st->cnt, latency, st->use_file,
@@ -4731,7 +4731,7 @@ doLog(TState *thread, CState *st,
else
fprintf(logfile, "%d " INT64_FORMAT " %s %d "
INT64_FORMAT " "
INT64_FORMAT,
- st->id, st->cnt,
getResultString(skipped, st->estatus),
+ st->id, st->cnt,
getResultString(tx_skipped, st->estatus),
st->use_file, now / 1000000, now %
1000000);
if (throttle_delay)
@@ -4751,14 +4751,14 @@ doLog(TState *thread, CState *st,
*/
static void
processXactStats(TState *thread, CState *st, pg_time_usec_t *now,
- bool skipped, StatsData *agg)
+ bool tx_skipped, StatsData *agg)
{
double latency = 0.0,
lag = 0.0;
bool detailed = progress || throttle_delay || latency_limit
||
use_log || per_script_stats;
- if (detailed && !skipped && st->estatus == ESTATUS_NO_ERROR)
+ if (detailed && !tx_skipped && st->estatus == ESTATUS_NO_ERROR)
{
pg_time_now_lazy(now);
@@ -4768,7 +4768,7 @@ processXactStats(TState *thread, CState *st,
pg_time_usec_t *now,
}
/* keep detailed thread stats */
- accumStats(&thread->stats, skipped, latency, lag, st->estatus,
st->tries);
+ accumStats(&thread->stats, tx_skipped, latency, lag, st->estatus,
st->tries);
/* count transactions over the latency limit, if needed */
if (latency_limit && latency > latency_limit)
@@ -4778,11 +4778,11 @@ processXactStats(TState *thread, CState *st,
pg_time_usec_t *now,
st->cnt++;
if (use_log)
- doLog(thread, st, agg, skipped, latency, lag);
+ doLog(thread, st, agg, tx_skipped, latency, lag);
/* XXX could use a mutex here, but we choose not to */
if (per_script_stats)
- accumStats(&sql_script[st->use_file].stats, skipped, latency,
lag,
+ accumStats(&sql_script[st->use_file].stats, tx_skipped,
latency, lag,
st->estatus, st->tries);
}
@@ -6336,7 +6336,7 @@ printProgressReport(TState *threads, int64 test_start,
pg_time_usec_t now,
mergeSimpleStats(&cur.latency, &threads[i].stats.latency);
mergeSimpleStats(&cur.lag, &threads[i].stats.lag);
cur.cnt += threads[i].stats.cnt;
- cur.skipped += threads[i].stats.skipped;
+ cur.cnt_skipped += threads[i].stats.cnt_skipped;
cur.retries += threads[i].stats.retries;
cur.retried += threads[i].stats.retried;
cur.serialization_failures +=
@@ -6383,7 +6383,7 @@ printProgressReport(TState *threads, int64 test_start,
pg_time_usec_t now,
fprintf(stderr, ", lag %.3f ms", lag);
if (latency_limit)
fprintf(stderr, ", " INT64_FORMAT " skipped",
- cur.skipped - last->skipped);
+ cur.cnt_skipped - last->cnt_skipped);
}
/* it can be non-zero only if max_tries is not equal to one */
@@ -6451,7 +6451,7 @@ printResults(StatsData *total,
{
/* tps is about actually executed transactions during benchmarking */
int64 failures = getFailures(total);
- int64 total_cnt = total->cnt + total->skipped + failures;
+ int64 total_cnt = total->cnt + total->cnt_skipped + failures;
double bench_duration = PG_TIME_GET_DOUBLE(total_duration);
double tps = total->cnt / bench_duration;
@@ -6517,7 +6517,7 @@ printResults(StatsData *total,
if (throttle_delay && latency_limit)
printf("number of transactions skipped: " INT64_FORMAT "
(%.3f%%)\n",
- total->skipped, 100.0 * total->skipped / total_cnt);
+ total->cnt_skipped, 100.0 * total->cnt_skipped /
total_cnt);
if (latency_limit)
printf("number of transactions above the %.1f ms latency limit:
" INT64_FORMAT "/" INT64_FORMAT " (%.3f%%)\n",
@@ -6578,7 +6578,7 @@ printResults(StatsData *total,
StatsData *sstats = &sql_script[i].stats;
int64 script_failures =
getFailures(sstats);
int64 script_total_cnt =
- sstats->cnt + sstats->skipped +
script_failures;
+ sstats->cnt + sstats->cnt_skipped +
script_failures;
printf("SQL script %d: %s\n"
" - weight: %d (targets %.1f%% of
total)\n"
@@ -6629,8 +6629,8 @@ printResults(StatsData *total,
if (throttle_delay && latency_limit)
printf(" - number of
transactions skipped: " INT64_FORMAT " (%.3f%%)\n",
- sstats->skipped,
- 100.0 *
sstats->skipped / script_total_cnt);
+ sstats->cnt_skipped,
+ 100.0 *
sstats->cnt_skipped / script_total_cnt);
}
printSimpleStats(" - latency",
&sstats->latency);
@@ -7482,7 +7482,7 @@ main(int argc, char **argv)
mergeSimpleStats(&stats.latency, &thread->stats.latency);
mergeSimpleStats(&stats.lag, &thread->stats.lag);
stats.cnt += thread->stats.cnt;
- stats.skipped += thread->stats.skipped;
+ stats.cnt_skipped += thread->stats.cnt_skipped;
stats.retries += thread->stats.retries;
stats.retried += thread->stats.retried;
stats.serialization_failures +=
thread->stats.serialization_failures;
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 063e2555814..0829face13d 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -1672,7 +1672,7 @@ describeOneTableDetails(const char *schemaname,
if (tableinfo.relkind == RELKIND_SEQUENCE)
{
PGresult *result = NULL;
- printQueryOpt myopt = pset.popt;
+ printQueryOpt popt = pset.popt;
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence
information"));
@@ -1788,12 +1788,12 @@ describeOneTableDetails(const char *schemaname,
printfPQExpBuffer(&title, _("Sequence \"%s.%s\""),
schemaname,
relationname);
- myopt.footers = footers;
- myopt.topt.default_footer = false;
- myopt.title = title.data;
- myopt.translate_header = true;
+ popt.footers = footers;
+ popt.topt.default_footer = false;
+ popt.title = title.data;
+ popt.translate_header = true;
- printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
+ printQuery(res, &popt, pset.queryFout, false, pset.logfile);
pg_free(footers[0]);
pg_free(footers[1]);
@@ -2290,11 +2290,11 @@ describeOneTableDetails(const char *schemaname,
if (PQntuples(result) == 1)
{
- char *schemaname = PQgetvalue(result, 0, 0);
- char *relname = PQgetvalue(result, 0, 1);
+ char *owning_schemaname = PQgetvalue(result, 0,
0);
+ char *owning_relname = PQgetvalue(result, 0, 1);
printfPQExpBuffer(&tmpbuf, _("Owning table: \"%s.%s\""),
- schemaname, relname);
+ owning_schemaname,
owning_relname);
printTableAddFooter(&cont, tmpbuf.data);
}
PQclear(result);
diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c
index 4906f320e77..681574bee79 100644
--- a/src/bin/psql/prompt.c
+++ b/src/bin/psql/prompt.c
@@ -68,17 +68,16 @@
*/
char *
-get_prompt(promptStatus_t status, ConditionalStack cstack)
+get_prompt(promptStatus_t prompt_status, ConditionalStack cstack)
{
#define MAX_PROMPT_SIZE 256
static char destination[MAX_PROMPT_SIZE + 1];
char buf[MAX_PROMPT_SIZE + 1];
bool esc = false;
- const char *p;
const char *prompt_string = "? ";
static size_t last_prompt1_width = 0;
- switch (status)
+ switch (prompt_status)
{
case PROMPT_READY:
prompt_string = pset.prompt1;
@@ -100,7 +99,7 @@ get_prompt(promptStatus_t status, ConditionalStack cstack)
destination[0] = '\0';
- for (p = prompt_string;
+ for (const char *p = prompt_string;
*p && strlen(destination) < sizeof(destination) - 1;
p++)
{
@@ -203,11 +202,11 @@ get_prompt(promptStatus_t status, ConditionalStack cstack)
case 'P':
if (pset.db)
{
- PGpipelineStatus status =
PQpipelineStatus(pset.db);
+ PGpipelineStatus plstatus =
PQpipelineStatus(pset.db);
- if (status == PQ_PIPELINE_ON)
+ if (plstatus == PQ_PIPELINE_ON)
strlcpy(buf, "on",
sizeof(buf));
- else if (status ==
PQ_PIPELINE_ABORTED)
+ else if (plstatus ==
PQ_PIPELINE_ABORTED)
strlcpy(buf, "abort",
sizeof(buf));
else
strlcpy(buf, "off",
sizeof(buf));
@@ -225,7 +224,7 @@ get_prompt(promptStatus_t status, ConditionalStack cstack)
--p;
break;
case 'R':
- switch (status)
+ switch (prompt_status)
{
case PROMPT_READY:
if (cstack != NULL &&
!conditional_active(cstack))
@@ -390,23 +389,23 @@ get_prompt(promptStatus_t status, ConditionalStack cstack)
/* Compute the visible width of PROMPT1, for PROMPT2's %w */
if (prompt_string == pset.prompt1)
{
- char *p = destination;
- char *end = p + strlen(p);
+ char *d = destination;
+ char *end = d + strlen(d);
bool visible = true;
last_prompt1_width = 0;
- while (*p)
+ while (*d)
{
#if defined(USE_READLINE) && defined(RL_PROMPT_START_IGNORE)
- if (*p == RL_PROMPT_START_IGNORE)
+ if (*d == RL_PROMPT_START_IGNORE)
{
visible = false;
- ++p;
+ ++d;
}
- else if (*p == RL_PROMPT_END_IGNORE)
+ else if (*d == RL_PROMPT_END_IGNORE)
{
visible = true;
- ++p;
+ ++d;
}
else
#endif
@@ -414,21 +413,21 @@ get_prompt(promptStatus_t status, ConditionalStack cstack)
int chlen,
chwidth;
- chlen = PQmblen(p, pset.encoding);
- if (p + chlen > end)
+ chlen = PQmblen(d, pset.encoding);
+ if (d + chlen > end)
break; /* Invalid string */
if (visible)
{
- chwidth = PQdsplen(p, pset.encoding);
+ chwidth = PQdsplen(d, pset.encoding);
- if (*p == '\n')
+ if (*d == '\n')
last_prompt1_width = 0;
else if (chwidth > 0)
last_prompt1_width += chwidth;
}
- p += chlen;
+ d += chlen;
}
}
}
diff --git a/src/bin/psql/prompt.h b/src/bin/psql/prompt.h
index 3227cb6eeb7..b3fa4dba5e1 100644
--- a/src/bin/psql/prompt.h
+++ b/src/bin/psql/prompt.h
@@ -12,6 +12,6 @@
/* enum promptStatus_t is now defined by psqlscan.h */
#include "fe_utils/psqlscan.h"
-char *get_prompt(promptStatus_t status, ConditionalStack cstack);
+char *get_prompt(promptStatus_t prompt_status, ConditionalStack cstack);
#endif /* PROMPT_H */
diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c
index b0dd9d54371..73b12625435 100644
--- a/src/fe_utils/print.c
+++ b/src/fe_utils/print.c
@@ -668,7 +668,7 @@ print_aligned_text(const printTableContent *cont, FILE
*fout, bool is_pager)
*width_wrap,
*width_average;
unsigned int *max_nl_lines, /* value split by newlines */
- *curr_nl_line,
+ *curr_nl_lines,
*max_bytes;
unsigned char **format_buf;
unsigned int width_total;
@@ -698,7 +698,7 @@ print_aligned_text(const printTableContent *cont, FILE
*fout, bool is_pager)
max_width = pg_malloc0_array(unsigned int, col_count);
width_wrap = pg_malloc0_array(unsigned int, col_count);
max_nl_lines = pg_malloc0_array(unsigned int, col_count);
- curr_nl_line = pg_malloc0_array(unsigned int, col_count);
+ curr_nl_lines = pg_malloc0_array(unsigned int, col_count);
col_lineptrs = pg_malloc0_array(struct lineptr *, col_count);
max_bytes = pg_malloc0_array(unsigned int, col_count);
format_buf = pg_malloc0_array(unsigned char *, col_count);
@@ -713,7 +713,7 @@ print_aligned_text(const printTableContent *cont, FILE
*fout, bool is_pager)
max_width = NULL;
width_wrap = NULL;
max_nl_lines = NULL;
- curr_nl_line = NULL;
+ curr_nl_lines = NULL;
col_lineptrs = NULL;
max_bytes = NULL;
format_buf = NULL;
@@ -1015,7 +1015,7 @@ print_aligned_text(const printTableContent *cont, FILE
*fout, bool is_pager)
{
pg_wcsformat((const unsigned char *) ptr[j],
strlen(ptr[j]), encoding,
col_lineptrs[j],
max_nl_lines[j]);
- curr_nl_line[j] = 0;
+ curr_nl_lines[j] = 0;
}
memset(bytes_output, 0, col_count * sizeof(int));
@@ -1037,7 +1037,7 @@ print_aligned_text(const printTableContent *cont, FILE
*fout, bool is_pager)
for (j = 0; j < col_count; j++)
{
/* We have a valid array element, so index it */
- struct lineptr *this_line =
&col_lineptrs[j][curr_nl_line[j]];
+ struct lineptr *this_line =
&col_lineptrs[j][curr_nl_lines[j]];
int bytes_to_output;
int chars_to_output =
width_wrap[j];
bool finalspaces = (opt_border == 2
||
@@ -1098,8 +1098,8 @@ print_aligned_text(const printTableContent *cont, FILE
*fout, bool is_pager)
else
{
/* Advance to next newline line
*/
- curr_nl_line[j]++;
- if
(col_lineptrs[j][curr_nl_line[j]].ptr != NULL)
+ curr_nl_lines[j]++;
+ if
(col_lineptrs[j][curr_nl_lines[j]].ptr != NULL)
more_lines = true;
bytes_output[j] = 0;
}
@@ -1107,11 +1107,11 @@ print_aligned_text(const printTableContent *cont, FILE
*fout, bool is_pager)
/* Determine next line's wrap status for this
column */
wrap[j] = PRINT_LINE_WRAP_NONE;
- if (col_lineptrs[j][curr_nl_line[j]].ptr !=
NULL)
+ if (col_lineptrs[j][curr_nl_lines[j]].ptr !=
NULL)
{
if (bytes_output[j] != 0)
wrap[j] = PRINT_LINE_WRAP_WRAP;
- else if (curr_nl_line[j] != 0)
+ else if (curr_nl_lines[j] != 0)
wrap[j] =
PRINT_LINE_WRAP_NEWLINE;
}
@@ -1143,7 +1143,7 @@ print_aligned_text(const printTableContent *cont, FILE
*fout, bool is_pager)
fputs(format->midvrule_wrap,
fout);
else if (wrap[j + 1] ==
PRINT_LINE_WRAP_NEWLINE)
fputs(format->midvrule_nl,
fout);
- else if (col_lineptrs[j +
1][curr_nl_line[j + 1]].ptr == NULL)
+ else if (col_lineptrs[j +
1][curr_nl_lines[j + 1]].ptr == NULL)
fputs(format->midvrule_blank,
fout);
else
fputs(dformat->midvrule, fout);
@@ -1189,7 +1189,7 @@ print_aligned_text(const printTableContent *cont, FILE
*fout, bool is_pager)
pg_free(max_width);
pg_free(width_wrap);
pg_free(max_nl_lines);
- pg_free(curr_nl_line);
+ pg_free(curr_nl_lines);
pg_free(col_lineptrs);
pg_free(max_bytes);
pg_free(format_buf);
diff --git a/src/include/lib/radixtree.h b/src/include/lib/radixtree.h
index 04e495fbd41..aa494b3261a 100644
--- a/src/include/lib/radixtree.h
+++ b/src/include/lib/radixtree.h
@@ -2293,7 +2293,7 @@ RT_COPY_ARRAYS_AND_DELETE(uint8 *dst_chunks, RT_PTR_ALLOC
* dst_children,
* in the caller.
*/
static void pg_noinline
-RT_SHRINK_NODE_256(RT_RADIX_TREE * tree, RT_PTR_ALLOC * parent_slot,
RT_CHILD_PTR node, uint8 chunk)
+RT_SHRINK_NODE_256(RT_RADIX_TREE * tree, RT_PTR_ALLOC * parent_slot,
RT_CHILD_PTR node)
{
RT_NODE_256 *n256 = (RT_NODE_256 *) node.local;
RT_CHILD_PTR newnode;
@@ -2353,7 +2353,7 @@ RT_REMOVE_CHILD_256(RT_RADIX_TREE * tree, RT_PTR_ALLOC *
parent_slot, RT_CHILD_P
shrink_threshold = Min(RT_FANOUT_48 / 4 * 3, shrink_threshold);
if (n256->base.count <= shrink_threshold)
- RT_SHRINK_NODE_256(tree, parent_slot, node, chunk);
+ RT_SHRINK_NODE_256(tree, parent_slot, node);
}
/*
@@ -2361,7 +2361,7 @@ RT_REMOVE_CHILD_256(RT_RADIX_TREE * tree, RT_PTR_ALLOC *
parent_slot, RT_CHILD_P
* in the caller.
*/
static void pg_noinline
-RT_SHRINK_NODE_48(RT_RADIX_TREE * tree, RT_PTR_ALLOC * parent_slot,
RT_CHILD_PTR node, uint8 chunk)
+RT_SHRINK_NODE_48(RT_RADIX_TREE * tree, RT_PTR_ALLOC * parent_slot,
RT_CHILD_PTR node)
{
RT_NODE_48 *n48 = (RT_NODE_48 *) (node.local);
RT_CHILD_PTR newnode;
@@ -2377,12 +2377,12 @@ RT_SHRINK_NODE_48(RT_RADIX_TREE * tree, RT_PTR_ALLOC *
parent_slot, RT_CHILD_PTR
/* copy over all existing entries */
RT_COPY_COMMON(newnode, node);
- for (int chunk = 0; chunk < RT_NODE_MAX_SLOTS; chunk++)
+ for (int i = 0; i < RT_NODE_MAX_SLOTS; i++)
{
- if (n48->slot_idxs[chunk] != RT_INVALID_SLOT_IDX)
+ if (n48->slot_idxs[i] != RT_INVALID_SLOT_IDX)
{
- new16->chunks[destidx] = chunk;
- new16->children[destidx] =
n48->children[n48->slot_idxs[chunk]];
+ new16->chunks[destidx] = i;
+ new16->children[destidx] =
n48->children[n48->slot_idxs[i]];
destidx++;
}
}
@@ -2421,7 +2421,7 @@ RT_REMOVE_CHILD_48(RT_RADIX_TREE * tree, RT_PTR_ALLOC *
parent_slot, RT_CHILD_PT
* node48 anyway.
*/
if (n48->base.count <= shrink_threshold)
- RT_SHRINK_NODE_48(tree, parent_slot, node, chunk);
+ RT_SHRINK_NODE_48(tree, parent_slot, node);
}
/*
diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h
index 051e38c1189..d3853d1c076 100644
--- a/src/include/optimizer/paths.h
+++ b/src/include/optimizer/paths.h
@@ -143,7 +143,7 @@ extern EquivalenceClass
*get_eclass_for_sort_expr(PlannerInfo *root,
Oid opcintype,
Oid collation,
Index sortref,
-
Relids rel,
+
Relids relids,
bool create_it);
extern EquivalenceMember *find_ec_member_matching_expr(EquivalenceClass *ec,
Expr *expr,
diff --git a/src/include/storage/sinval.h b/src/include/storage/sinval.h
index 4d33fdcabe1..baf21dfe97c 100644
--- a/src/include/storage/sinval.h
+++ b/src/include/storage/sinval.h
@@ -154,9 +154,9 @@ extern void HandleCatchupInterrupt(void);
*/
extern void ProcessCatchupInterrupt(void);
-extern int xactGetCommittedInvalidationMessages(SharedInvalidationMessage
**msgs,
+extern int xactGetCommittedInvalidationMessages(SharedInvalidationMessage
**invalmsgs,
bool *RelcacheInitFileInval);
-extern int inplaceGetInvalidationMessages(SharedInvalidationMessage **msgs,
+extern int inplaceGetInvalidationMessages(SharedInvalidationMessage
**invalmsgs,
bool *RelcacheInitFileInval);
extern void ProcessCommittedInvalidationMessages(SharedInvalidationMessage
*msgs,
int nmsgs, bool RelcacheInitFileInval,
diff --git a/src/interfaces/ecpg/test/expected/pgtypeslib-num_test2.c
b/src/interfaces/ecpg/test/expected/pgtypeslib-num_test2.c
index 9debc34e791..747f8a6008e 100644
--- a/src/interfaces/ecpg/test/expected/pgtypeslib-num_test2.c
+++ b/src/interfaces/ecpg/test/expected/pgtypeslib-num_test2.c
@@ -83,7 +83,6 @@ main(void)
decimal *dec;
long l;
int i, j, k, q, r, count = 0;
- double d;
numeric **numarr = (numeric **) calloc(1, sizeof(numeric));
ECPGdebug(1, stderr);
@@ -152,6 +151,8 @@ main(void)
/* underflow does not work reliable on several archs,
so not testing it here */
/* this is a libc problem since we only call strtod() */
+ double d;
+
r = PGTYPESnumeric_to_double(num, &d);
if (r) check_errno();
printf("num[%d,10]: ", i);
diff --git a/src/interfaces/ecpg/test/pgtypeslib/num_test2.pgc
b/src/interfaces/ecpg/test/pgtypeslib/num_test2.pgc
index 8241d45ca51..57259136052 100644
--- a/src/interfaces/ecpg/test/pgtypeslib/num_test2.pgc
+++ b/src/interfaces/ecpg/test/pgtypeslib/num_test2.pgc
@@ -32,7 +32,6 @@ main(void)
decimal *dec;
long l;
int i, j, k, q, r, count = 0;
- double d;
numeric **numarr = (numeric **) calloc(1, sizeof(numeric));
ECPGdebug(1, stderr);
@@ -101,6 +100,8 @@ main(void)
/* underflow does not work reliable on several archs,
so not testing it here */
/* this is a libc problem since we only call strtod() */
+ double d;
+
r = PGTYPESnumeric_to_double(num, &d);
if (r) check_errno();
printf("num[%d,10]: ", i);
diff --git a/src/interfaces/libpq/fe-connect.c
b/src/interfaces/libpq/fe-connect.c
index ee398f13998..aa7a759f481 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -2929,7 +2929,6 @@ PQconnectPoll(PGconn *conn)
{
bool reset_connection_state_machine = false;
bool need_new_connection = false;
- PGresult *res;
char sebuf[PG_STRERROR_R_BUFLEN];
int optval;
@@ -4366,6 +4365,8 @@ PQconnectPoll(PGconn *conn)
* asyncStatus = PGASYNC_BUSY (done above).
*/
+ PGresult *res;
+
if (PQisBusy(conn))
return PGRES_POLLING_READING;
@@ -4583,6 +4584,9 @@ PQconnectPoll(PGconn *conn)
* CONNECTION_OK in order to use the
result-consuming
* subroutines.
*/
+
+ PGresult *res;
+
conn->status = CONNECTION_OK;
if (!PQconsumeInput(conn))
goto error_return;
@@ -4613,6 +4617,9 @@ PQconnectPoll(PGconn *conn)
* must transiently set status = CONNECTION_OK
in order to use
* the result-consuming subroutines.
*/
+
+ PGresult *res;
+
conn->status = CONNECTION_OK;
if (!PQconsumeInput(conn))
goto error_return;
@@ -4678,6 +4685,9 @@ PQconnectPoll(PGconn *conn)
* must transiently set status = CONNECTION_OK
in order to use
* the result-consuming subroutines.
*/
+
+ PGresult *res;
+
conn->status = CONNECTION_OK;
if (!PQconsumeInput(conn))
goto error_return;
diff --git a/src/interfaces/libpq/fe-secure-openssl.c
b/src/interfaces/libpq/fe-secure-openssl.c
index 140cec0e003..8895a17ff8a 100644
--- a/src/interfaces/libpq/fe-secure-openssl.c
+++ b/src/interfaces/libpq/fe-secure-openssl.c
@@ -841,10 +841,10 @@ initialize_SSL(PGconn *conn)
SSL_context = SSL_CTX_new(TLS_method());
if (!SSL_context)
{
- char *err = SSLerrmessage(ERR_get_error());
+ char *errm = SSLerrmessage(ERR_get_error());
- libpq_append_conn_error(conn, "could not create SSL context:
%s", err);
- SSLerrfree(err);
+ libpq_append_conn_error(conn, "could not create SSL context:
%s", errm);
+ SSLerrfree(errm);
return -1;
}
@@ -893,10 +893,10 @@ initialize_SSL(PGconn *conn)
if (!SSL_CTX_set_min_proto_version(SSL_context, ssl_min_ver))
{
- char *err = SSLerrmessage(ERR_get_error());
+ char *errm = SSLerrmessage(ERR_get_error());
- libpq_append_conn_error(conn, "could not set minimum
SSL protocol version: %s", err);
- SSLerrfree(err);
+ libpq_append_conn_error(conn, "could not set minimum
SSL protocol version: %s", errm);
+ SSLerrfree(errm);
SSL_CTX_free(SSL_context);
return -1;
}
@@ -919,10 +919,10 @@ initialize_SSL(PGconn *conn)
if (!SSL_CTX_set_max_proto_version(SSL_context, ssl_max_ver))
{
- char *err = SSLerrmessage(ERR_get_error());
+ char *errm = SSLerrmessage(ERR_get_error());
- libpq_append_conn_error(conn, "could not set maximum
SSL protocol version: %s", err);
- SSLerrfree(err);
+ libpq_append_conn_error(conn, "could not set maximum
SSL protocol version: %s", errm);
+ SSLerrfree(errm);
SSL_CTX_free(SSL_context);
return -1;
}
@@ -957,11 +957,11 @@ initialize_SSL(PGconn *conn)
*/
if (SSL_CTX_set_default_verify_paths(SSL_context) != 1)
{
- char *err = SSLerrmessage(ERR_get_error());
+ char *errm = SSLerrmessage(ERR_get_error());
libpq_append_conn_error(conn, "could not load system
root certificate paths: %s",
- err);
- SSLerrfree(err);
+ errm);
+ SSLerrfree(errm);
SSL_CTX_free(SSL_context);
return -1;
}
@@ -974,11 +974,11 @@ initialize_SSL(PGconn *conn)
if (SSL_CTX_load_verify_locations(SSL_context, fnbuf, NULL) !=
1)
{
- char *err = SSLerrmessage(ERR_get_error());
+ char *errm = SSLerrmessage(ERR_get_error());
libpq_append_conn_error(conn, "could not read root
certificate file \"%s\": %s",
- fnbuf,
err);
- SSLerrfree(err);
+ fnbuf,
errm);
+ SSLerrfree(errm);
SSL_CTX_free(SSL_context);
return -1;
}
@@ -1082,11 +1082,11 @@ initialize_SSL(PGconn *conn)
*/
if (SSL_CTX_use_certificate_chain_file(SSL_context, fnbuf) != 1)
{
- char *err = SSLerrmessage(ERR_get_error());
+ char *errm = SSLerrmessage(ERR_get_error());
libpq_append_conn_error(conn, "could not read
certificate file \"%s\": %s",
- fnbuf,
err);
- SSLerrfree(err);
+ fnbuf,
errm);
+ SSLerrfree(errm);
SSL_CTX_free(SSL_context);
return -1;
}
@@ -1106,10 +1106,10 @@ initialize_SSL(PGconn *conn)
!SSL_set_app_data(conn->ssl, conn) ||
!ssl_set_pgconn_bio(conn))
{
- char *err = SSLerrmessage(ERR_get_error());
+ char *errm = SSLerrmessage(ERR_get_error());
- libpq_append_conn_error(conn, "could not establish SSL
connection: %s", err);
- SSLerrfree(err);
+ libpq_append_conn_error(conn, "could not establish SSL
connection: %s", errm);
+ SSLerrfree(errm);
SSL_CTX_free(SSL_context);
return -1;
}
@@ -1155,10 +1155,10 @@ initialize_SSL(PGconn *conn)
{
if (SSL_set_tlsext_host_name(conn->ssl, host) != 1)
{
- char *err =
SSLerrmessage(ERR_get_error());
+ char *errm =
SSLerrmessage(ERR_get_error());
- libpq_append_conn_error(conn, "could not set
SSL Server Name Indication (SNI): %s", err);
- SSLerrfree(err);
+ libpq_append_conn_error(conn, "could not set
SSL Server Name Indication (SNI): %s", errm);
+ SSLerrfree(errm);
return -1;
}
}
@@ -1172,10 +1172,10 @@ initialize_SSL(PGconn *conn)
if (retval != 0)
{
- char *err = SSLerrmessage(ERR_get_error());
+ char *errm = SSLerrmessage(ERR_get_error());
- libpq_append_conn_error(conn, "could not set SSL ALPN
extension: %s", err);
- SSLerrfree(err);
+ libpq_append_conn_error(conn, "could not set SSL ALPN
extension: %s", errm);
+ SSLerrfree(errm);
return -1;
}
}
@@ -1215,22 +1215,22 @@ initialize_SSL(PGconn *conn)
conn->engine = ENGINE_by_id(engine_str);
if (conn->engine == NULL)
{
- char *err =
SSLerrmessage(ERR_get_error());
+ char *errm =
SSLerrmessage(ERR_get_error());
libpq_append_conn_error(conn, "could not load
SSL engine \"%s\": %s",
-
engine_str, err);
- SSLerrfree(err);
+
engine_str, errm);
+ SSLerrfree(errm);
free(engine_str);
return -1;
}
if (ENGINE_init(conn->engine) == 0)
{
- char *err =
SSLerrmessage(ERR_get_error());
+ char *errm =
SSLerrmessage(ERR_get_error());
libpq_append_conn_error(conn, "could not
initialize SSL engine \"%s\": %s",
-
engine_str, err);
- SSLerrfree(err);
+
engine_str, errm);
+ SSLerrfree(errm);
ENGINE_free(conn->engine);
conn->engine = NULL;
free(engine_str);
@@ -1241,11 +1241,11 @@ initialize_SSL(PGconn *conn)
NULL, NULL);
if (pkey == NULL)
{
- char *err =
SSLerrmessage(ERR_get_error());
+ char *errm =
SSLerrmessage(ERR_get_error());
libpq_append_conn_error(conn, "could not read
private SSL key \"%s\" from engine \"%s\": %s",
-
engine_colon, engine_str, err);
- SSLerrfree(err);
+
engine_colon, engine_str, errm);
+ SSLerrfree(errm);
ENGINE_finish(conn->engine);
ENGINE_free(conn->engine);
conn->engine = NULL;
@@ -1254,11 +1254,11 @@ initialize_SSL(PGconn *conn)
}
if (SSL_use_PrivateKey(conn->ssl, pkey) != 1)
{
- char *err =
SSLerrmessage(ERR_get_error());
+ char *errm =
SSLerrmessage(ERR_get_error());
libpq_append_conn_error(conn, "could not load
private SSL key \"%s\" from engine \"%s\": %s",
-
engine_colon, engine_str, err);
- SSLerrfree(err);
+
engine_colon, engine_str, errm);
+ SSLerrfree(errm);
ENGINE_finish(conn->engine);
ENGINE_free(conn->engine);
conn->engine = NULL;
@@ -1345,7 +1345,7 @@ initialize_SSL(PGconn *conn)
if (SSL_use_PrivateKey_file(conn->ssl, fnbuf, SSL_FILETYPE_PEM)
!= 1)
{
- char *err = SSLerrmessage(ERR_get_error());
+ char *errm = SSLerrmessage(ERR_get_error());
/*
* We'll try to load the file in DER (binary ASN.1)
format, and if
@@ -1362,12 +1362,12 @@ initialize_SSL(PGconn *conn)
if (SSL_use_PrivateKey_file(conn->ssl, fnbuf,
SSL_FILETYPE_ASN1) != 1)
{
libpq_append_conn_error(conn, "could not load
private key file \"%s\": %s",
-
fnbuf, err);
- SSLerrfree(err);
+
fnbuf, errm);
+ SSLerrfree(errm);
return -1;
}
- SSLerrfree(err);
+ SSLerrfree(errm);
}
}
@@ -1375,11 +1375,11 @@ initialize_SSL(PGconn *conn)
if (have_cert &&
SSL_check_private_key(conn->ssl) != 1)
{
- char *err = SSLerrmessage(ERR_get_error());
+ char *errm = SSLerrmessage(ERR_get_error());
libpq_append_conn_error(conn, "certificate does not match
private key file \"%s\": %s",
- fnbuf, err);
- SSLerrfree(err);
+ fnbuf, errm);
+ SSLerrfree(errm);
return -1;
}
@@ -1458,10 +1458,10 @@ open_client_SSL(PGconn *conn)
}
case SSL_ERROR_SSL:
{
- char *err = SSLerrmessage(ecode);
+ char *errm = SSLerrmessage(ecode);
- libpq_append_conn_error(conn, "SSL
error: %s", err);
- SSLerrfree(err);
+ libpq_append_conn_error(conn, "SSL
error: %s", errm);
+ SSLerrfree(errm);
switch (ERR_GET_REASON(ecode))
{
/*
@@ -1550,10 +1550,10 @@ open_client_SSL(PGconn *conn)
conn->peer = SSL_get_peer_certificate(conn->ssl);
if (conn->peer == NULL)
{
- char *err = SSLerrmessage(ERR_get_error());
+ char *errm = SSLerrmessage(ERR_get_error());
- libpq_append_conn_error(conn, "certificate could not be
obtained: %s", err);
- SSLerrfree(err);
+ libpq_append_conn_error(conn, "certificate could not be
obtained: %s", errm);
+ SSLerrfree(errm);
pgtls_close(conn);
return PGRES_POLLING_FAILED;
}
base-commit: 2a2dab67dc40a41a003545308423c1d3def02dea
--
2.55.0
From 24839799bb2d752fc3e86914088992f9898e0e59 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 1 Sep 2026 16:38:32 +0200
Subject: [PATCH 2/3] Use -isystem for LLVM include directories
LLVM's headers produce warnings under some of the warning options we
use. For example, -Wshadow=local reports several warnings from LLVM's
headers when compiling llvmjit_inline.cpp. To work around that, add
the include directories reported by llvm-config with -isystem rather
than -I, which makes the compiler treat them as system headers and not
report warnings from them. In meson, this is a built-in facility of
the dependency() function, in configure we implement it ourselves.
An alternative solution would have been to use '#pragma GCC
system_header', as is already done elsewhere in the tree. But that
seems less elegant here. Either, we would have to potentially create
a separate wrapper for each LLVM header, or we would have to route all
LLVM includes through a common header, which would break modularity.
---
config/llvm.m4 | 7 +++++--
configure | 7 +++++--
meson.build | 5 ++++-
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/config/llvm.m4 b/config/llvm.m4
index 5d4f14cb900..496fd8f72a4 100644
--- a/config/llvm.m4
+++ b/config/llvm.m4
@@ -46,10 +46,13 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
# clear what the minimum version is.
# Collect compiler flags necessary to build the LLVM dependent
- # shared library.
+ # shared library. The include directories are added with -isystem
+ # rather than -I, so that warnings from LLVM's own headers are not
+ # reported under the warning options we select for our own code.
for pgac_option in `$LLVM_CONFIG --cppflags`; do
case $pgac_option in
- -I*|-D*) LLVM_CPPFLAGS="$pgac_option $LLVM_CPPFLAGS";;
+ -I*) LLVM_CPPFLAGS="-isystem ${pgac_option#-I} $LLVM_CPPFLAGS";;
+ -D*) LLVM_CPPFLAGS="$pgac_option $LLVM_CPPFLAGS";;
esac
done
diff --git a/configure b/configure
index d42a7a794ff..002e31bf695 100755
--- a/configure
+++ b/configure
@@ -5105,10 +5105,13 @@ fi
# clear what the minimum version is.
# Collect compiler flags necessary to build the LLVM dependent
- # shared library.
+ # shared library. The include directories are added with -isystem
+ # rather than -I, so that warnings from LLVM's own headers are not
+ # reported under the warning options we select for our own code.
for pgac_option in `$LLVM_CONFIG --cppflags`; do
case $pgac_option in
- -I*|-D*) LLVM_CPPFLAGS="$pgac_option $LLVM_CPPFLAGS";;
+ -I*) LLVM_CPPFLAGS="-isystem ${pgac_option#-I} $LLVM_CPPFLAGS";;
+ -D*) LLVM_CPPFLAGS="$pgac_option $LLVM_CPPFLAGS";;
esac
done
diff --git a/meson.build b/meson.build
index f4cde249242..52d6bc37dd9 100644
--- a/meson.build
+++ b/meson.build
@@ -924,7 +924,10 @@ endif
llvmopt = get_option('llvm')
llvm = not_found_dep
if have_cxx
- llvm = dependency('llvm', version: '>=14', method: 'config-tool', required:
llvmopt)
+ # Use include_type 'system' so that warnings from LLVM's own headers are
+ # not reported under the warning options we select for our own code.
+ llvm = dependency('llvm', version: '>=14', method: 'config-tool',
+ include_type: 'system', required: llvmopt)
if llvm.found()
--
2.55.0
From b4593b162036b4b0ed51e60da0f4fdacf8f4a68e Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 1 Sep 2026 16:38:32 +0200
Subject: [PATCH 3/3] Use warning option -Wshadow=local
Change the existing -Wshadow=compatible-local to -Wshadow=local. This
covers more cases than before. In particular, some types are
assignable to each other, such as char * and const char *, or bool and
some integer type, but they are not "compatible" in the C sense, so
they are missed by the previous warning setting, but they are really
the same basic problem.
---
configure | 40 ++++++++++++++++++++--------------------
configure.ac | 4 ++--
meson.build | 2 +-
3 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/configure b/configure
index 002e31bf695..ec97d4d2c98 100755
--- a/configure
+++ b/configure
@@ -5905,15 +5905,15 @@ fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports
-Wshadow=compatible-local, for CFLAGS" >&5
-$as_echo_n "checking whether ${CC} supports -Wshadow=compatible-local, for
CFLAGS... " >&6; }
-if ${pgac_cv_prog_CC_cflags__Wshadow_compatible_local+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports
-Wshadow=local, for CFLAGS" >&5
+$as_echo_n "checking whether ${CC} supports -Wshadow=local, for CFLAGS... "
>&6; }
+if ${pgac_cv_prog_CC_cflags__Wshadow_local+:} false; then :
$as_echo_n "(cached) " >&6
else
pgac_save_CFLAGS=$CFLAGS
pgac_save_CC=$CC
CC=${CC}
-CFLAGS="${CFLAGS} -Wshadow=compatible-local"
+CFLAGS="${CFLAGS} -Wshadow=local"
ac_save_c_werror_flag=$ac_c_werror_flag
ac_c_werror_flag=yes
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -5928,31 +5928,31 @@ main ()
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
- pgac_cv_prog_CC_cflags__Wshadow_compatible_local=yes
+ pgac_cv_prog_CC_cflags__Wshadow_local=yes
else
- pgac_cv_prog_CC_cflags__Wshadow_compatible_local=no
+ pgac_cv_prog_CC_cflags__Wshadow_local=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_c_werror_flag=$ac_save_c_werror_flag
CFLAGS="$pgac_save_CFLAGS"
CC="$pgac_save_CC"
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result:
$pgac_cv_prog_CC_cflags__Wshadow_compatible_local" >&5
-$as_echo "$pgac_cv_prog_CC_cflags__Wshadow_compatible_local" >&6; }
-if test x"$pgac_cv_prog_CC_cflags__Wshadow_compatible_local" = x"yes"; then
- CFLAGS="${CFLAGS} -Wshadow=compatible-local"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result:
$pgac_cv_prog_CC_cflags__Wshadow_local" >&5
+$as_echo "$pgac_cv_prog_CC_cflags__Wshadow_local" >&6; }
+if test x"$pgac_cv_prog_CC_cflags__Wshadow_local" = x"yes"; then
+ CFLAGS="${CFLAGS} -Wshadow=local"
fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CXX} supports
-Wshadow=compatible-local, for CXXFLAGS" >&5
-$as_echo_n "checking whether ${CXX} supports -Wshadow=compatible-local, for
CXXFLAGS... " >&6; }
-if ${pgac_cv_prog_CXX_cxxflags__Wshadow_compatible_local+:} false; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CXX} supports
-Wshadow=local, for CXXFLAGS" >&5
+$as_echo_n "checking whether ${CXX} supports -Wshadow=local, for CXXFLAGS... "
>&6; }
+if ${pgac_cv_prog_CXX_cxxflags__Wshadow_local+:} false; then :
$as_echo_n "(cached) " >&6
else
pgac_save_CXXFLAGS=$CXXFLAGS
pgac_save_CXX=$CXX
CXX=${CXX}
-CXXFLAGS="${CXXFLAGS} -Wshadow=compatible-local"
+CXXFLAGS="${CXXFLAGS} -Wshadow=local"
ac_save_cxx_werror_flag=$ac_cxx_werror_flag
ac_cxx_werror_flag=yes
ac_ext=cpp
@@ -5973,9 +5973,9 @@ main ()
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
- pgac_cv_prog_CXX_cxxflags__Wshadow_compatible_local=yes
+ pgac_cv_prog_CXX_cxxflags__Wshadow_local=yes
else
- pgac_cv_prog_CXX_cxxflags__Wshadow_compatible_local=no
+ pgac_cv_prog_CXX_cxxflags__Wshadow_local=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
@@ -5988,10 +5988,10 @@ ac_cxx_werror_flag=$ac_save_cxx_werror_flag
CXXFLAGS="$pgac_save_CXXFLAGS"
CXX="$pgac_save_CXX"
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result:
$pgac_cv_prog_CXX_cxxflags__Wshadow_compatible_local" >&5
-$as_echo "$pgac_cv_prog_CXX_cxxflags__Wshadow_compatible_local" >&6; }
-if test x"$pgac_cv_prog_CXX_cxxflags__Wshadow_compatible_local" = x"yes"; then
- CXXFLAGS="${CXXFLAGS} -Wshadow=compatible-local"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result:
$pgac_cv_prog_CXX_cxxflags__Wshadow_local" >&5
+$as_echo "$pgac_cv_prog_CXX_cxxflags__Wshadow_local" >&6; }
+if test x"$pgac_cv_prog_CXX_cxxflags__Wshadow_local" = x"yes"; then
+ CXXFLAGS="${CXXFLAGS} -Wshadow=local"
fi
diff --git a/configure.ac b/configure.ac
index a331749fcb5..0308491ac6e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -575,8 +575,8 @@ if test "$GCC" = yes -a "$ICC" = no; then
PGAC_PROG_CC_CFLAGS_OPT([-Wcast-function-type])
PGAC_PROG_CXX_CFLAGS_OPT([-Wcast-function-type])
- PGAC_PROG_CC_CFLAGS_OPT([-Wshadow=compatible-local])
- PGAC_PROG_CXX_CFLAGS_OPT([-Wshadow=compatible-local])
+ PGAC_PROG_CC_CFLAGS_OPT([-Wshadow=local])
+ PGAC_PROG_CXX_CFLAGS_OPT([-Wshadow=local])
# This was included in -Wall/-Wformat in older GCC versions
PGAC_PROG_CC_CFLAGS_OPT([-Wformat-security])
PGAC_PROG_CXX_CFLAGS_OPT([-Wformat-security])
diff --git a/meson.build b/meson.build
index 52d6bc37dd9..acd2defaded 100644
--- a/meson.build
+++ b/meson.build
@@ -2212,7 +2212,7 @@ common_warning_flags = [
'-Werror=unguarded-availability-new',
'-Wmissing-format-attribute',
'-Wcast-function-type',
- '-Wshadow=compatible-local',
+ '-Wshadow=local',
# This was included in -Wall/-Wformat in older GCC versions
'-Wformat-security',
]
--
2.55.0