Re: [PATCH] Add pretty formatting to pg_get_triggerdef

From: Philip Alger <paalger0(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Add pretty formatting to pg_get_triggerdef
Date: 2025-11-06 20:19:29
Message-ID: CAPXBC8JHx=BuVwvxPX19BLZHppXNAj7R2GU0cJsUHnbadAq-7Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Tom,

> This patch will cause psql's \d to fail hard against any pre-v19
> server. That's not acceptable. Note the comment at the top of
> describe.c:
>
> * Support for the various \d ("describe") commands. Note that the current
> * expectation is that all functions in this file will succeed when working
> * with servers of versions 9.2 and up. It's okay to omit irrelevant
> * information for an old server, but not to fail outright. (But failing
> * against a pre-9.2 server is allowed.)
>
>
I didn't see that at the top of the file, and didn't think the new function
would break it all.

> You could get around that with a conditional on the server version,
> as is done elsewhere in describe.c. But I kind of wonder why we
> need this new function at all. Isn't "pg_get_triggerdef(oid, false)"
> close enough?

No. That works to print out the CREATE TRIGGER statement with the
schema.relation name. I am trying to make `pretty` print similar to what is
in pg_get_viewdef and pg_get_functiondef which formats the output.

> An alternative suggestion is to keep "pg_get_triggerdef(oid, true)"
> doing exactly what it does today and have the newly-introduced
> function be the one that has new behavior. This might be a smarter
> plan anyway to avoid side-swiping other clients that are expecting
> the current behavior.
>

Thinking aloud, I would need to create a new function like
pg_get_triggerdef_worker and let it handle the formatting.

--
Best,
Phil Alger
EDB: https://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2025-11-06 20:50:59 Re: Refactor StringInfo usage in subscriptioncmds.c
Previous Message David Rowley 2025-11-06 20:06:42 Re: Some efforts to get rid of "long" in our codebase