public inbox for [email protected]  
help / color / mirror / Atom feed
From: Peter Smith <[email protected]>
To: PostgreSQL Hackers <[email protected]>
Subject: Redundant/mis-use of _(x) gettext macro?
Date: Wed, 1 Apr 2026 14:48:08 +1100
Message-ID: <CAHut+Pvp7jYcaiZ3pXedXgLcWZWDBLXFUK05JtZpGv3Mj=UOjw@mail.gmail.com> (raw)

Hi.

As originally reported [1] in the EXCEPT (TABLE ...) thread, I felt
the _() gettext macro is mis-used when it contains nothing but a
quoted format string.

AFAIK the purpose of using gettext (e.g. the "_(x)" macro) is for
marking the string for i18n translation. But there's nothing even to
translate here.

Only 2 examples were found like this. Granted, this is probably not
very harmful, but IMO it's better to patch the mis-use to prevent it
from propagating.

PSA the patch for more details.

======
[1] https://www.postgresql.org/message-id/CAHut%2BPtVaOYVP1R0TOoNh5G9CUBurrP%3D6i7fJCdfWEZiqVCRvw%40mail...

Kind Regards,
Peter Smith.
Fujitsu Australia


Attachments:

  [application/octet-stream] v1-0001-misuse-of-gettext-macro.patch (1.4K, 2-v1-0001-misuse-of-gettext-macro.patch)
  download | inline diff:
From bd2a5ba9e7d65b4fc6e964048437ad776246b067 Mon Sep 17 00:00:00 2001
From: Peter Smith <[email protected]>
Date: Wed, 1 Apr 2026 14:40:18 +1100
Subject: [PATCH v1] misuse of gettext macro

---
 src/backend/commands/tablecmds.c           | 2 +-
 src/backend/replication/logical/relation.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 4ee58feb10e..65229b7384e 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -20732,7 +20732,7 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd,
 
 			first = false;
 
-			appendStringInfo(&pubnames, _("\"%s\""), pubname);
+			appendStringInfo(&pubnames, "\"%s\"", pubname);
 		}
 
 		ereport(ERROR,
diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c
index 0b1d80b5b0f..02e60ddf516 100644
--- a/src/backend/replication/logical/relation.c
+++ b/src/backend/replication/logical/relation.c
@@ -253,7 +253,7 @@ logicalrep_get_attrs_str(LogicalRepRelation *remoterel, Bitmapset *atts)
 			/* translator: This is a separator in a list of entity names. */
 			appendStringInfoString(&attsbuf, _(", "));
 
-		appendStringInfo(&attsbuf, _("\"%s\""), remoterel->attnames[i]);
+		appendStringInfo(&attsbuf, "\"%s\"", remoterel->attnames[i]);
 	}
 
 	return attsbuf.data;
-- 
2.47.3



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Redundant/mis-use of _(x) gettext macro?
  In-Reply-To: <CAHut+Pvp7jYcaiZ3pXedXgLcWZWDBLXFUK05JtZpGv3Mj=UOjw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox