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

From: Philip Alger <paalger0(at)gmail(dot)com>
To: jian he <jian(dot)universality(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>, 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-22 22:27:19
Message-ID: CAPXBC8L-31TtFAs0XnDKeOX_u0RX+3J6jEBmge7SkR=TfnWPQA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> doc said trigger name can not be schema-qualified,
>>> we can not do:
>>> CREATE TRIGGER public.modified_a BEFORE UPDATE OF a ON main_table
>>> FOR EACH ROW WHEN (OLD.a <> NEW.a) EXECUTE PROCEDURE
>>> trigger_func('modified_a');
>>
>>
>>
>>> + nameList = textToQualifiedNameList(trgName);
>>>
>>>
> I am wondering if adding an error message if someone inserted a schema
> name would be advantageous?
>

It might be advantageous to show a `trigger name cannot be schema
qualified` error to the user. Therefore, I added the check and the tests on
v8 attached.

postgres=# SELECT pg_get_trigger_ddl('main_table', 'public.modified_a');
ERROR: trigger name cannot be schema qualified

Thanks.

--
Best,
Phil Alger

Attachment Content-Type Size
v8-0001-Add-pg_get_trigger_ddl-function.patch application/octet-stream 19.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2025-10-22 22:59:56 Re: POC: enable logical decoding when wal_level = 'replica' without a server restart
Previous Message Masahiko Sawada 2025-10-22 22:25:39 Add copyright notice to 048_vacuum_horizon_floor.pl