]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix latent bug in get_stats_option_name()
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 30 Mar 2026 17:34:48 +0000 (20:34 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 30 Mar 2026 17:34:48 +0000 (20:34 +0300)
The function is supposed to look at the passed in 'arg' argument, but
peeks at the 'optarg' global variable that's part of getopt()
instead. It happened to work anyway, because all callers passed
'optarg' as the argument.

Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://www.postgresql.org/message-id/d1da5f0e-0d68-47c9-a882-eb22f462752f@iki.fi

src/backend/tcop/postgres.c

index b3563113219149ab0acbcfb7b34951b9739056cf..04f4ae116a5be92f6de84667898bedbd755d462f 100644 (file)
@@ -3796,9 +3796,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;