Open
Description
Jira Link: DB-13937
Description
This is the feature supported in PG13.
Example
CREATE TABLE test_partition_trigger (
id INT,
val TEXT,
PRIMARY KEY (id)
) PARTITION BY RANGE (id);
CREATE TABLE test_partition_trigger_part1 PARTITION OF test_partition_trigger
FOR VALUES FROM (1) TO (100);
CREATE TABLE test_partition_trigger_part2 PARTITION OF test_partition_trigger
FOR VALUES FROM (100) TO (200);
CREATE OR REPLACE FUNCTION check_and_modify_val()
RETURNS TRIGGER AS $$
BEGIN
-- Check if id is even; if not, modify `val` to indicate an odd ID
IF (NEW.id % 2) <> 0 THEN
NEW.val := 'Odd ID';
END IF;
-- Return the row with modifications (if any)
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER before_insert_check
BEFORE INSERT ON test_partition_trigger
FOR EACH ROW
EXECUTE FUNCTION check_and_modify_val();
Error-
ERROR: "test_partition_trigger" is a partitioned table
DETAIL: Partitioned tables cannot have BEFORE / FOR EACH ROW triggers.
Issue Type
kind/enhancement
Warning: Please confirm that this issue does not contain any sensitive information
- I confirm this issue does not contain any sensitive information.