Fix some shadow variables in src/backend/replication/
authorMichael Paquier <michael@paquier.xyz>
Wed, 30 Aug 2023 23:07:48 +0000 (08:07 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 30 Aug 2023 23:07:48 +0000 (08:07 +0900)
The code is able to compile already without warnings under
-Wshadow=compatible-local, which is itself already enabled in the tree,
and the ones fixed here showed up with the more restrictive -Wshadow.

There are more of these that we may want to look at, and the ones fixed
here made the code confusing.

Author: Peter Smith
Discussion: https://postgr.es/m/CAHut+PuR0y4ofNOxi691VTVWmBfScHV9AaBMGSpeh8+DKp81Nw@mail.gmail.com

src/backend/replication/logical/logicalfuncs.c
src/backend/replication/logical/reorderbuffer.c
src/backend/replication/walsender.c

index 55a24c02c9480b5d4a4ea7e0964245e803ae9753..197169d6b0da1694d91380efab075ff0ed269051 100644 (file)
@@ -181,10 +181,10 @@ pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool bin
 
        for (i = 0; i < nelems; i += 2)
        {
-           char       *name = TextDatumGetCString(datum_opts[i]);
+           char       *optname = TextDatumGetCString(datum_opts[i]);
            char       *opt = TextDatumGetCString(datum_opts[i + 1]);
 
-           options = lappend(options, makeDefElem(name, (Node *) makeString(opt), -1));
+           options = lappend(options, makeDefElem(optname, (Node *) makeString(opt), -1));
        }
    }
 
index 0dab0bb64e8d6c668abf44166118e523f3270baa..12edc5772a9c3d78c4d9eda3c729f788130f808e 100644 (file)
@@ -4840,16 +4840,16 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn,
        /* stitch toast tuple back together from its parts */
        dlist_foreach(it, &ent->chunks)
        {
-           bool        isnull;
+           bool        cisnull;
            ReorderBufferChange *cchange;
            ReorderBufferTupleBuf *ctup;
            Pointer     chunk;
 
            cchange = dlist_container(ReorderBufferChange, node, it.cur);
            ctup = cchange->data.tp.newtuple;
-           chunk = DatumGetPointer(fastgetattr(&ctup->tuple, 3, toast_desc, &isnull));
+           chunk = DatumGetPointer(fastgetattr(&ctup->tuple, 3, toast_desc, &cisnull));
 
-           Assert(!isnull);
+           Assert(!cisnull);
            Assert(!VARATT_IS_EXTERNAL(chunk));
            Assert(!VARATT_IS_SHORT(chunk));
 
index 80374c55be51b5147b159b3bd6a870367e6e5cc1..46e48492ac8ebd99af42457b9ce2aed6b5872154 100644 (file)
@@ -3540,7 +3540,7 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
    for (i = 0; i < max_wal_senders; i++)
    {
        WalSnd     *walsnd = &WalSndCtl->walsnds[i];
-       XLogRecPtr  sentPtr;
+       XLogRecPtr  sent_ptr;
        XLogRecPtr  write;
        XLogRecPtr  flush;
        XLogRecPtr  apply;
@@ -3564,7 +3564,7 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
            continue;
        }
        pid = walsnd->pid;
-       sentPtr = walsnd->sentPtr;
+       sent_ptr = walsnd->sentPtr;
        state = walsnd->state;
        write = walsnd->write;
        flush = walsnd->flush;
@@ -3607,9 +3607,9 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
        {
            values[1] = CStringGetTextDatum(WalSndGetStateString(state));
 
-           if (XLogRecPtrIsInvalid(sentPtr))
+           if (XLogRecPtrIsInvalid(sent_ptr))
                nulls[2] = true;
-           values[2] = LSNGetDatum(sentPtr);
+           values[2] = LSNGetDatum(sent_ptr);
 
            if (XLogRecPtrIsInvalid(write))
                nulls[3] = true;