Re: How can a Postgres SQL script be automatically run when a new table turns up? - Mailing list pgsql-general

From David G. Johnston
Subject Re: How can a Postgres SQL script be automatically run when a new table turns up?
Date
Msg-id CAKFQuwajqp8PRuxWu=RQsYbh3zq+txV9hCNJpu3Y81Qhmi-z0A@mail.gmail.com
Whole thread Raw
In response to Re: How can a Postgres SQL script be automatically run when a new table turns up?  (Shaozhong SHI <shishaozhong@gmail.com>)
Responses Re: How can a Postgres SQL script be automatically run when a new table turns up?
List pgsql-general
On Thu, Jan 13, 2022 at 8:55 AM Shaozhong SHI <shishaozhong@gmail.com> wrote:
That looks interesting.  Is there an excellent example to do the following?

 How to create an event trigger in Postgres? When a user finished loading a new table on to it, the trigger can start off an script 10 minutes after the event?


IIUC when an event trigger executes it prevents the DLL (create table in this example) from committing - so the only thing the event trigger can meaningfully do is write a record to the database that tells some other piece of software to do something 10 minutes from now.  You could have a script execute every minute (say via cron) looking for such a record and when it finds one, and the time is right, it would do its thing.  Otherwise it would just stop.

David J.

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Assistance with an out of shared memory error
Next
From: "Zwettler Markus (OIZ)"
Date:
Subject: AW: [Extern] Re: postgres event trigger workaround