Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement
Jim Jones <jim.jones@uni-muenster.de>
From: Jim Jones <jim.jones@uni-muenster.de>
To: Philip Alger <paalger0@gmail.com>
Cc: Andrew Dunstan <andrew@dunslane.net>, Cary Huang <cary.huang@highgo.ca>,
jian he <jian.universality@gmail.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-10-18T15:19:30Z
Lists: 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