8000 Rename shadowed local variables · postgres/postgres@2d0bbed · GitHub
[go: up one dir, main page]

Skip to content

Commit 2d0bbed

Browse files
committed
Rename shadowed local variables
In a similar effort to f01592f, here we mostly rename shadowed local variables to remove the warnings produced when compiling with -Wshadow=compatible-local. This fixes 63 warnings and leaves just 5. Author: Justin Pryzby, David Rowley Reviewed-by: Justin Pryzby Discussion https://postgr.es/m/20220817145434.GC26426%40telsasoft.com
1 parent 839c252 commit 2d0bbed

File tree

39 files changed

+220
-226
lines changed
  • plan
  • prep
  • util
  • parser
  • partitioning
  • replication
  • statistics
  • storage/lmgr
  • tsearch
  • utils/adt
  • bin/psql
  • include/lib
  • interfaces/ecpg
  • pl/plpgsql/src
  • 39 files changed

    +220
    -226
    lines changed

    src/backend/access/brin/brin_minmax_multi.c

    Lines changed: 4 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -3059,16 +3059,16 @@ brin_minmax_multi_summary_out(PG_FUNCTION_ARGS)
    30593059
    char *a,
    30603060
    *b;
    30613061
    text *c;
    3062-
    StringInfoData str;
    3062+
    StringInfoData buf;
    30633063

    3064-
    initStringInfo(&str);
    3064+
    initStringInfo(&buf);
    30653065

    30663066
    a = OutputFunctionCall(&fmgrinfo, ranges_deserialized->values[idx++]);
    30673067
    b = OutputFunctionCall(&fmgrinfo, ranges_deserialized->values[idx++]);
    30683068

    3069-
    appendStringInfo(&str, "%s ... %s", a, b);
    3069+
    appendStringInfo(&buf, "%s ... %s", a, b);
    30703070

    3071-
    c = cstring_to_text_with_len(str.data, str.len);
    3071+
    c = cstring_to_text_with_len(buf.data, buf.len);
    30723072

    30733073
    astate_values = accumArrayResult(astate_values,
    30743074
    PointerGetDatum(c),

    src/backend/access/gin/ginget.c

    Lines changed: 3 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -397,7 +397,7 @@ startScanEntry(GinState *ginstate, GinScanEntry entry, Snapshot snapshot)
    397397
    {
    398398
    BlockNumber rootPostingTree = GinGetPostingTree(itup);
    399399
    GinBtreeStack *stack;
    400-
    Page page;
    400+
    Page entrypage;
    401401
    ItemPointerData minItem;
    402402

    403403
    /*
    @@ -428,13 +428,13 @@ startScanEntry(GinState *ginstate, GinScanEntry entry, Snapshot snapshot)
    428428
    */
    429429
    IncrBufferRefCount(entry->buffer);
    430430

    431-
    page = BufferGetPage(entry->buffer);
    431+
    entrypage = BufferGetPage(entry->buffer);
    432432

    433433
    /*
    434434
    * Load the first page into memory.
    435435
    */
    436436
    ItemPointerSetMin(&minItem);
    437-
    entry->list = GinDataLeafPageGetItems(page, &entry->nlist, minItem);
    437+
    entry->list = GinDataLeafPageGetItems(entrypage, &entry->nlist, minItem);
    438438

    439439
    entry->predictNumberResult = stack->predictNumber * entry->nlist;
    440440

    src/backend/access/heap/heapam.c

    Lines changed: 9 additions & 9 deletions
    Original file line numberDiff line numberDiff line change
    @@ -6283,14 +6283,14 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
    62836283
    */
    62846284
    if (ISUPDATE_from_mxstatus(members[i].status))
    62856285
    {
    6286-
    TransactionId xid = members[i].xid;
    6286+
    TransactionId txid = members[i].xid;
    62876287

    6288-
    Assert(TransactionIdIsValid(xid));
    6289-
    if (TransactionIdPrecedes(xid, relfrozenxid))
    6288+
    Assert(TransactionIdIsValid(txid));
    6289+
    if (TransactionIdPrecedes(txid, relfrozenxid))
    62906290
    ereport(ERROR,
    62916291
    (errcode(ERRCODE_DATA_CORRUPTED),
    62926292
    errmsg_internal("found update xid %u from before relfrozenxid %u",
    6293-
    xid, relfrozenxid)));
    6293+
    txid, relfrozenxid)));
    62946294

    62956295
    /*
    62966296
    * It's an update; should we keep it? If the transaction is known
    @@ -6304,13 +6304,13 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
    63046304
    * because of race conditions explained in detail in
    63056305
    * heapam_visibility.c.
    63066306
    */
    6307-
    if (TransactionIdIsCurrentTransactionId(xid) ||
    6308-
    TransactionIdIsInProgress(xid))
    6307+
    if (TransactionIdIsCurrentTransactionId(txid) ||
    6308+
    TransactionIdIsInProgress(txid))
    63096309
    {
    63106310
    Assert(!TransactionIdIsValid(update_xid));
    6311-
    update_xid = xid;
    6311+
    update_xid = txid;
    63126312
    }
    6313-
    else if (TransactionIdDidCommit(xid))
    6313+
    else if (TransactionIdDidCommit(txid))
    63146314
    {
    63156315
    /*
    63166316
    * The transaction committed, so we can tell caller to set
    @@ -6319,7 +6319,7 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
    63196319
    */
    63206320
    Assert(!TransactionIdIsValid(update_xid));
    63216321
    update_committed = true;
    6322-
    update_xid = xid;
    6322+
    update_xid = txid;
    63236323
    }
    63246324
    else
    63256325
    {

    src/backend/access/transam/clog.c

    Lines changed: 15 additions & 15 deletions
    Original file line numberDiff line numberDiff line change
    @@ -516,23 +516,23 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
    516516
    /* Walk the list and update the status of all XIDs. */
    517517
    while (nextidx != INVALID_PGPROCNO)
    518518
    {
    519-
    PGPROC *proc = &ProcGlobal->allProcs[nextidx];
    519+
    PGPROC *nextproc = &ProcGlobal->allProcs[nextidx];
    520520

    521521
    /*
    522522
    * Transactions with more than THRESHOLD_SUBTRANS_CLOG_OPT sub-XIDs
    523523
    * should not use group XID status update mechanism.
    524524
    */
    525-
    Assert(proc->subxidStatus.count <= THRESHOLD_SUBTRANS_CLOG_OPT);
    525+
    Assert(nextproc->subxidStatus.count <= THRESHOLD_SUBTRANS_CLOG_OPT);
    526526

    527-
    TransactionIdSetPageStatusInternal(proc->clogGroupMemberXid,
    528-
    proc->subxidStatus.count,
    529-
    proc->subxids.xids,
    530-
    proc->clogGroupMemberXidStatus,
    531-
    proc->clogGroupMemberLsn,
    532-
    proc->clogGroupMemberPage);
    527+
    TransactionIdSetPageStatusInternal(nextproc->clogGroupMemberXid,
    528+
    nextproc->subxidStatus.count,
    529+
    nextproc->subxids.xids,
    530+
    nextproc->clogGroupMemberXidStatus,
    531+
    nextproc->clogGroupMemberLsn,
    532+
    nextproc->clogGroupMemberPage);
    533533

    534534
    /* Move to next proc in list. */
    535-
    nextidx = pg_atomic_read_u32(&proc->clogGroupNext);
    535+
    nextidx = pg_atomic_read_u32(&nextproc->clogGroupNext);
    536536
    }
    537537

    538538
    /* We're done with the lock now. */
    @@ -545,18 +545,18 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
    545545
    */
    546546
    while (wakeidx != INVALID_PGPROCNO)
    547547
    {
    548-
    PGPROC *proc = &ProcGlobal->allProcs[wakeidx];
    548+
    PGPROC *wakeproc = &ProcGlobal->allProcs[wakeidx];
    549549

    550-
    wakeidx = pg_atomic_read_u32(&proc->clogGroupNext);
    551-
    pg_atomic_write_u32(&proc->clogGroupNext, INVALID_PGPROCNO);
    550+
    wakeidx = pg_atomic_read_u32(&wakeproc->clogGroupNext);
    551+
    pg_atomic_write_u32(&wakeproc->clogGroupNext, INVALID_PGPROCNO);
    552552

    553553
    /* ensure all previous writes are visible before follower continues. */
    554554
    pg_write_barrier();
    555555

    556-
    proc->clogGroupMember = false;
    556+
    wakeproc->clogGroupMember = false;
    557557

    558-
    if (proc != MyProc)
    559-
    PGSemaphoreUnlock(proc->sem);
    558+
    if (wakeproc != MyProc)
    559+
    PGSemaphoreUnlock(wakeproc->sem);
    560560
    }
    561561

    562562
    return true;

    src/backend/backup/basebackup.c

    Lines changed: 4 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -275,12 +275,12 @@ perform_base_backup(basebackup_options *opt, bbsink *sink)
    275275
    PG_ENSURE_ERROR_CLEANUP(do_pg_abort_backup, BoolGetDatum(false));
    276276
    {
    277277
    ListCell *lc;
    278-
    tablespaceinfo *ti;
    278+
    tablespaceinfo *newti;
    279279

    280280
    /* Add a node for the base directory at the end */
    281-
    ti = palloc0(sizeof(tablespaceinfo));
    282-
    ti->size = -1;
    283-
    state.tablespaces = lappend(state.tablespaces, ti);
    281+
    newti = palloc0(sizeof(tablespaceinfo));
    282+
    newti->size = -1;
    283+
    state.tablespaces = lappend(state.tablespaces, newti);
    284284

    285285
    /*
    286286
    * Calculate the total backup size by summing up the size of each

    src/backend/catalog/heap.c

    Lines changed: 8 additions & 8 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1818,19 +1818,19 @@ heap_drop_with_catalog(Oid relid)
    18181818
    */
    18191819
    if (rel->rd_rel->relkind == RELKIND_FOREIGN_TABLE)
    18201820
    {
    1821-
    Relation rel;
    1822-
    HeapTuple tuple;
    1821+
    Relation ftrel;
    1822+
    HeapTuple fttuple;
    18231823

    1824-
    rel = table_open(ForeignTableRelationId, RowExclusiveLock);
    1824+
    ftrel = table_open(ForeignTableRelationId, RowExclusiveLock);
    18251825

    1826-
    tuple = SearchSysCache1(FOREIGNTABLEREL, ObjectIdGetDatum(relid));
    1827-
    if (!HeapTupleIsValid(tuple))
    1826+
    fttuple = SearchSysCache1(FOREIGNTABLEREL, ObjectIdGetDatum(relid));
    1827+
    if (!HeapTupleIsValid(fttuple))
    18281828
    elog(ERROR, "cache lookup failed for foreign table %u", relid);
    18291829

    1830-
    CatalogTupleDelete(rel, &tuple->t_self);
    1830+
    CatalogTupleDelete(ftrel, &fttuple->t_self);
    18311831

    1832-
    ReleaseSysCache(tuple);
    1833-
    table_close(rel, RowExclusiveLock);
    1832+
    ReleaseSysCache(fttuple);
    1833+
    table_close(ftrel, RowExclusiveLock);
    18341834
    }
    18351835

    18361836
    /*

    src/backend/catalog/namespace.c

    Lines changed: 4 additions & 8 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1151,10 +1151,8 @@ FuncnameGetCandidates(List *names, int nargs, List *argnames,
    11511151
    if (argnumbers)
    11521152
    {
    11531153
    /* Re-order the argument types into call's logical order */
    1154-
    int i;
    1155-
    1156-
    for (i = 0; i < pronargs; i++)
    1157-
    newResult->args[i] = proargtypes[argnumbers[i]];
    1154+
    for (int j = 0; j < pronargs; j++)
    1155+
    newResult->args[j] = proargtypes[argnumbers[j]];
    11581156
    }
    11591157
    else
    11601158
    {
    @@ -1163,12 +1161,10 @@ FuncnameGetCandidates(List *names, int nargs, List *argnames,
    11631161
    }
    11641162
    if (variadic)
    11651163
    {
    1166-
    int i;
    1167-
    11681164
    newResult->nvargs = effective_nargs - pronargs + 1;
    11691165
    /* Expand variadic argument into N copies of element type */
    1170-
    for (i = pronargs - 1; i < effective_nargs; i++)
    1171-
    newResult->args[i] = va_elem_type;
    1166+
    for (int j = pronargs - 1; j < effective_nargs; j++)
    1167+
    newResult->args[j] = va_elem_type;
    11721168
    }
    11731169
    else
    11741170
    newResult->nvargs = 0;

    src/backend/commands/publicationcmds.c

    Lines changed: 3 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -107,7 +107,7 @@ parse_publication_options(ParseState *pstate,
    107107
    {
    108108
    char *publish;
    109109
    List *publish_list;
    110-
    ListCell *lc;
    110+
    ListCell *lc2;
    111111

    112112
    if (*publish_given)
    113113
    errorConflictingDefElem(defel, pstate);
    @@ -131,9 +131,9 @@ parse_publication_options(ParseState *pstate,
    131131
    "publish")));
    132132

    133133
    /* Process the option list. */
    134-
    foreach(lc, publish_list)
    134+
    foreach(lc2, publish_list)
    135135
    {
    136-
    char *publish_opt = (char *) lfirst(lc);
    136+
    char *publish_opt = (char *) lfirst(lc2);
    137137

    138138
    if (strcmp(publish_opt, "insert") == 0)
    139139
    pubactions->pubinsert = true;

    src/backend/commands/tablecmds.c

    Lines changed: 11 additions & 11 deletions
    Original file line numberDiff line numberDiff line change
    @@ -10223,7 +10223,7 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel)
    1022310223
    Oid constrOid;
    1022410224
    ObjectAddress address,
    1022510225
    referenced;
    10226-
    ListCell *cell;
    10226+
    ListCell *lc;
    1022710227
    Oid insertTriggerOid,
    1022810228
    updateTriggerOid;
    1022910229

    @@ -10276,9 +10276,9 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel)
    1027610276
    * don't need to recurse to partitions for this constraint.
    1027710277
    */
    1027810278
    attached = false;
    10279-
    foreach(cell, partFKs)
    10279+
    foreach(lc, partFKs)
    1028010280
    {
    10281-
    ForeignKeyCacheInfo *fk = lfirst_node(ForeignKeyCacheInfo, cell);
    10281+
    ForeignKeyCacheInfo *fk = lfirst_node(ForeignKeyCacheInfo, lc);
    1028210282

    1028310283
    if (tryAttachPartitionForeignKey(fk,
    1028410284
    RelationGetRelid(partRel),
    @@ -10877,7 +10877,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
    1087710877
    {
    1087810878
    Form_pg_trigger tgform = (Form_pg_trigger) GETSTRUCT(tgtuple);
    1087910879
    Form_pg_trigger copy_tg;
    10880-
    HeapTuple copyTuple;
    10880+
    HeapTuple tgCopyTuple;
    1088110881

    38BA
    1088210882
    /*
    1088310883
    * Remember OIDs of other relation(s) involved in FK constraint.
    @@ -10901,16 +10901,16 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
    1090110901
    tgform->tgfoid != F_RI_FKEY_CHECK_UPD)
    1090210902
    continue;
    1090310903

    10904-
    copyTuple = heap_copytuple(tgtuple);
    10905-
    copy_tg = (Form_pg_trigger) GETSTRUCT(copyTuple);
    10904+
    tgCopyTuple = heap_copytuple(tgtuple);
    10905+
    copy_tg = (Form_pg_trigger) GETSTRUCT(tgCopyTuple);
    1090610906

    1090710907
    copy_tg->tgdeferrable = cmdcon->deferrable;
    1090810908
    copy_tg->tginitdeferred = cmdcon->initdeferred;
    10909-
    CatalogTupleUpdate(tgrel, &copyTuple->t_self, copyTuple);
    10909+
    CatalogTupleUpdate(tgrel, &tgCopyTuple->t_self, tgCopyTuple);
    1091010910

    1091110911
    InvokeObjectPostAlterHook(TriggerRelationId, tgform->oid, 0);
    1091210912

    10913-
    heap_freetuple(copyTuple);
    10913+
    heap_freetuple(tgCopyTuple);
    1091410914
    }
    1091510915

    1091610916
    systable_endscan(tgscan);
    @@ -18083,14 +18083,14 @@ AttachPartitionEnsureIndexes(Relation rel, Relation attachrel)
    1808318083
    if (!found)
    1808418084
    {
    1808518085
    IndexStmt *stmt;
    18086-
    Oid constraintOid;
    18086+
    Oid conOid;
    1808718087

    1808818088
    stmt = generateClonedIndexStmt(NULL,
    1808918089
    idxRel, attmap,
    18090-
    &constraintOid);
    18090+
    &conOid);
    1809118091
    DefineIndex(RelationGetRelid(attachrel), stmt, InvalidOid,
    1809218092
    RelationGetRelid(idxRel),
    18093-
    constraintOid,
    18093+
    conOid,
    1809418094
    true, false, false, false, false);
    1809518095
    }
    1809618096

    src/backend/commands/trigger.c

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1694,9 +1694,9 @@ renametrig_partition(Relation tgrel, Oid partitionId, Oid parentTriggerOid,
    16941694

    16951695
    for (int i = 0; i < partdesc->nparts; i++)
    16961696
    {
    1697-
    Oid partitionId = partdesc->oids[i];
    1697+
    Oid partoid = partdesc->oids[i];
    16981698

    1699-
    renametrig_partition(tgrel, partitionId, tgform->oid, newname,
    1699+
    renametrig_partition(tgrel, partoid, tgform->oid, newname,
    17001700
    NameStr(tgform->tgname));
    17011701
    }
    17021702
    }

    0 commit comments

    Comments
     (0)
    0