On Wed, Aug 02, 2023 at 09:09:14AM -0700, Nathan Bossart wrote:
> On Wed, Aug 02, 2023 at 01:02:53PM +0530, Bharath Rupireddy wrote:
>> On Wed, Aug 2, 2023 at 12:45 PM Peter Eisentraut <pe...@eisentraut.org> 
>> wrote:
>>> I think we should change the output format to be more like initdb, like
>>>
>>>      Doing something ... ok
>>>
>>> without horizontally aligning all the "ok"s.
>> 
>> While this looks simple, we might end up with a lot of diff and
>> changes after removing MESSAGE_WIDTH. There's a significant part of
>> pg_upgrade code that deals with MESSAGE_WIDTH. I don't think it's
>> worth the effort. Therefore, I'd prefer the simplest possible fix -
>> change the message to '"Checking for  \"aclitem\" data type in user
>> tables". It may be an overkill, but we can consider adding
>> Assert(sizeof(message) < MESSAGE_WIDTH) in progress report functions
>> to not encourage new messages to end up in the same formatting issue.
> 
> I don't think it's that difficult.  ІMO the bigger question is whether we
> want to back-patch such a change to v16 at this point.

Here is a work-in-progress patch that seems to get things pretty close to
what Peter is suggesting.

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
>From 1a8aab9c9c86c8fa140ccdb53d3479a77de0e762 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nat...@postgresql.org>
Date: Wed, 2 Aug 2023 10:20:11 -0700
Subject: [PATCH 1/1] work-in-progress: fix pg_upgrade output

---
 src/bin/pg_upgrade/util.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_upgrade/util.c b/src/bin/pg_upgrade/util.c
index 21ba4c8f12..bea6d7289d 100644
--- a/src/bin/pg_upgrade/util.c
+++ b/src/bin/pg_upgrade/util.c
@@ -50,10 +50,10 @@ end_progress_output(void)
 	if (log_opts.isatty)
 	{
 		printf("\r");
-		pg_log(PG_REPORT_NONL, "%-*s", MESSAGE_WIDTH, "");
+		pg_log(PG_REPORT_NONL, "%-*s\r  ", MESSAGE_WIDTH, "");
 	}
 	else if (log_opts.verbose)
-		pg_log(PG_REPORT_NONL, "%-*s", MESSAGE_WIDTH, "");
+		pg_log(PG_REPORT_NONL, "  ");
 }
 
 /*
@@ -114,9 +114,6 @@ cleanup_output_dirs(void)
  * prep_status
  *
  *	Displays a message that describes an operation we are about to begin.
- *	We pad the message out to MESSAGE_WIDTH characters so that all of the
- *	"ok" and "failed" indicators line up nicely.  (Overlength messages
- *	will be truncated, so don't get too verbose.)
  *
  *	A typical sequence would look like this:
  *		prep_status("about to flarb the next %d files", fileCount);
@@ -135,8 +132,7 @@ prep_status(const char *fmt,...)
 	vsnprintf(message, sizeof(message), fmt, args);
 	va_end(args);
 
-	/* trim strings */
-	pg_log(PG_REPORT_NONL, "%-*s", MESSAGE_WIDTH, message);
+	pg_log(PG_REPORT_NONL, "%s ... ", message);
 }
 
 /*
@@ -167,9 +163,9 @@ prep_status_progress(const char *fmt,...)
 	 * put the individual progress items onto the next line.
 	 */
 	if (log_opts.isatty || log_opts.verbose)
-		pg_log(PG_REPORT, "%-*s", MESSAGE_WIDTH, message);
+		pg_log(PG_REPORT, "%s ...", message);
 	else
-		pg_log(PG_REPORT_NONL, "%-*s", MESSAGE_WIDTH, message);
+		pg_log(PG_REPORT_NONL, "%s ... ", message);
 }
 
 static void
-- 
2.25.1

Reply via email to