From: | Philip Alger <paalger0(at)gmail(dot)com> |
---|---|
To: | Cary Huang <cary(dot)huang(at)highgo(dot)ca> |
Cc: | jian he <jian(dot)universality(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement |
Date: | 2025-10-14 21:14:52 |
Message-ID: | CAPXBC8+PMB49hSOSCNyBNtFv_oL15Huzuk2Orv21HTPw5JAjWw@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
your documentation and the function's comment specifically say that the
> function take a trigger name and a table name, so it should not use
> regclass type, which allows OID as input as well.
>
Thanks for pointing that out in the documentation.
I think the regclass type actually makes it easier to use because you can
input a name or OID, but you're right in that it is essentially
'table_name'::regclass::oid. However, isn't the point of the regclass type
to make it easier to do table lookups? In that case, using a name seems
easier.
There is already a family of pg_get_[xxx]def functions available in
> PostgreSQL. pg_get_triggerdef() being one of them and it already can take
> OID as input and output the same text, so regclass type is not necessary.
>
True, but you have to look for the trigger OID. If you have more than one
table using the same trigger name, then you have to figure that out as
well. Using names over OIDs seems more intuitive and less error prone than
having to look up all the OIDs in my opinion. Also, having the added option
of using an OID as well shouldn't be frowned upon since that's what it's
using under the hood with regclass, but I understand what you're saying
about pg_get_triggerdef(OID) doing the same thing with the OID only.
> The term "DDL statement" may be a little misleading here, it does not
> return
> the actual DDL statements executed to create the trigger. The
> documentation for
> "pg_get_triggerdef" calls this statement as follows :
>
> "the creating command for a trigger. (This is a decompiled reconstruction,
> not the original text of the command.)"
>
True, Cary. Appreciate calling that out. I can fix that in the
documentation as well.
--
Best, Phil Alger
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Smith | 2025-10-14 21:18:15 | Re: pg_createsubscriber - more logging to say if there are no pubs to drop |
Previous Message | Tomas Vondra | 2025-10-14 21:13:07 | Re: Fix overflow of nbatch |