Re: Pasword expiration warning - Mailing list pgsql-hackers

From Euler Taveira
Subject Re: Pasword expiration warning
Date
Msg-id f04d4dc5-c7a7-4987-bc20-4b97f45ab92d@app.fastmail.com
Whole thread Raw
In response to Re: Pasword expiration warning  (Gilles Darold <gilles@darold.net>)
Responses Re: Pasword expiration warning
List pgsql-hackers
On Fri, Jan 9, 2026, at 8:27 AM, Gilles Darold wrote:
>
> Here is a v11 version of the patch.
>

+           if (result <= (TimestampTz) password_expire_warning)
+           {
+               MyClientConnectionInfo.warning_message =
+                   psprintf(_("your password will expire in %d day(s)"),
+                            (int) (result / SECS_PER_DAY));
+           }

You should use ngettext() for plural forms. I don't think you need a string
into ClientConnectionInfo. Instead, you could store only the number of days.

+   /*
+    * Emit a warning message to the client when set, for example
+    * to warn the user that the password will expire.
+    */
+   if (MyClientConnectionInfo.warning_message)
+       ereport(WARNING, (errmsg("%s", MyClientConnectionInfo.warning_message)));
+

... and you construct the message directly in the ereport().


-- 
Euler Taveira
EDB   https://www.enterprisedb.com/



pgsql-hackers by date:

Previous
From: Ahmed Et-tanany
Date:
Subject: Re: [PATCH] Add max_logical_replication_slots GUC
Next
From: Álvaro Herrera
Date:
Subject: Re: [PATCH] Add max_logical_replication_slots GUC