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

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Philip Alger <paalger0(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 05:54:17
Message-ID: CACJufxHeP5ver0jUs13xdLsa4Xs_73TnXHi7LsOvNHCSZZpoDQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Oct 14, 2025 at 12:03 PM Philip Alger <paalger0(at)gmail(dot)com> wrote:
>
>
>
> 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.
>

select pg_get_trigger_ddl(-1, 'h');
ERROR: relation with OID 4294967295 does not exist

this error obviously is not good.
we can follow the approach used by pg_get_viewdef(oid)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2025-10-14 06:02:42 A tidyup of pathkeys.c
Previous Message Peter Smith 2025-10-14 05:44:25 Re: [WIP]Vertical Clustered Index (columnar store extension) - take2