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.

Reviewed-by: Peter Geoghegan <pg@bowt.ie>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/84b6f128-91f5-480e-8a9e-7d0e8f538cea%40eisentraut.org
This commit is contained in:
Peter Eisentraut committed 2026-09-08 08:49:30 +02:00
1 parent b3dfd8d4ea
commit f9fc9a78a3
38 files changed
+390 -379

No files matched your search

+11 -11
View File
@@ -2002,7 +2002,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;
@@ -2017,7 +2017,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
@@ -2032,10 +2032,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++)
@@ -2049,8 +2049,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)
@@ -2095,19 +2095,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;
@@ -2116,7 +2116,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.
+4 -4
View File
@@ -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);
}
+8 -8
View File
@@ -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);
+15 -15
View File
@@ -2140,37 +2140,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
{
@@ -2194,22 +2194,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));
}
}
+13 -13
View File
@@ -864,22 +864,22 @@ RelationGetNotNullConstraints(Oid relid, bool cooked, bool include_noinh)
if (cooked)
{
CookedConstraint *cooked;
CookedConstraint *cookedConstr;
cooked = palloc_object(CookedConstraint);
cookedConstr = 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;
cookedConstr->contype = CONSTR_NOTNULL;
cookedConstr->conoid = conForm->oid;
cookedConstr->name = pstrdup(NameStr(conForm->conname));
cookedConstr->attnum = colnum;
cookedConstr->expr = NULL;
cookedConstr->is_enforced = true;
cookedConstr->skip_validation = !conForm->convalidated;
cookedConstr->is_local = true;
cookedConstr->inhcount = 0;
cookedConstr->is_no_inherit = conForm->connoinherit;
notnulls = lappend(notnulls, cooked);
notnulls = lappend(notnulls, cookedConstr);
}
else
{
+4 -4
View File
@@ -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\"",
+2 -2
View File
@@ -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;
+3 -3
View File
@@ -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;
+7 -7
View File
@@ -672,8 +672,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);
@@ -16286,7 +16286,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;
@@ -16300,7 +16300,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)
{
@@ -16311,7 +16311,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;
@@ -16319,7 +16319,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);
@@ -16330,7 +16330,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);
+6 -6
View File
@@ -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;
}
@@ -987,8 +987,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;
+8 -8
View File
@@ -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;
+2 -2
View File
@@ -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]);
+3 -3
View File
@@ -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;
/*
+22 -22
View File
@@ -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 */
+6 -6
View File
@@ -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 @@ retry:
{
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 @@ retry:
* 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 @@ retry:
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;
+15 -15
View File
@@ -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,
@@ -1143,10 +1143,10 @@ clauselist_apply_dependencies(PlannerInfo *root, List *clauses,
*
* Similar to dependency_is_compatible_clause, but doesn't enforce that the
* expression is a simple Var. On success, return the matching statistics
* expression into *expr.
* expression into *stat_expr_p.
*/
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;
}
}
+3 -3
View File
@@ -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++;
}
+7 -7
View File
@@ -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
}
+7 -7
View File
@@ -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;
+24 -24
View File
@@ -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;
}
/*
+3 -3
View File
@@ -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);
}
}
+10 -10
View File
@@ -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),
+10 -10
View File
@@ -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)
@@ -4795,7 +4795,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;
@@ -4868,7 +4868,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. */
@@ -4888,7 +4888,7 @@ text_format(PG_FUNCTION_ARGS)
*/
if (*cp != '%')
{
appendStringInfoCharMacro(&str, *cp);
appendStringInfoCharMacro(&result_str, *cp);
continue;
}
@@ -4897,7 +4897,7 @@ text_format(PG_FUNCTION_ARGS)
/* Easy case: %% outputs a single % */
if (*cp == '%')
{
appendStringInfoCharMacro(&str, *cp);
appendStringInfoCharMacro(&result_str, *cp);
continue;
}
@@ -5030,7 +5030,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;
@@ -5052,8 +5052,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);
}
+24 -24
View File
@@ -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,
+21 -21
View File
@@ -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);
+3 -3
View File
@@ -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
+31 -31
View File
@@ -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;
+9 -9
View File
@@ -1668,7 +1668,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"));
@@ -1784,12 +1784,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]);
@@ -2212,11 +2212,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);
+19 -20
View File
@@ -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;
}
}
}
+1 -1
View File
@@ -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 */
+11 -11
View File
@@ -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 @@ cleanup:
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);
+8 -8
View File
@@ -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);
}
/*
+1 -1
View File
@@ -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,
+2 -2
View File
@@ -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,
@@ -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);
@@ -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);
+11 -1
View File
@@ -2930,7 +2930,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;
@@ -4341,6 +4340,8 @@ keep_going: /* We will come back to here until there is
* asyncStatus = PGASYNC_BUSY (done above).
*/
PGresult *res;
if (PQisBusy(conn))
return PGRES_POLLING_READING;
@@ -4550,6 +4551,9 @@ keep_going: /* We will come back to here until there is
* CONNECTION_OK in order to use the result-consuming
* subroutines.
*/
PGresult *res;
conn->status = CONNECTION_OK;
if (!PQconsumeInput(conn))
goto error_return;
@@ -4580,6 +4584,9 @@ keep_going: /* We will come back to here until there is
* 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;
@@ -4645,6 +4652,9 @@ keep_going: /* We will come back to here until there is
* 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;
+52 -52
View File
@@ -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;
}