Re: Pasword expiration warning
Euler Taveira <euler@eulerto.com>
From: "Euler Taveira" <euler@eulerto.com>
To: "Gilles Darold" <gilles@darold.net>, japin <japinli@hotmail.com>
Cc: "Yuefei Shi" <shiyuefei1004@gmail.com>,
songjinzhou <tsinghualucky912@foxmail.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>,
"Andrew Dunstan" <andrew@dunslane.net>,
"Bossart, Nathan" <bossartn@amazon.com>, "Tom Lane" <tgl@sss.pgh.pa.us>,
"liu xiaohui" <liuxh.zj.cn@gmail.com>, "Steven Niu" <niushiji@gmail.com>
Date: 2026-01-28T12:44:55Z
Lists: 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/
Commits
-
Add password expiration warnings.
- 1d92e0c2cc47 19 (unreleased) landed