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

From: Soumya S Murali <soumyamurali(dot)work(at)gmail(dot)com>
To: Philip Alger <paalger0(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement
Date: 2026-05-06 05:54:44
Message-ID: CAMtXxw8eqOd44403C162zmDF3qb4kNHvMQu7y0oNSFXjQ+mc3g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Philip,

Thank you for the clarification and feedback.

On Wed, May 6, 2026 at 3:40 AM Philip Alger <paalger0(at)gmail(dot)com> wrote:
>
>
>>
>> In support of this, I have tried testing after making a small change
>> in the function pg_get_trigger_ddl() in ruleutils.c:
>>
>> Instead of this:
>> /*Parse the trigger name to handle quoted identifiers */
>> nameList = textToQualifiedNameList(trgName);
>> if (list_length(nameList) != 1)
>> ereport(ERROR,
>> (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
>> errmsg("trigger name cannot be schema qualified")));
>> DeconstructQualifiedName(nameList, &schemaName, &objName);
>>
>
> Thanks for taking a look Soumya.
>
> I believe these DDL functions now live in ddlutils.c and include a new parameter for adding a "pretty" flag is required. I am in the middle of developing a patch for that, but I took your fix into consideration.
>

Thank you for considering my fix. I understand that the DDL-related
functions are being moved to ddlutils.c and I think introducing a new
parameter for adding "pretty" flag makes sense.

>>
>> Do: objName = text_to_cstring(trgName); to treat the trigger name
>
>
> I think this makes sense.
>
> I also will need to make a few adjustments to get the pretty printing functionality working. Since my patch essentially borrows from pg_get_triggerdef_worker, it will need some work.

I am glad that the observation regarding quoted trigger names was
useful. I’ll continue following the discussion and testing newer
versions of the patch as they evolve.

Regards,
Soumya

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ayush Tiwari 2026-05-06 06:23:38 Re: [PATCH] Clean up property graph error messages
Previous Message Ajin Cherian 2026-05-06 05:43:02 Re: [PATCH] Preserve replication origin OIDs in pg_upgrade