Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement
Philip Alger <paalger0@gmail.com>
From: Philip Alger <paalger0@gmail.com>
To: jian he <jian.universality@gmail.com>
Cc: Jim Jones <jim.jones@uni-muenster.de>,
Andrew Dunstan <andrew@dunslane.net>, Cary Huang <cary.huang@highgo.ca>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-10-22T22:27:19Z
Lists: pgsql-hackers
Attachments
- v8-0001-Add-pg_get_trigger_ddl-function.patch (application/octet-stream) patch v8-0001
>
> 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