The caller of `get_stats_option_name` pass optarg as the argument, it's saner to use the argument instead of the global variable set by getopt, which is more safe since the argument has a *const* specifier.
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 11e802eba9..68552b8779 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -3598,9 +3598,9 @@ get_stats_option_name(const char *arg) switch (arg[0]) { case 'p': - if (optarg[1] == 'a') /* "parser" */ + if (arg[1] == 'a') /* "parser" */ return "log_parser_stats"; - else if (optarg[1] == 'l') /* "planner" */ + else if (arg[1] == 'l') /* "planner" */ return "log_planner_stats"; break; -- Regards Junwang Zhao