I am about to port a large database application from 7.4.x* to 8.0
(mainly to test 8.0).
There is an interesting thing I have come across:
CREATE OR REPLACE FUNCTION xy(int4) RETURNS SETOF RECORD AS ' DECLARE v_is ALIAS FOR $1;
v_loop int4; v_rec RECORD;
BEGIN v_loop := 0; SELECT INTO v_rec 0;
WHILE (v_loop < v_is) LOOP SELECT INTO v_rec v_loop;
v_loop := v_loop + 1;
RETURN NEXT v_rec; END LOOP;
RETURN NEXT v_rec; RETURN v_rec; END;
' LANGUAGE 'plpgsql';
SELECT * FROM xy(0) AS (id int4);
SELECT * FROM xy(1) AS (id int4);
This function works nicely in 7.4.x (even without the last RETURN NEXT).
8.0 returns an error.
[hs@fedora tmp]$ psql microtec -h epi < t.sql
ERROR: RETURN cannot have a parameter in function returning set; use
RETURN NEXT at or near "v_rec" at character 324
ERROR: function xy(integer) does not exist
HINT: No function matches the given name and argument types. You may
need to add explicit type casts.
ERROR: function xy(integer) does not exist
HINT: No function matches the given name and argument types. You may
need to add explicit type casts.
7.4.1 works nicely ...
[hs@fedora tmp]$ psql microtec -h epi -p 9999 < t.sql
CREATE FUNCTION id
---- 0
(1 row)
id
---- 0 0
(2 rows)
I have tried to look it up in the source code (gramy.y line 1144) but I
don't really know what the new check which has been added in 8.0 is good
for.
Can anybody give me a hint how it is supposed to be?
Regards,
Hans
--
Cybertec Geschwinde u Schoenig
Schoengrabern 134, A-2020 Hollabrunn, Austria
Tel: +43/720/10 1234567 or +43/660/816 40 77
www.cybertec.at, www.postgresql.at, kernel.cybertec.at