On 21.06.23 09:18, Alvaro Herrera wrote:
That is a terrible pattern in relatively new code.  Let's get rid of it
entirely rather than continue to propagate it.

So, I don't think it is fair to say that these format strings are OK
for the existing HEAD code, but not OK for the patch code, when they
are both the same.

Agreed.  Let's remove them all.

This is an open issue for PG16 translation. I propose the attached patch to fix this. Mostly, this just reverts to the previous wordings. (I don't think for these messages the difference between "apply worker" and "parallel apply worker" is all that interesting to explode the number of messages. AFAICT, the table sync worker case wasn't even used, since callers always handled it separately.)
From 6a1558629f97d83c8b11f204b39aceffc94dee8f Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Wed, 12 Jul 2023 13:31:08 +0200
Subject: [PATCH] Fix untranslatable error message assembly

Discussion: 
https://www.postgresql.org/message-id/flat/CAHut%2BPt1xwATviPGjjtJy5L631SGf3qjV9XUCmxLu16cHamfgg%40mail.gmail.com
---
 src/backend/replication/logical/worker.c | 44 +++++++-----------------
 1 file changed, 12 insertions(+), 32 deletions(-)

diff --git a/src/backend/replication/logical/worker.c 
b/src/backend/replication/logical/worker.c
index 0ee764d68f..95b36ced13 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -435,20 +435,6 @@ static inline void reset_apply_error_context_info(void);
 static TransApplyAction get_transaction_apply_action(TransactionId xid,
                                                                                
                         ParallelApplyWorkerInfo **winfo);
 
-/*
- * Return the name of the logical replication worker.
- */
-static const char *
-get_worker_name(void)
-{
-       if (am_tablesync_worker())
-               return _("logical replication table synchronization worker");
-       else if (am_parallel_apply_worker())
-               return _("logical replication parallel apply worker");
-       else
-               return _("logical replication apply worker");
-}
-
 /*
  * Form the origin name for the subscription.
  *
@@ -3904,9 +3890,8 @@ maybe_reread_subscription(void)
        if (!newsub)
        {
                ereport(LOG,
-               /* translator: first %s is the name of logical replication 
worker */
-                               (errmsg("%s for subscription \"%s\" will stop 
because the subscription was removed",
-                                               get_worker_name(), 
MySubscription->name)));
+                               (errmsg("logical replication apply worker for 
subscription \"%s\" will stop because the subscription was removed",
+                                               MySubscription->name)));
 
                /* Ensure we remove no-longer-useful entry for worker's start 
time */
                if (!am_tablesync_worker() && !am_parallel_apply_worker())
@@ -3918,9 +3903,8 @@ maybe_reread_subscription(void)
        if (!newsub->enabled)
        {
                ereport(LOG,
-               /* translator: first %s is the name of logical replication 
worker */
-                               (errmsg("%s for subscription \"%s\" will stop 
because the subscription was disabled",
-                                               get_worker_name(), 
MySubscription->name)));
+                               (errmsg("logical replication apply worker for 
subscription \"%s\" will stop because the subscription was disabled",
+                                               MySubscription->name)));
 
                apply_worker_exit();
        }
@@ -3954,9 +3938,8 @@ maybe_reread_subscription(void)
                                                        MySubscription->name)));
                else
                        ereport(LOG,
-                       /* translator: first %s is the name of logical 
replication worker */
-                                       (errmsg("%s for subscription \"%s\" 
will restart because of a parameter change",
-                                                       get_worker_name(), 
MySubscription->name)));
+                                       (errmsg("logical replication apply 
worker for subscription \"%s\" will restart because of a parameter change",
+                                                       MySubscription->name)));
 
                apply_worker_exit();
        }
@@ -4478,9 +4461,8 @@ InitializeApplyWorker(void)
        if (!MySubscription)
        {
                ereport(LOG,
-               /* translator: %s is the name of logical replication worker */
-                               (errmsg("%s for subscription %u will not start 
because the subscription was removed during startup",
-                                               get_worker_name(), 
MyLogicalRepWorker->subid)));
+                               (errmsg("logical replication apply worker for 
subscription %u will not start because the subscription was removed during 
startup",
+                                               MyLogicalRepWorker->subid)));
 
                /* Ensure we remove no-longer-useful entry for worker's start 
time */
                if (!am_tablesync_worker() && !am_parallel_apply_worker())
@@ -4494,9 +4476,8 @@ InitializeApplyWorker(void)
        if (!MySubscription->enabled)
        {
                ereport(LOG,
-               /* translator: first %s is the name of logical replication 
worker */
-                               (errmsg("%s for subscription \"%s\" will not 
start because the subscription was disabled during startup",
-                                               get_worker_name(), 
MySubscription->name)));
+                               (errmsg("logical replication apply worker for 
subscription \"%s\" will not start because the subscription was disabled during 
startup",
+                                               MySubscription->name)));
 
                apply_worker_exit();
        }
@@ -4517,9 +4498,8 @@ InitializeApplyWorker(void)
                                                
get_rel_name(MyLogicalRepWorker->relid))));
        else
                ereport(LOG,
-               /* translator: first %s is the name of logical replication 
worker */
-                               (errmsg("%s for subscription \"%s\" has 
started",
-                                               get_worker_name(), 
MySubscription->name)));
+                               (errmsg("logical replication apply worker for 
subscription \"%s\" has started",
+                                               MySubscription->name)));
 
        CommitTransactionCommand();
 }
-- 
2.41.0

Reply via email to