"Unified logging system" breaks access to pg_dump debug outputs - Mailing list pgsql-hackers

From Tom Lane
Subject "Unified logging system" breaks access to pg_dump debug outputs
Date
Msg-id 1173106.1600116625@sss.pgh.pa.us
Whole thread Raw
Responses Re: "Unified logging system" breaks access to pg_dump debug outputs
List pgsql-hackers
pg_dump et al have some low-level debug log messages that commit
cc8d41511 converted to pg_log_debug() calls, replacing the previous
one-off logging verbosity system that was there.  However, these
calls are dead code as things stand, because there is no way to set
__pg_log_level high enough to get them to print.

I propose the attached minimal patch to restore the previous
functionality.

Alternatively, we might consider inventing an additional logging.c
function pg_logging_increase_level() with the obvious semantics, and
make the various programs just call that when they see a -v switch.
That would be a slightly bigger patch, but it would more easily support
programs with a range of useful verbosities, so maybe that's a better
idea.

In a quick look around, I could not find any other unreachable
pg_log_debug calls.

(Note: it seems possible that the theoretical multiple verbosity
levels in pg_dump were already broken before cc8d41511, because
right offhand I do not see any code that that removed that would
have allowed invoking the higher levels either.  Nonetheless, there
is no point in carrying dead code --- and these messages *are*
of some interest.  I discovered this problem while trying to
debug parallel pg_restore behavior just now, and wondering
why "-v -v" didn't produce the messages I saw in the source code.)

            regards, tom lane

diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 784bceaec3..08a2976a6b 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -511,8 +511,11 @@ main(int argc, char **argv)
                 break;
 
             case 'v':            /* verbose */
+                if (g_verbose)
+                    pg_logging_set_level(PG_LOG_DEBUG); /* -v -v */
+                else
+                    pg_logging_set_level(PG_LOG_INFO);
                 g_verbose = true;
-                pg_logging_set_level(PG_LOG_INFO);
                 break;
 
             case 'w':
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 97d2b8dac1..11eeb36aa1 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -282,8 +282,11 @@ main(int argc, char *argv[])
                 break;
 
             case 'v':
+                if (verbose)
+                    pg_logging_set_level(PG_LOG_DEBUG); /* -v -v */
+                else
+                    pg_logging_set_level(PG_LOG_INFO);
                 verbose = true;
-                pg_logging_set_level(PG_LOG_INFO);
                 appendPQExpBufferStr(pgdumpopts, " -v");
                 break;
 
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 544ae3bc5c..af04aa0787 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -244,8 +244,11 @@ main(int argc, char **argv)
                 break;
 
             case 'v':            /* verbose */
+                if (opts->verbose)
+                    pg_logging_set_level(PG_LOG_DEBUG); /* -v -v */
+                else
+                    pg_logging_set_level(PG_LOG_INFO);
                 opts->verbose = 1;
-                pg_logging_set_level(PG_LOG_INFO);
                 break;
 
             case 'w':

pgsql-hackers by date:

Previous
From: Neha Sharma
Date:
Subject: Re: Subscription test 013_partition.pl fails under CLOBBER_CACHE_ALWAYS
Next
From: Robert Haas
Date:
Subject: Re: Allow ERROR from heap_prepare_freeze_tuple to be downgraded to WARNING