redacting password in SQL statement in server log - Mailing list pgsql-hackers

From Zhihong Yu
Subject redacting password in SQL statement in server log
Date
Msg-id CALNJ-vRdBH3Kp08hzgy8P28bAZcQUQXBFPD-1dRfnvE3aQB3dA@mail.gmail.com
Whole thread Raw
Responses Re: redacting password in SQL statement in server log
List pgsql-hackers
Hi,
Currently, in situation such as duplicate role creation, the server log would show something such as the following:

2022-07-22 13:48:18.251 UTC [330] STATEMENT:  CREATE ROLE test WITH LOGIN PASSWORD 'foobar';

The password itself should be redacted before logging the statement.

Here is sample output with the patch applied:

2022-07-23 23:28:20.359 UTC [16850] ERROR:  role "test" already exists
2022-07-23 23:28:20.359 UTC [16850] STATEMENT:  CREATE ROLE test WITH LOGIN PASSWORD

Please take a look at the short patch.
I know variables should be declared at the start of the func - I can do that once the approach is confirmed.

Cheers
Attachment

pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: Cleaning up historical portability baggage
Next
From: Tom Lane
Date:
Subject: Re: Cleaning up historical portability baggage