public inbox for [email protected]
help / color / mirror / Atom feedFrom: Gilles Darold <[email protected]>
To: [email protected]
Subject: Re: Pasword expiration warning
Date: Thu, 29 Jan 2026 16:39:54 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<MEAPR01MB3031D75330A64DD25A5B8A04B685A@MEAPR01MB3031.ausprd01.prod.outlook.com>
<[email protected]>
<MEAPR01MB30311B76AFD06D3CAEAEF9C7B685A@MEAPR01MB3031.ausprd01.prod.outlook.com>
<[email protected]>
<MEAPR01MB303185AAA6F5BF90759D5E86B685A@MEAPR01MB3031.ausprd01.prod.outlook.com>
<[email protected]>
<MEAPR01MB303142AEB3F47886C171194EB682A@MEAPR01MB3031.ausprd01.prod.outlook.com>
<CAD43U4WHJm=UkxbfhxQRxQRxtdtu7AGj77uO2fF78THQWCaYTg@mail.gmail.com>
<MEAPR01MB30319B858B3028CA38BEDC5EB682A@MEAPR01MB3031.ausprd01.prod.outlook.com>
<MN2PR15MB30212CEFE2F8B93C398FBF60A782A@MN2PR15MB3021.namprd15.prod.outlook.com>
<MEAPR01MB30319C7BB75B88028E1DB7E1B682A@MEAPR01MB3031.ausprd01.prod.outlook.com>
<[email protected]>
<[email protected]>
Le 28/01/2026 à 13:44, Euler Taveira a écrit :
> 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.
Is it a use we must do now or a wish?
$ grep -r "ngettext(" src/backend/ | wc -l
9
$ grep -r "(s)" src/backend/ | wc -l
831
If this is not a must do now, I prefer to use the old way because we
don't have to repeat 2 times the constant.
> 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().
I have explained this choice in my first message:
"I have chosen to add a new field, const char *warning_message, to
struct ClientConnectionInfo so that it can be used to send other
messages to the client at end of connection (
src/backend/utils/init/postinit.c: InitPostgres() ). Not sure sure that
this is the best way to do that but as it is a message dedicated to the
connection I've though it could be the right place. If we don't expect
other warning message sent to the client at connection time, just using
an integer for the number of days remaining will be enough. We could use
notice but it is not logged by default and also I think that warning is
the good level for this message. "
--
Gilles Darold
http://hexacluster.ai/
view thread (27+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Pasword expiration warning
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox