-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi!
This is an old problem, referred to in bug #4907:
CREATE TABLE test(id INTEGER);
INSERT INTO test VALUES (1);
CREATE OR REPLACE FUNCTION test_func() returns SETOF test as $$
DECLARE res_ test;
BEGIN FOR res_ IN SELECT * FROM test LOOP RETURN NEXT res_; END LOOP;
END
$$ LANGUAGE 'plpgsql';
SELECT * FROM test_func();
ALTER TABLE test ADD COLUMN foo INTEGER;
SELECT * FROM test_func();
- -- ERROR: wrong record type supplied in RETURN NEXT
You have to run create or replace again to fix it when changing the
schema. How come it fails? Is the return type "hardcoded" when the
function is created? Is this very hard to fix? IS there a suggested
work-around?
It seems to work to change to a generic "record", but that is also more
sloppy as it is not as well typed.
Thoughts?
Palle
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJQkWwGAAoJEIhV+7FrxBJDc6wIAK0w3h7hvPT0zsu7YyviKL+f
vi/cL5f+B9NYRkXxQ4AJ5+Qr0xwODNvSFlCEoqrREcdcCAZHoEktunZtp0FTvNLQ
HJEemac23/YyUaYE5rFI7KIySxTEnpY6qQx+YkHW1OiDF4/X/XzEFYFjCa9x3jNi
BfrnmYP0MXCB0y+vXRpUn4vm8QW7o5m+hQE0nQ0Ni4xk+GHbGOh2q21WzYevOe6s
Gj4r8nDPMX1q0Sk4zmnNrUbudVx6YsEtj7ogAbGCg5KbB3ebjfj5eJdSAD9z/uCs
0ikfZt2kvDAkdbrz/uEaRhq91gkkjZR2+Tm1iEKJhedRsRBk2y554zw7esxkj/c=
=sVM9
-----END PGP SIGNATURE-----