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

From Álvaro Herrera
Subject Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement
Date
Msg-id 202510141001.f2k44sg4l66j@alvherre.pgsql
Whole thread Raw
In response to Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement  (jian he <jian.universality@gmail.com>)
List pgsql-hackers
On 2025-Oct-14, jian he wrote:

> 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)

Hmm.  For pg_get_viewdef() we have two functions:

{ oid => '1640', descr => 'select statement of a view',
  proname => 'pg_get_viewdef', provolatile => 's', proparallel => 'r',
  prorettype => 'text', proargtypes => 'text',
  prosrc => 'pg_get_viewdef_name' },

{ oid => '1641', descr => 'select statement of a view',
  proname => 'pg_get_viewdef', provolatile => 's', proparallel => 'r',
  prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_viewdef' },

one of which takes a 'name' reference the table, and the other takes
OID.  I suspect this arrangement predates the 'regclass' business ... 

   git show 52200befd0^:src/backend/utils/adt/ruleutils.c

yep, it does.  I think we wouldn't do it this way nowadays.  I think the
choice to implement pg_get_trigger_ddl(regclass) is a good one.

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"Every machine is a smoke machine if you operate it wrong enough."
https://twitter.com/libseybieda/status/1541673325781196801



pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: A tidyup of pathkeys.c
Next
From: David Rowley
Date:
Subject: Re: A tidyup of pathkeys.c