Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement - Mailing list pgsql-hackers

From Jim Jones
Subject Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement
Date
Msg-id 9ce36292-7b03-448c-9afd-f55af05bb51c@uni-muenster.de
Whole thread Raw
In response to Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement  (Philip Alger <paalger0@gmail.com>)
Responses Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement
Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement
List pgsql-hackers

On 10/18/25 06:08, Philip Alger wrote:
> 
>  Yes, you're correct. I've added that in v6 attached.

Nice. The code now checks res for NULL, which aligns with other similar
functions, e.g. pg_get_indexdef.

if (res == NULL)
  PG_RETURN_NULL();

One nitpick:

You're probably initialising the buffer a bit too early:

...

/* Validate that the relation exists */
if (!OidIsValid(relid) || get_rel_name(relid) == NULL)
    PG_RETURN_NULL();

initStringInfo(&buf);

...

If the function is going to return NULL, there is no need to allocate
memory for buf. I guess you could place it right before the
appendStringInfo call:

initStringInfo(&buf);
appendStringInfo(&buf, "%s;", res);

Other than that, the patch LGTM. If the other reviewers have no
objections, I'll mark it as ready for committer.

Thanks for the patch.

Best, Jim





pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: abi-compliance-check failure due to recent changes to pg_{clear,restore}_{attribute,relation}_stats()
Next
From: "David E. Wheeler"
Date:
Subject: Re: abi-compliance-check failure due to recent changes to pg_{clear,restore}_{attribute,relation}_stats()