The following patch fixes propagation of arguments to the trigger
function to child partitions both when initially creating the trigger
and when adding new partitions to a partitioned table.
The included regression test should demonstrate the problem, for clarity
repeated in slightly more readable form here:
bb=> create table parted_trig (a int) partition by list (a);
CREATE TABLE
bb=> create table parted_trig1 partition of parted_trig for values in (1);
CREATE TABLE
bb=> create or replace function trigger_notice() returns trigger as $$
bb$> declare
bb$> arg1 text = TG_ARGV[0];
bb$> arg2 integer = TG_ARGV[1];
bb$> begin
bb$> raise notice 'trigger % on % % % for % args % %', TG_NAME, TG_TABLE_NAME, TG_WHEN, TG_OP, TG_LEVEL, arg1,
arg2;
bb$> return null;
bb$> end;
bb$> $$ language plpgsql;
CREATE FUNCTION
bb=> create trigger aaa after insert on parted_trig for each row execute procedure trigger_notice('text', 1);
CREATE TRIGGER
bb=> \d parted_trig
Tabelle »public.parted_trig«
Spalte | Typ | Sortierfolge | NULL erlaubt? | Vorgabewert
--------+---------+--------------+---------------+-------------
a | integer | | |
Partitionsschlüssel: LIST (a)
Trigger:
aaa AFTER INSERT ON parted_trig FOR EACH ROW EXECUTE PROCEDURE trigger_notice('text', '1')
Anzahl Partitionen: 1 (Mit \d+ alle anzeigen.)
bb=> \d parted_trig1
Tabelle »public.parted_trig1«
Spalte | Typ | Sortierfolge | NULL erlaubt? | Vorgabewert
--------+---------+--------------+---------------+-------------
a | integer | | |
Partition von: parted_trig FOR VALUES IN (1)
Trigger:
aaa AFTER INSERT ON parted_trig1 FOR EACH ROW EXECUTE PROCEDURE trigger_notice()
Fixed:
bb=> \d parted_trig1
Tabelle »public.parted_trig1«
Spalte | Typ | Sortierfolge | NULL erlaubt? | Vorgabewert
--------+---------+--------------+---------------+-------------
a | integer | | |
Partition von: parted_trig FOR VALUES IN (1)
Trigger:
aaa AFTER INSERT ON parted_trig1 FOR EACH ROW EXECUTE PROCEDURE trigger_notice('text', '1')
Patch is against 11.4, but applies to master with minor offset.
All regression test pass.