Skip to content

This patch implements the pg_get_trigger_ddl() function#3

Open
drpalaric wants to merge 1 commit intomasterfrom
dev/trigger/PG-152
Open

This patch implements the pg_get_trigger_ddl() function#3
drpalaric wants to merge 1 commit intomasterfrom
dev/trigger/PG-152

Conversation

@drpalaric
Copy link
Owner

This patch implements the pg_get_trigger_ddl() function, which emits the DDL for CREATE TRIGGER. It includes functionality comments in the code, as well as tests and documentation.

The returned function looks like the following:

postgres=# SELECT pg_get_trigger_ddl('main_table', 'modified_a');
pg_get_trigger_ddl

CREATE TRIGGER foo_trigger BEFORE UPDATE OF a ON public.main_table FOR EACH ROW WHEN ((old.a <> new.a)) EXECUTE FUNCTION trigger_func()
(1 row)

PG-152

Author: Phil Alger phil.alger@enterprisedb.com

@drpalaric drpalaric force-pushed the dev/trigger/PG-152 branch 2 times, most recently from d23377c to 6f8a7e3 Compare October 7, 2025 17:39
@drpalaric drpalaric force-pushed the dev/trigger/PG-152 branch 10 times, most recently from 7d482c0 to 4faebbc Compare October 23, 2025 00:57
@drpalaric drpalaric force-pushed the dev/trigger/PG-152 branch 4 times, most recently from 07172e3 to f124086 Compare October 30, 2025 18:22
@drpalaric drpalaric force-pushed the dev/trigger/PG-152 branch 2 times, most recently from ec19b82 to 7b1b125 Compare November 3, 2025 16:28
the DDL for CREATE TRIGGER. It includes functionality comments in the code,
as well as tests and documentation.

The returned function looks like the following:

postgres=# SELECT pg_get_trigger_ddl('bar_table', 'foo_trigger');
                                                           pg_get_trigger_ddl
-----------------------------------------------------------------------------------------------------------------------------------------
 CREATE TRIGGER foo_trigger BEFORE UPDATE OF a ON public.bar_table FOR EACH ROW WHEN ((old.a <> new.a)) EXECUTE FUNCTION trigger_func();
(1 row)

PG-152

Author: Phil Alger <paalger0@gmail.com>
drpalaric pushed a commit that referenced this pull request Jan 30, 2026
cost_tidrangescan() was setting the disabled_nodes value correctly,
and then immediately resetting it to zero, due to poor code editing on
my part.

materialized_finished_plan correctly set matpath.parent to
zero, but forgot to also set matpath.parallel_workers = 0, causing
an access to uninitialized memory in cost_material. (This shouldn't
result in any real problem, but it makes valgrind unhappy.)

reparameterize_path was dereferencing a variable before verifying that
it was not NULL.

Reported-by: Tom Lane <tgl@sss.pgh.pa.us> (issue #1)
Reported-by: Michael Paquier <michael@paquier.xyz> (issue #1)
Diagnosed-by: Lukas Fittl <lukas@fittl.com> (issue #1)
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com> (issue #2)
Reported-by: Richard Guo <guofenglinux@gmail.com> (issue #3)
Discussion: http://postgr.es/m/CAN4CZFPvwjNJEZ_JT9Y67yR7C=KMNa=LNefOB8ZY7TKDcmAXOA@mail.gmail.com
Discussion: http://postgr.es/m/aXrnPgrq6Gggb5TG@paquier.xyz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants