Trigger (or something similar) on table rename?

From: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
To: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Trigger (or something similar) on table rename?
Date: 2018-02-15 18:52:51
Message-ID: CAD3a31X1VJgH1zE5GuVL0Ws03y7UEHe5mQxar5gv0n3gCJ=Wng@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi. I'm wondering about possibilities for taking action when a table is
renamed.

Specifically in this case, I'm using table_log, which when you use it on a
table creates a new table, sequence and index that is tied to the table
name. Of course, if the oriignal table is renamed, the other relations
aren't. So I rename table to table_old, and then create a new version of
table, but the table logging fails because of the already-existing
relations that table_log created.

I could of course rename them manually, or create a function to do it, but
that would still need to be manually invoked. I haven't really used
listen/notify--I assume it could do this, but there would need to be some
kind of process actively listening?

Something like a trigger on the table rename would be ideal for my
purposes. Anything like that possible? Thanks!

Ken

--
AGENCY Software
A Free Software data system
By and for non-profits
*http://agency-software.org/ <http://agency-software.org/>*
*https://demo.agency-software.org/client
<https://demo.agency-software.org/client>*
ken(dot)tanzer(at)agency-software(dot)org
(253) 245-3801

Subscribe to the mailing list
<agency-general-request(at)lists(dot)sourceforge(dot)net?body=subscribe> to
learn more about AGENCY or
follow the discussion.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2018-02-15 19:01:07 Re: Trigger (or something similar) on table rename?
Previous Message Meikel Bisping 2018-02-15 16:40:48 Can parallel vacuum commands lead to a lock in Postgres 10.2