[PATCH] remove incorrect comment in pg_resetwal.c

Started by Gavin LYU8 months ago6 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t53104
psql -h localhost -U postgres

Built from patchset v1 (message #1), July 27, 2026 at 04:53 AM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t53104_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t53104_1 && git checkout t53104_1

Patchset v1 (message #1) is on t53104_1

Jump to latest
#1Gavin LYU
gavin790417@gmail.com

Hi Hackers,

While reading the code, I noticed an incorrect comment in the main() function
of src/bin/pg_resetwal/pg_resetwal.c.

In the block handling the -e option, there’s a comment that appears to be a
copy-paste error (line 190 and 191). It references a second %s, but none
exists in that format string. Moreover, similar argument-handling code for
other options doesn’t include such a comment.

I believe it should be removed.
Attached is a patch that fixes this issue.

Best regards,
--
Gavin LYU

Attachments:

t53104_1
0001-PATCH-remove-wrong-comment-in-pg_resetwal.c.patchapplication/octet-stream; name=0001-PATCH-remove-wrong-comment-in-pg_resetwal.c.patchDownload+0-3
#2Michael Paquier
michael@paquier.xyz
In reply to: Gavin LYU (#1)
Re: [PATCH] remove incorrect comment in pg_resetwal.c

On Fri, Jan 16, 2026 at 02:45:42PM +0800, Gavin LYU wrote:

In the block handling the -e option, there’s a comment that appears to be a
copy-paste error (line 190 and 191). It references a second %s, but none
exists in that format string. Moreover, similar argument-handling code for
other options doesn’t include such a comment.

I believe it should be removed.

I disagree. This note still looks helpful to me when it comes to
translation even if it is incorrect: the %s markup refers to an option
switch.
--
Michael

#3David Rowley
dgrowleyml@gmail.com
In reply to: Michael Paquier (#2)
Re: [PATCH] remove incorrect comment in pg_resetwal.c

On Fri, 16 Jan 2026 at 19:53, Michael Paquier <michael@paquier.xyz> wrote:

On Fri, Jan 16, 2026 at 02:45:42PM +0800, Gavin LYU wrote:

In the block handling the -e option, there’s a comment that appears to be a
copy-paste error (line 190 and 191). It references a second %s, but none
exists in that format string. Moreover, similar argument-handling code for
other options doesn’t include such a comment.

I believe it should be removed.

I disagree. This note still looks helpful to me when it comes to
translation even if it is incorrect: the %s markup refers to an option
switch.

I think fixing it rather than removing it is the way to go. cc8d41511
removed the first va arg and didn't update the comment.

git diff cc8d41511~1..cc8d41511 -- */pg_resetwal.c | grep translator -C 3
@@ -156,13 +157,13 @@ main(int argc, char *argv[])
                                {
                                        /*------
                                          translator: the second %s is
a command line argument (-e, etc) */
-                                       fprintf(stderr, _("%s: invalid
argument for option %s\n"), progname, "-e");
+                                       pg_log_error("invalid argument
for option %s", "-e");
                                        fprintf(stderr, _("Try \"%s
--help\" for more information.\n"), progname);

We should delete "the second"

David

#4Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: David Rowley (#3)
Re: [PATCH] remove incorrect comment in pg_resetwal.c

On 2026-Jan-16, David Rowley wrote:

I think fixing it rather than removing it is the way to go. cc8d41511
removed the first va arg and didn't update the comment.

git diff cc8d41511~1..cc8d41511 -- */pg_resetwal.c | grep translator -C 3
@@ -156,13 +157,13 @@ main(int argc, char *argv[])
{
/*------
translator: the second %s is
a command line argument (-e, etc) */
-                                       fprintf(stderr, _("%s: invalid
argument for option %s\n"), progname, "-e");
+                                       pg_log_error("invalid argument
for option %s", "-e");
fprintf(stderr, _("Try \"%s
--help\" for more information.\n"), progname);

Right. So the fix is to remove the word "second". But there are more
mistakes of the same ilk in the same commit, visible if you remove the
"-- */pg_resetwal.c" part of your command line.

So I propose to park the following in Michael's trivial fixes branch.

diff --git a/src/bin/pg_basebackup/pg_receivewal.c b/src/bin/pg_basebackup/pg_receivewal.c
index 4f9a7b076ca..ddfec298fb7 100644
--- a/src/bin/pg_basebackup/pg_receivewal.c
+++ b/src/bin/pg_basebackup/pg_receivewal.c
@@ -770,7 +770,7 @@ main(int argc, char **argv)
 	if (replication_slot == NULL && (do_drop_slot || do_create_slot))
 	{
-		/* translator: second %s is an option name */
+		/* translator: %s is an option name */
 		pg_log_error("%s needs a slot to be specified using --slot",
 					 do_drop_slot ? "--drop-slot" : "--create-slot");
 		pg_log_error_hint("Try \"%s --help\" for more information.", progname);
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
index b2c4b9db395..2e3dfd7c94a 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -188,7 +188,7 @@ main(int argc, char *argv[])
 				if (endptr == optarg || *endptr != '\0' || errno != 0)
 				{
 					/*------
-					  translator: the second %s is a command line argument (-e, etc) */
+					  translator: %s is a command line argument (-e, etc) */
 					pg_log_error("invalid argument for option %s", "-e");
 					pg_log_error_hint("Try \"%s --help\" for more information.", progname);
 					exit(1);

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"No tengo por qué estar de acuerdo con lo que pienso"
(Carlos Caszeli)

#5Fujii Masao
masao.fujii@gmail.com
In reply to: David Rowley (#3)
Re: [PATCH] remove incorrect comment in pg_resetwal.c

On Fri, Jan 16, 2026 at 7:10 PM David Rowley <dgrowleyml@gmail.com> wrote:

On Fri, 16 Jan 2026 at 19:53, Michael Paquier <michael@paquier.xyz> wrote:

On Fri, Jan 16, 2026 at 02:45:42PM +0800, Gavin LYU wrote:

In the block handling the -e option, there’s a comment that appears to be a
copy-paste error (line 190 and 191). It references a second %s, but none
exists in that format string. Moreover, similar argument-handling code for
other options doesn’t include such a comment.

I believe it should be removed.

I disagree. This note still looks helpful to me when it comes to
translation even if it is incorrect: the %s markup refers to an option
switch.

I think fixing it rather than removing it is the way to go. cc8d41511
removed the first va arg and didn't update the comment.

git diff cc8d41511~1..cc8d41511 -- */pg_resetwal.c | grep translator -C 3
@@ -156,13 +157,13 @@ main(int argc, char *argv[])
{
/*------
translator: the second %s is
a command line argument (-e, etc) */
-                                       fprintf(stderr, _("%s: invalid
argument for option %s\n"), progname, "-e");
+                                       pg_log_error("invalid argument
for option %s", "-e");
fprintf(stderr, _("Try \"%s
--help\" for more information.\n"), progname);

We should delete "the second"

+1

Commit cc8d41511 made a similar change in pg_receivewal.c, as follows.
This should be fixed as well.

  /* translator: second %s is an option name */
- fprintf(stderr, _("%s: %s needs a slot to be specified using
--slot\n"), progname,
+ pg_log_error("%s needs a slot to be specified using --slot",

Regards,

--
Fujii Masao

#6Michael Paquier
michael@paquier.xyz
In reply to: David Rowley (#3)
Re: [PATCH] remove incorrect comment in pg_resetwal.c

On Fri, Jan 16, 2026 at 11:41:58AM +0100, Alvaro Herrera wrote:

Right. So the fix is to remove the word "second". But there are more
mistakes of the same ilk in the same commit, visible if you remove the
"-- */pg_resetwal.c" part of your command line.

So I propose to park the following in Michael's trivial fixes
branch.

Sounds about right to me. Integrated now.
--
Michael