I was looking for missing use of gettext plural forms, which led me to
errdetail_busy_db().

While we can't do much about this:

    errdetail("There are %d other session(s) and %d prepared transaction(s) 
using the database.",
              notherbackends, npreparedxacts);

I think it's still worth pluralizing the other cases

    errdetail("There are %d other session(s) using the database.",
              notherbackends);

and

    errdetail("There are %d prepared transaction(s) using the database.",
              npreparedxacts);

Especially the "other sessions" case is probably the one most seen by users.

So I propose the attached patch.

diff --git i/src/backend/commands/dbcommands.c w/src/backend/commands/dbcommands.c
index b7224bd..c9b80ad 100644
--- i/src/backend/commands/dbcommands.c
+++ w/src/backend/commands/dbcommands.c
@@ -1804,20 +1804,21 @@ static bool get_db_info(const char *name, LOCKMODE lockmode,
 static int
 errdetail_busy_db(int notherbackends, int npreparedxacts)
 {
-	/*
-	 * We don't worry about singular versus plural here, since the English
-	 * rules for that don't translate very well.  But we can at least avoid
-	 * the case of zero items.
-	 */
 	if (notherbackends > 0 && npreparedxacts > 0)
+		/* We don't deal with singular versus plural here, since gettext
+		 * doesn't support multiple plurals in one string. */
 		errdetail("There are %d other session(s) and %d prepared transaction(s) using the database.",
 				  notherbackends, npreparedxacts);
 	else if (notherbackends > 0)
-		errdetail("There are %d other session(s) using the database.",
-				  notherbackends);
+		errdetail_plural("There is %d other session using the database.",
+						 "There are %d other sessions using the database.",
+						 notherbackends,
+						 notherbackends);
 	else
-		errdetail("There are %d prepared transaction(s) using the database.",
-				  npreparedxacts);
+		errdetail_plural("There is %d prepared transaction using the database.",
+						 "There are %d prepared transactions using the database.",
+						 npreparedxacts,
+						 npreparedxacts);
 	return 0;					/* just to keep ereport macro happy */
 }
 
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to