-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
If you create an event trigger on the partitioned table (main table) then events are generated (for all partitions) but they are not delivered.
This is because the table name value is coming from the Postgres variable TG_TABLE_NAME in the trigger function: https://github.com/hasura/graphql-engine/blob/master/server/src-rsr/trigger.sql.shakespeare and this reports the partition name and not the main table. When the event is subsequently picked for delivery then either the table is not found (if the partition is untracked) or the event trigger definition is not found on the table (since no even trigger is defined on the partition).
Repro:
CREATE TABLE measurement (
city_id int not null,
logdate date not null,
peaktemp int,
unitsales int
) PARTITION BY RANGE (logdate);
CREATE TABLE measurement_y2006m02 PARTITION OF measurement
FOR VALUES FROM ('2006-02-01') TO ('2006-03-01');
CREATE TABLE measurement_y2006m03 PARTITION OF measurement
FOR VALUES FROM ('2006-03-01') TO ('2006-04-01');
Track measurement and add an event trigger for insert.
Insert some values like (1, '2006-02-10', 30, 100). Note the error in logs:
{"type":"event-trigger","timestamp":"2020-11-26T14:25:06.348+0000","level":"error","detail":{"path":"$","error":"table '"measurement_y2006m03"' not found","code":"unexpected"}}
And if you track the partition measurement_y2006m03 then
{"type":"event-trigger","timestamp":"2020-11-26T14:37:07.825+0000","level":"error","detail":{"path":"$","error":"event trigger 'test_trigger' on table '"measurement_y2006m03"' not found","code":"unexpected"}}