Thread: Add relcreated (timestamp) column to pg_class catalog to record the time an object was created

I am a bit confused. If this is the correct list for enhancement requests, then why is that not explicitly stated in the list description? Then again, none of the list descriptions mention they are are the correct ones for enhancement requests. However, Customer Feedback ( https://postgresql.uservoice.com/forums/21853-general ) does seem to indicate it and give positive results.
That being said, I would like to put forth a very simple enhancement request.

Add relcreated (timestamp) column to pg_class catalog to record the time an object was created.

Adding relcreated column to pg_class would facilitate auditing of when objects are created. In addition, it would also facilitate the dropping of objects that have exceeded a certain age. EG: SELECT 'DELETE TABLE ' || relname || ';' FROM pg_class WHERE relkind = 'r' AND relcreated > current_timestamp - INTERVAL ' 1 year';

There are those whom have argued that this would create a problem with table restore from pg_dump, but it does not. Simply make it an attribute of CREATE TABLE. The only requirement would be to insure that the date cannot be a future date.

--
Melvin Davidson
I reserve the right to fantasize.  Whether or not you
wish to share my fantasy is entirely up to you.

On Wednesday, April 20, 2016, Melvin Davidson <melvin6925@gmail.com> wrote:
I am a bit confused. If this is the correct list for enhancement requests, then why is that not explicitly stated in the list description? Then again, none of the list descriptions mention they are are the correct ones for enhancement requests. However, Customer Feedback ( https://postgresql.uservoice.com/forums/21853-general ) does seem to indicate it and give positive results.
That being said, I would like to put forth a very simple enhancement request.

Add relcreated (timestamp) column to pg_class catalog to record the time an object was created.

Adding relcreated column to pg_class would facilitate auditing of when objects are created. In addition, it would also facilitate the dropping of objects that have exceeded a certain age. EG: SELECT 'DELETE TABLE ' || relname || ';' FROM pg_class WHERE relkind = 'r' AND relcreated > current_timestamp - INTERVAL ' 1 year';

There are those whom have argued that this would create a problem with table restore from pg_dump, but it does not. Simply make it an attribute of CREATE TABLE. The only requirement would be to insure that the date cannot be a future date.

I'm reasonably certain nothing has changed since the last time you've made this request...

David J.
Melvin Davidson <melvin6925@gmail.com> writes:
> *I am a bit confused. If this is the correct list for enhancement requests,
> then why is that not explicitly stated in the list description?

In general, any of the major PG lists are suitable places for discussing
enhancements; either here or pgsql-hackers is most common, depending on
how much technical detail is part of the discussion.

> However, Customer Feedback (
> https://postgresql.uservoice.com/forums/21853-general
> <https://postgresql.uservoice.com/forums/21853-general> ) does seem to
> indicate it and give positive results.

I had never heard of postgresql.uservoice.com before this thread, and
I daresay most other community members had not either.  It has NO
standing or influence on our development work.

> That being said, I would like to put
> forth a very simple enhancement request.Add relcreated (timestamp) column
> to pg_class catalog to record the time an object was created.

This has been discussed, and rejected, many times before.  Please consult
the PG list archives to find previous threads about it.  I'll just note
that it *sounds* trivial, until you start thinking about backup/restore/
replication situations, and then you realize that the required semantics
are far from clear.  In practice, audit logs (which is a class of feature
that we are working on) are a far better solution.

            regards, tom lane


Tom Lane wrote:
> Melvin Davidson <melvin6925@gmail.com> writes:

> > However, Customer Feedback (
> > https://postgresql.uservoice.com/forums/21853-general
> > <https://postgresql.uservoice.com/forums/21853-general> ) does seem to
> > indicate it and give positive results.
>
> I had never heard of postgresql.uservoice.com before this thread, and
> I daresay most other community members had not either.  It has NO
> standing or influence on our development work.

Actually, to be fair, Peter Eisentraut set it up back in 2009 and
continues to keep it updated.  I thought I had seen it announced, but
now that I look, it seems he only mailed sysadmins@postgresql.org and
never any public list.  From the comments there, it's pretty obvious
that the list is helpful; the number of things marked "done" in recent
times is not small.

I'm not saying that *anything* listed there is useful.  (In particular I
don't think the "relcreated" column provides a lot of value.)

--
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services