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: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Cary Huang <cary(dot)huang(at)highgo(dot)ca>, jian he <jian(dot)universality(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: 2025-10-18 20:55:41
Message-ID: CAB-JLwa1bviUf_rzyoOp81xuMeXOwvh-hwP=U0ZBfz6Y+v+hSg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em sáb., 18 de out. de 2025 às 15:23, Philip Alger <paalger0(at)gmail(dot)com>
escreveu:

There is no pretty option for this one, and the intent is for the user to
be able to input a table and trigger to get the CREATE TRIGGER statement.
Not sure how drop_first fits in here; we’re not dropping or creating
triggers.

Sorry, sometimes my fingers don't obey my brain, I wrote one thing thinking
another.
In a multi tenant world this feature will be cool for clone or sync ddl of
two schemas. So, if I’m creating a new schema the way you did works but if
both exists and I want to update some ddls of a schema, sometimes I have to
DROP and CREATE or returned command should have CREATE OR REPLACE,
depending on what ddl you are doing.
If you try to create a trigger but it already exists, you’ll get an
exception, so you can emit a DROP IF EXISTS before CREATE of that trigger.
For this that param drop_first would be.
I know you are doing only trigger ddl rigth now but I think we would have
this kind of functions for tables, constraints, triggers, domains and so
on, then all of them should work the same way, and for this a drop_first or
if_exists would be good.

Regards
Marcos

>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2025-10-18 21:15:07 Re: A tidyup of pathkeys.c
Previous Message Mankirat Singh 2025-10-18 20:48:58 Re: abi-compliance-check failure due to recent changes to pg_{clear,restore}_{attribute,relation}_stats()