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

From: Kirk Wolak <wolakk(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
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-11 19:57:17
Message-ID: CACLU5mQrUypGnNZACWDtCGL8VSL6NB8T-Jgr1fZKgJRehERD7Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, May 10, 2023 at 1:33 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> 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.
>

I agree that the argument for \et or \etf fails. Simply on the one to many
issues.
And I agree that a more consistent approach is best.

Having just cleaned up 158 Triggers/Trigger Functions... Just having \eft
<TAB> work would be nice.

Which would solve my problem of quickly getting the tables triggers and
reviewing the code.

I like the idea of adding to the \s* options. As in "show".
but the "t" is very common (table, trigger, type). I think \st \str \sty
could work, but this is the first place where we would be doing this?

Honestly I think \st is "missing", especially to throw something in
dbfiddle or another tool.

And if we drop "trigger" from this, then \st and \sT where T would be for
Types as elsewhere.

Now that feels more consistent?

So, currently thinking:
1) lets get \ef? <TAB> working
2) Discuss: \st \sT for outputting Table and Type Creation DDL...

Something is telling me that #2 (\st) might be a can of worms, since it
seems so obviously "missing"?

>
> regards, tom lane
>

I appreciate the feedback!

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2023-05-11 20:04:05 Re: Overhauling "Routine Vacuuming" docs, particularly its handling of freezing
Previous Message Tom Lane 2023-05-11 19:30:22 Re: psql tests hangs