Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vlU7x-00CuCF-1H for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Jan 2026 15:40:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vlU7p-00A6O6-1n for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Jan 2026 15:40:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vlU7o-00A6Ny-2r for pgsql-hackers@lists.postgresql.org; Thu, 29 Jan 2026 15:40:05 +0000 Received: from 4.mo576.mail-out.ovh.net ([46.105.42.102]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vlU7j-002wWE-02 for pgsql-hackers@lists.postgresql.org; Thu, 29 Jan 2026 15:40:02 +0000 Received: from director3.ghost.mail-out.ovh.net (unknown [10.110.0.157]) by mo576.mail-out.ovh.net (Postfix) with ESMTP id 4f23HH3nQCz5wkp for ; Thu, 29 Jan 2026 15:39:55 +0000 (UTC) Received: from ghost-submission-7d8d68f679-g6hcj (unknown [10.110.118.225]) by director3.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 3A175C088B for ; Thu, 29 Jan 2026 15:39:55 +0000 (UTC) Received: from darold.net ([37.59.142.105]) by ghost-submission-7d8d68f679-g6hcj with ESMTPSA id v6iXAkt/e2mZogkA72SrkA (envelope-from ) for ; Thu, 29 Jan 2026 15:39:55 +0000 Authentication-Results:garm.ovh; auth=pass (GARM-105G0067c7ab0c9-606d-47d7-98a2-2ef3b40a28c7, 0999A824C40F323C13D32124FEF93155D3D7C273) smtp.auth=gilles@darold.net X-OVh-ClientIp:90.38.194.7 Content-Type: multipart/alternative; boundary="------------gcpGKpSzAKvTmo1aNC5e0tEO" Message-ID: Date: Thu, 29 Jan 2026 16:39:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Pasword expiration warning To: pgsql-hackers@lists.postgresql.org References: <129bcfbf-47a6-e58a-190a-62fc21a17d03@migops.com> <7aa9c67e-c423-43c4-89e8-4fbe8f5019d2@darold.net> <3002ddbd-64b5-499e-b15c-e1c1720cc356@darold.net> <94634e38-7184-42a1-b9e1-7611076e1c08@darold.net> Content-Language: en-US From: Gilles Darold Autocrypt: addr=gilles@darold.net; keydata= xsBNBEyscTYBCADOHjxbECHbFaVEA8fKAh8gtdRMKCXPhYwgrhIq+435c824l0NkxxT6xAq/ U2embiCGSBy13yVT016bzcxOnOqxgw4dJgXPE1P6RYLgjd17c5Xt7uzkbn4ChO1LOVtx+7y/ uf8GV1fiPTtnilzGQvWdXMDDTNaFbyfIsebE6rB2p47Ns0m+cj46hS22pmEWELM4RilmQ2MX X7vNZPxQ/C6SKQDgeGZSHrvw9OLzFty8yY7HnExfUmCzfN4asAH3q/lCu1YQgud84bCC6hXz Cbw/DvR7pW8QK/ej/UkNzeGUWsWX6GYDF26P3wO9Zqk5T8JixrveiCaWA/e4DR5yr2bTABEB AAHNIUdpbGxlcyBEYXJvbGQgPGdpbGxlc0BkYXJvbGQubmV0PsLAjgQTAQoAOBYhBEnFnv37 SNFcBZKyn3AqzJ89qW5hBQJfxQsiAhsjBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEHAq zJ89qW5hjXsIAI53R1IdrgOia4DCtL1hK3+nbqPYYAhHAbQa54V/oHFEuXubH5F+mEBRT12M XNibbPvOCVUHTa46CuYLyBY6GZZ83fYpPZ3IQIavCDiLmpANR7rOoVmGERKs8VLVnQuJ1a+q BObwo1WKOFiqR1UEeT3hfytsmJVan8l2GzNFA+OOwIGEPdLLEpuS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PqdmA7lZxv0NCXeJAT2Iz6lGxXbaHwjVumo5d8wOeJW4y3U/Dp4DdXW2jUn9+PQT76YcPokU/XP+wsLuQxppdIJ6QhUPDZrT98k8naUSepBqPrqE2qazIg8HCVFazUJH1nqGeFE9juclpSjkS7QdUEGT/2OxiqG+2kLPfp1pCFBSgnb7N5HupdADIUZU9CnqyqidWvwPBoTyFFwnxkN4+zTgaAzbIDoVUCpidKjsGqoGPI3EL6BwcfePHTKJS5nMhlzME3oGY+51zaZw7EvY/9pIsCR3h7G75xHg6WFjMRMKl+i+qbh13Ls+YNkWVvave707mlkXEU4ADoiYN32L6XYOgBNrxZAm+lEpV1L0geS7FgVJJ/f6J8r9rAo6kDZDbsI/fAeZBGJANb55vQcJ+nXVij3IxGhB23QIBmXE40PySHCHNjnntvuEmyBTRgyTJUaP2NsCVCaOTEzGaZkqoSJAJ+csOChnr9qz8YR3a/n5sWJtXMpWSDLLJJ3NTetjCeyksCSUG4FZh95OmsmxPMOcVWyNwMc5xu2RWYuARxDa3sI6oMO19UwGNhvni11eL5vcSGc3qLdRq7Q DKIM-Signature: a=rsa-sha256; bh=EBTLXALe/kqTPW/9Wt55cQis3briPY9enyb6J5fbiZ4=; c=relaxed/relaxed; d=darold.net; h=From; s=ovhmo452075-selector1; t=1769701195; v=1; b=JNAERGAuvcmLs3RxuwCwujRYkcDwz8ziJKodDvBy8sP+oeauMmrDpSA//ZmqTbKW6PKyGQf6 KRXojMGabXlL9KJkcfvcW4G8i8A5VsMVPu7yZHuCZ8XSrgwSRyaaviLkusVSm1annmxlHwxAD+C vproXlHEDEKT0CZ0vI+Hfr37nosfA9wF4sOIblrlqE62B8MMLDQoqOdUyaGPl9PVexbclOEi1O5 96D3bxZQEIHa4eQqrTln7iIoD2Wh3ue2iUX86M1Ua3BrgErePk3o5Obe/szrYvUXNG5MrNqDrn9 oLeaMHdO1DgANS0imUzmnEFsonoViZwuzXpra/W7bVoUw== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------gcpGKpSzAKvTmo1aNC5e0tEO Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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/ --------------gcpGKpSzAKvTmo1aNC5e0tEO Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
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/
--------------gcpGKpSzAKvTmo1aNC5e0tEO--