Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement
Philip Alger <paalger0@gmail.com>
From: Philip Alger <paalger0@gmail.com>
To: jian he <jian.universality@gmail.com>
Cc: pgsql-hackers@postgresql.org
Date: 2025-10-14T04:03:13Z
Lists: pgsql-hackers
Attachments
- v2-0001-Add-pg_get_trigger_ddl-function.patch (application/octet-stream) patch v2-0001
On Mon, Oct 13, 2025 at 9:28 PM jian he <jian.universality@gmail.com> wrote: > > I just did a quick test. > > src1=# SELECT pg_get_trigger_ddl(2, 'foo_trigger'); > ERROR: trigger "foo_trigger" for table "(null)" does not exist > src1=# SELECT pg_get_trigger_ddl(0, 'foo_trigger'); > ERROR: trigger "foo_trigger" for table "(null)" does not exist > > this error message is use facing, is the above error message what we > expected? > Thank you for checking that. Short answer: no. Please see v2. The latest version should take care of the (null) relation issue now, since it is checking if the OID exists for the table. I've included a test for that as well. It should return a clearer error if the relation does not exist. -- Best, Phil Alger