Re: Discussion: psql \et <trigger_name> -> edit the trigger function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kirk Wolak <wolakk(at)gmail(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Discussion: psql \et <trigger_name> -> edit the trigger function
Date: 2023-05-10 17:33:35
Message-ID: 908211.1683740015@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> Hmm, I wonder how useful that's really going to be, considering
> that trigger names aren't unique across tables. Wouldn't it
> need to be more like "\et table-name trigger-name"?

Different line of thought: \et seems awfully single-purpose.
Perhaps we should think more of "\st table-name trigger-name"
(show trigger), which perhaps could print something along the
lines of

CREATE TRIGGER after_ins_stmt_trig AFTER INSERT ON main_table
FOR EACH STATEMENT EXECUTE FUNCTION trigger_func('after_ins_stmt');

CREATE FUNCTION public.trigger_func()
RETURNS trigger
... the rest like \sf for the trigger function

If you indeed want to edit the function, it's a quick copy-and-paste
from here. But if you just want to see the trigger definition,
this is more wieldy than looking at the whole "\d table-name"
output. Also we have less of an overloading problem with the
command name.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2023-05-10 17:54:07 de-catalog one error message
Previous Message Bruce Momjian 2023-05-10 17:33:26 createuser --memeber and PG 16