pgsql: Fix lack of message pluralization
Fix lack of message pluralization
Fixups for commits b99b74144f9, 79b101486c1, bf7d19be9b1.
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/534db08f972852b77ea5e96e77d5fe45f3d8df93
Modified Files
--------------
src/backend/commands/trigger.c | 6 ++++--
src/backend/replication/logical/worker.c | 18 ++++++++++++------
src/backend/utils/time/snapmgr.c | 17 +++++++++++++----
3 files changed, 29 insertions(+), 12 deletions(-)
On 3 Sep 2026, at 12:47, Peter Eisentraut <peter@eisentraut.org> wrote:
Fix lack of message pluralization
Maybe I'm daft, but why is the message below pluralized since the %d parameter
is the same?
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -904,8 +904,10 @@ CreateTriggerFiringOn(const CreateTrigStmt *stmt, const char *queryString,
if (nargs > PG_INT16_MAX)
ereport(ERROR,
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
- errmsg("triggers cannot have more than %d arguments",
- PG_INT16_MAX));
+ errmsg_plural("triggers cannot have more than %d argument",
+ "triggers cannot have more than %d arguments",
+ PG_INT16_MAX,
+ PG_INT16_MAX));
--
Daniel Gustafsson
On 03.09.26 13:29, Daniel Gustafsson wrote:
On 3 Sep 2026, at 12:47, Peter Eisentraut <peter@eisentraut.org> wrote:
Fix lack of message pluralization
Maybe I'm daft, but why is the message below pluralized since the %d parameter
is the same?
Do you mean the parameter is constant?
This is correct, but we have some precedent to pluralize these kinds of
things anyway. Several reasons:
- Translators shouldn't have to look into the source code what the
actual value is. (Or, in this case, even beyond the actual source code.)
- Maybe tomorrow someone changes this to PG_UINT16_MAX, and then it
might have to be translated differently.
- Not in this specific case but in general: You might have the same
message in different contexts but with different numbers.
Show quoted text
--- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -904,8 +904,10 @@ CreateTriggerFiringOn(const CreateTrigStmt *stmt, const char *queryString, if (nargs > PG_INT16_MAX) ereport(ERROR, errcode(ERRCODE_TOO_MANY_ARGUMENTS), - errmsg("triggers cannot have more than %d arguments", - PG_INT16_MAX)); + errmsg_plural("triggers cannot have more than %d argument", + "triggers cannot have more than %d arguments", + PG_INT16_MAX, + PG_INT16_MAX));
On 3 Sep 2026, at 14:49, Peter Eisentraut <peter@eisentraut.org> wrote:
On 03.09.26 13:29, Daniel Gustafsson wrote:
On 3 Sep 2026, at 12:47, Peter Eisentraut <peter@eisentraut.org> wrote:
Fix lack of message pluralization
Maybe I'm daft, but why is the message below pluralized since the %d parameter
is the same?Do you mean the parameter is constant?
Right.
This is correct, but we have some precedent to pluralize these kinds of things anyway. Several reasons:
- Translators shouldn't have to look into the source code what the actual value is. (Or, in this case, even beyond the actual source code.)
- Maybe tomorrow someone changes this to PG_UINT16_MAX, and then it might have to be translated differently.
- Not in this specific case but in general: You might have the same message in different contexts but with different numbers.
Makes sense, thanks for explaining!
--
Daniel Gustafsson
On Thu, Sep 03, 2026 at 02:51:31PM +0200, Daniel Gustafsson wrote:
On 3 Sep 2026, at 14:49, Peter Eisentraut <peter@eisentraut.org> wrote:
This is correct, but we have some precedent to pluralize these
kinds of things anyway. Several reasons:- Translators shouldn't have to look into the source code what the
- actual value is. (Or, in this case, even beyond the actual
- source code.)- Maybe tomorrow someone changes this to PG_UINT16_MAX, and then
- it might have to be translated differently.- Not in this specific case but in general: You might have the
- same message in different contexts but with different numbers.Makes sense, thanks for explaining!
Commenting as the guy who has touched the trigger code and added this
message. Thanks for the explanation, will keep that in mind.
--
Michael