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

From: Marcos Pegoraro <marcos(at)f10(dot)com(dot)br>
To: Philip Alger <paalger0(at)gmail(dot)com>
Cc: Soumya S Murali <soumyamurali(dot)work(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement
Date: 2026-07-20 16:21:38
Message-ID: CAB-JLwZ+MNJXMdzBOdeFHSS7N4X8M89tu-NWqGYzbg3wqyKaAw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em seg., 20 de jul. de 2026 às 13:01, Philip Alger <paalger0(at)gmail(dot)com>
escreveu:

> I am not sure I understand. Could you provide an example, please? Thanks.
>

This patch [1] defines pg_get_table_ddl and you can see that it uses your
function to describe the structure of a table.

+ Note that <literal>trigger</literal> and <literal>policy</literal>
+ are accepted in the vocabulary but currently produce no output;
+ they are reserved for future use when standalone
+ <function>pg_get_trigger_ddl</function> and
+ <function>pg_get_policy_ddl</function> helpers become available.

So it results in something like
select pg_get_table_ddl('sch1.x'::regclass, schema_qualified => false)
CREATE TABLE x(...)
ALTER TABLE x...
CREATE CONSTRAINT yyy on x ...
CREATE INDEX idx on x...
CREATE TRIGGER ... --This one will use your function

Therefore, all results will be displayed with or without the schema name,
but the parts of the result that create the trigger will always have ?

1 -
https://www.postgresql.org/message-id/flat/CAN4CZFMYt2Q%2BntUm3Ywf-Yd22e3_HdA04TyBF4cw5o4kbDy2Kg%40mail.gmail.com#856fcec5f906a42202e1796aec6a72dc

regards
Marcos

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Srinath Reddy Sadipiralla 2026-07-20 16:47:11 Re: Fix "unexpected logical decoding status change" error; from concurrent logical decoding activation
Previous Message Paul A Jungwirth 2026-07-20 16:21:06 Re: Fix RETURNING side effects for FOR PORTION OF leftover rows