mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-06 22:27:28 +08:00
Fix plpython's handling of functions used as triggers on multiple tables.
plpython tried to use a single cache entry for a trigger function, but it needs a separate cache entry for each table the trigger is applied to, because there is table-dependent data in there. This was done correctly before 9.1, but commit 46211da1b84bc3537e799ee1126098e71c2428e8 broke it by simplifying the lookup key from "function OID and triggered table OID" to "function OID and is-trigger boolean". Go back to using both OIDs as the lookup key. Per bug report from Sandro Santilli. Andres Freund
This commit is contained in:
@ -388,3 +388,21 @@ INSERT INTO composite_trigger_nested_test VALUES (NULL);
|
||||
INSERT INTO composite_trigger_nested_test VALUES (ROW(ROW(1, 'f'), NULL, 3));
|
||||
INSERT INTO composite_trigger_nested_test VALUES (ROW(ROW(NULL, 't'), ROW(1, 'f'), NULL));
|
||||
SELECT * FROM composite_trigger_nested_test;
|
||||
|
||||
-- check that using a function as a trigger over two tables works correctly
|
||||
CREATE FUNCTION trig1234() RETURNS trigger LANGUAGE plpythonu AS $$
|
||||
TD["new"]["data"] = '1234'
|
||||
return 'MODIFY'
|
||||
$$;
|
||||
|
||||
CREATE TABLE a(data text);
|
||||
CREATE TABLE b(data int); -- different type conversion
|
||||
|
||||
CREATE TRIGGER a_t BEFORE INSERT ON a FOR EACH ROW EXECUTE PROCEDURE trig1234();
|
||||
CREATE TRIGGER b_t BEFORE INSERT ON b FOR EACH ROW EXECUTE PROCEDURE trig1234();
|
||||
|
||||
INSERT INTO a DEFAULT VALUES;
|
||||
SELECT * FROM a;
|
||||
DROP TABLE a;
|
||||
INSERT INTO b DEFAULT VALUES;
|
||||
SELECT * FROM b;
|
||||
|
||||
Reference in New Issue
Block a user