]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix new-to-v19 -Wshadow warnings
authorDavid Rowley <drowley@postgresql.org>
Thu, 23 Apr 2026 04:49:29 +0000 (16:49 +1200)
committerDavid Rowley <drowley@postgresql.org>
Thu, 23 Apr 2026 04:49:29 +0000 (16:49 +1200)
There's some talk about upgrading our current -Wshadow=compatible-local
up to -Wshadow.  There's some pending questions as to whether the churn
and extra backpatching pain are worthwhile for doing all of them.  We
can't use the latter argument for ones that are new to v19, providing we
fix them now.  So let's fix those ones so that the problem is not any
worse for if we decide to fix the remainder for v20.

Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Yuchen Li <liyuchen_xyz@163.com>
Discussion: https://postgr.es/m/CAApHDvp=rx5GxM=yW8QhFF3noXtYt7LkOxJ7zkaPOzpti4Gm8w@mail.gmail.com

src/backend/commands/tablecmds.c
src/backend/commands/wait.c
src/backend/postmaster/datachecksum_state.c
src/bin/pg_dump/pg_dumpall.c
src/bin/psql/describe.c

index 32db5a899dc88f6d5b2fe4f10cd37aefb4c8e7ca..d8d7969bf303a3867f99edf4691842d6e837b9b1 100644 (file)
@@ -22636,7 +22636,7 @@ createTableConstraints(List **wqueue, AlteredTableInfo *tab,
                bool            ccvalid = constr->check[ccnum].ccvalid;
                Node       *ccbin_node;
                bool            found_whole_row;
-               Constraint *constr;
+               Constraint *con;
 
                /*
                 * The partitioned table can not have a NO INHERIT check constraint
@@ -22658,19 +22658,19 @@ createTableConstraints(List **wqueue, AlteredTableInfo *tab,
                                 ccname,
                                 RelationGetRelationName(parent_rel));
 
-               constr = makeNode(Constraint);
-               constr->contype = CONSTR_CHECK;
-               constr->conname = pstrdup(ccname);
-               constr->deferrable = false;
-               constr->initdeferred = false;
-               constr->is_enforced = ccenforced;
-               constr->skip_validation = !ccvalid;
-               constr->initially_valid = ccvalid;
-               constr->is_no_inherit = ccnoinherit;
-               constr->raw_expr = NULL;
-               constr->cooked_expr = nodeToString(ccbin_node);
-               constr->location = -1;
-               constraints = lappend(constraints, constr);
+               con = makeNode(Constraint);
+               con->contype = CONSTR_CHECK;
+               con->conname = pstrdup(ccname);
+               con->deferrable = false;
+               con->initdeferred = false;
+               con->is_enforced = ccenforced;
+               con->skip_validation = !ccvalid;
+               con->initially_valid = ccvalid;
+               con->is_no_inherit = ccnoinherit;
+               con->raw_expr = NULL;
+               con->cooked_expr = nodeToString(ccbin_node);
+               con->location = -1;
+               constraints = lappend(constraints, con);
        }
 
        /* Install all CHECK constraints. */
index 382d5c2d44ffbe1f440bb4edc601c326cd1d4d35..40a6ffde16b7cab86a0a31188365057ee18f3947 100644 (file)
@@ -92,7 +92,7 @@ ExecWaitStmt(ParseState *pstate, WaitStmt *stmt, bool isTopLevel,
                {
                        char       *timeout_str;
                        const char *hintmsg;
-                       double          result;
+                       double          dval;
 
                        if (timeout_specified)
                                errorConflictingDefElem(defel, pstate);
@@ -100,7 +100,7 @@ ExecWaitStmt(ParseState *pstate, WaitStmt *stmt, bool isTopLevel,
 
                        timeout_str = defGetString(defel);
 
-                       if (!parse_real(timeout_str, &result, GUC_UNIT_MS, &hintmsg))
+                       if (!parse_real(timeout_str, &dval, GUC_UNIT_MS, &hintmsg))
                        {
                                ereport(ERROR,
                                                errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@@ -113,20 +113,20 @@ ExecWaitStmt(ParseState *pstate, WaitStmt *stmt, bool isTopLevel,
                         * don't fail on just-out-of-range values that would round into
                         * range.
                         */
-                       result = rint(result);
+                       dval = rint(dval);
 
                        /* Range check */
-                       if (unlikely(isnan(result) || !FLOAT8_FITS_IN_INT64(result)))
+                       if (unlikely(isnan(dval) || !FLOAT8_FITS_IN_INT64(dval)))
                                ereport(ERROR,
                                                errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
                                                errmsg("timeout value is out of range"));
 
-                       if (result < 0)
+                       if (dval < 0)
                                ereport(ERROR,
                                                errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                                errmsg("timeout cannot be negative"));
 
-                       timeout = (int64) result;
+                       timeout = (int64) dval;
                }
                else if (strcmp(defel->defname, "no_throw") == 0)
                {
index b3e991706699dec1b99af2cd66a3a039e2594b05..5556a9ca893a5ba2acd503ad7ad15d3ff8fa5717 100644 (file)
@@ -546,7 +546,7 @@ StartDataChecksumsWorkerLauncher(DataChecksumsWorkerOperation op,
 {
        BackgroundWorker bgw;
        BackgroundWorkerHandle *bgw_handle;
-       bool            launcher_running;
+       bool            running;
        DataChecksumsWorkerOperation launcher_running_op;
 
 #ifdef USE_ASSERT_CHECKING
@@ -565,8 +565,8 @@ StartDataChecksumsWorkerLauncher(DataChecksumsWorkerOperation op,
        DataChecksumState->launch_cost_limit = cost_limit;
 
        /* Is the launcher already running? If so, what is it doing? */
-       launcher_running = DataChecksumState->launcher_running;
-       if (launcher_running)
+       running = DataChecksumState->launcher_running;
+       if (running)
                launcher_running_op = DataChecksumState->operation;
 
        LWLockRelease(DataChecksumsWorkerLock);
@@ -589,7 +589,7 @@ StartDataChecksumsWorkerLauncher(DataChecksumsWorkerOperation op,
         * already in the desired state, i.e. if the checksums are already enabled
         * and you call pg_enable_data_checksums().
         */
-       if (!launcher_running)
+       if (!running)
        {
                /*
                 * Prepare the BackgroundWorker and launch it.
index 9e904f76baa3f6d6b1c4d48ef9d66d707adfe2e8..c1f43113c533e537d4e5a445d074a8227d31c2ef 100644 (file)
@@ -83,7 +83,7 @@ static void buildShSecLabels(PGconn *conn,
                                                         PQExpBuffer buffer);
 static void executeCommand(PGconn *conn, const char *query);
 static void check_for_invalid_global_names(PGconn *conn,
-                                                                                  SimpleStringList *database_exclude_names);
+                                                                                  SimpleStringList *excluded_names);
 static void expand_dbname_patterns(PGconn *conn, SimpleStringList *patterns,
                                                                   SimpleStringList *names);
 static void read_dumpall_filters(const char *filename, SimpleStringList *pattern);
@@ -2269,7 +2269,7 @@ executeCommand(PGconn *conn, const char *query)
  */
 static void
 check_for_invalid_global_names(PGconn *conn,
-                                                          SimpleStringList *database_exclude_names)
+                                                          SimpleStringList *excluded_names)
 {
        PGresult   *res;
        int                     i;
@@ -2296,7 +2296,7 @@ check_for_invalid_global_names(PGconn *conn,
 
                /* Skip excluded databases since they won't be in map.dat */
                if (strcmp(objtype, "database") == 0 &&
-                       simple_string_list_member(database_exclude_names, objname))
+                       simple_string_list_member(excluded_names, objname))
                        continue;
 
                if (strpbrk(objname, "\n\r"))
@@ -2406,29 +2406,27 @@ read_dumpall_filters(const char *filename, SimpleStringList *pattern)
 static ArchiveFormat
 parseDumpFormat(const char *format)
 {
-       ArchiveFormat archDumpFormat;
-
        if (pg_strcasecmp(format, "c") == 0)
-               archDumpFormat = archCustom;
+               return archCustom;
        else if (pg_strcasecmp(format, "custom") == 0)
-               archDumpFormat = archCustom;
+               return archCustom;
        else if (pg_strcasecmp(format, "d") == 0)
-               archDumpFormat = archDirectory;
+               return archDirectory;
        else if (pg_strcasecmp(format, "directory") == 0)
-               archDumpFormat = archDirectory;
+               return archDirectory;
        else if (pg_strcasecmp(format, "p") == 0)
-               archDumpFormat = archNull;
+               return archNull;
        else if (pg_strcasecmp(format, "plain") == 0)
-               archDumpFormat = archNull;
+               return archNull;
        else if (pg_strcasecmp(format, "t") == 0)
-               archDumpFormat = archTar;
+               return archTar;
        else if (pg_strcasecmp(format, "tar") == 0)
-               archDumpFormat = archTar;
+               return archTar;
        else
                pg_fatal("unrecognized output format \"%s\"; please specify \"c\", \"d\", \"p\", or \"t\"",
                                 format);
 
-       return archDumpFormat;
+       return archUnknown;
 }
 
 /*
index dd1179ef927be8bc02f891807dfef32828fa9faf..4a1ab873260697c9cee68153879de29df326cf73 100644 (file)
@@ -1938,7 +1938,7 @@ describeOneTableDetails(const char *schemaname,
         */
        if (tableinfo.relkind == RELKIND_PROPGRAPH)
        {
-               printQueryOpt myopt = pset.popt;
+               printQueryOpt popt = pset.popt;
                char       *footers[3] = {NULL, NULL, NULL};
 
                printfPQExpBuffer(&buf, "/* %s */\n", _("Get property graph information"));
@@ -1993,12 +1993,12 @@ describeOneTableDetails(const char *schemaname,
                        }
                }
 
-               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);
 
                free(footers[0]);
                free(footers[1]);