Re: Tracking role modification timestamps in pg_authid / pg_roles

Поиск
Список
Период
Сортировка
Искать

Re: Tracking role modification timestamps in pg_authid / pg_roles

От:
Andrew Dunstan <andrew@dunslane.net>
Дата:

On 2026-08-21 Fr 12:40 AM, Andres Freund wrote:
> Hi,
>
> On 2026-08-21 13:07:42 +1000, Gabriele Bartolini wrote:
>> I'd like to propose adding a small column to pg_authid (rollastupdated
>> timestamptz), that records when a role was last created or altered, and get
>> feedback on the idea before polishing it for a commitfest (a working
>> prototype is attached).
>>
>> Why?
>> Tools that manage PostgreSQL roles declaratively all reconcile in the same
>> way: given a desired set of roles and attributes, make the live cluster
>> match it, repeatedly and idempotently.
> My question is why this is needed for pg_authid and not any of the other
> catalogs? Adding one-off code for different catalogs one-by-one would ... not
> be likely to result in good code.
>

Is the suggestion to track modification times for all catalog objects? 
I'm not objecting, but that does seem like a pretty substantial change.


cheers


andrew


--
Andrew Dunstan
EDB: https://www.enterprisedb.com



Re: Tracking role modification timestamps in pg_authid / pg_roles

От:
Gabriele Bartolini <gabriele.bartolini@enterprisedb.com>
Дата:
Вложения:
Hi everyone,

On Fri, 21 Aug 2026 at 22:29, Gabriele Bartolini <gabriele.bartolini@enterprisedb.com> wrote:
Fair, and I should have drawn the line explicitly in the first mail rather than leaving it to be inferred. Also, to Andrew's question: no, not all catalog objects. The boundary I would propose is global objects, concretely roles, databases and, if necessary, tablespaces.

On the expectation of a lot of follow-up patches, I think the boundary can be based on event triggers: they already provide a way to get this information for other object types, and they deliberately do not fire for shared objects, which is what leaves global objects without an answer.

Happy to put together a PoC covering the three if that scope sounds reasonable.

As promised, I have created an initial proof of concept that adds a last-updated timestamp to roles, databases, and tablespaces, labelled `rolupdated`, `datupdated`, and `spcupdated`, respectively. I have attached the difference file (diff), and the pull request (PR) is also available on my GitHub fork of Postgres: https://github.com/gbartolini/postgres/pull/3.

The timestamp is updated as follows:

- CreateRole(), AlterRole(), RenameRole() and AlterRoleSet() for ALTER ROLE ... SET/RESET
- createdb(), AlterDatabase(), AlterDatabaseSet(), AlterDatabaseOwner(), AlterDatabaseRefreshColl(), movedb() and RenameDatabase()
- CreateTableSpace(), RenameTableSpace(), AlterTableSpaceOptions() and, via the generic AlterObjectOwner_internal() path, ALTER TABLESPACE ... OWNER TO

Please provide your feedback. I plan to conduct more tests inside Kubernetes and will need to build the container image once I receive confirmation that this is the correct approach.

Thanks,
Gabriele
--
Gabriele Bartolini
VP, Chief Architect, Kubernetes
enterprisedb.com / Melbourne, Australia
FAQ