Created
June 12, 2015 16:08
-
-
Save rapimo/accac676f7c8e3557a4d to your computer and use it in GitHub Desktop.
rowtype cache on trigger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE foo( | |
id integer | |
); | |
CREATE FUNCTION foo_trigger() RETURNS trigger LANGUAGE plpgsql AS $_$ | |
DECLARE | |
r foo%rowtype; | |
BEGIN | |
SELECT NEW.* INTO r; | |
RETURN r; | |
END; | |
$_$; | |
CREATE TRIGGER foo AFTER INSERT ON foo FOR EACH ROW EXECUTE PROCEDURE foo_trigger(); | |
INSERT INTO foo VALUES(1); | |
ALTER TABLE foo ADD COLUMN flag boolean; | |
INSERT INTO foo VALUES(2); | |
DROP TABLE foo; | |
DROP FUNCTION foo_trigger(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
results in
ERROR: returned row structure does not match the structure of the triggering table
DETAIL: Number of returned columns (1) does not match expected column count (2).
CONTEXT: PL/pgSQL function foo_trigger() during function exit