Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement

From: Philip Alger <paalger0(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement
Date: 2025-10-14 04:03:13
Message-ID: CAPXBC8JmfwzUrfN9jCxuX75dn-v8vPq+dvH0cPyPMXGjzBmKnA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Oct 13, 2025 at 9:28 PM jian he <jian(dot)universality(at)gmail(dot)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

Attachment Content-Type Size
v2-0001-Add-pg_get_trigger_ddl-function.patch application/octet-stream 12.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2025-10-14 04:27:23 RE: Patch for migration of the pg_commit_ts directory
Previous Message Alexander Lakhin 2025-10-14 04:00:00 Re: IO in wrong state on riscv64