Passing composite type to function fails...
Mahlzeit.
Is it a bug or a feature?
Wilhelm
-- Code --
CREATE TYPE t_test AS (
a INTEGER,
b INTEGER
);
CREATE FUNCTION f_init1 ( INTEGER ) RETURNS t_test AS '
DECLARE
dummy ALIAS FOR $1;
local t_test;
BEGIN
local.a := 1;
local.b := 2;
RETURN local;
END;
' LANGUAGE 'plpgsql' IMMUTABLE;
CREATE FUNCTION f_init2 ( t_test ) RETURNS t_test AS '
DECLARE
dummy ALIAS FOR $1;
local t_test;
BEGIN
local.a := 1;
local.b := 2;
RETURN local;
END;
' LANGUAGE 'plpgsql' IMMUTABLE;
CREATE FUNCTION f_test_the_functions () RETURNS void AS '
DECLARE
i INTEGER;
t t_test;
r t_test;
BEGIN
-- Using function with INTEGER-parameter
i := 1;
SELECT INTO r * FROM f_init1( i ); -- This works.
-- Using function with composite-type-parameter
t.a := 2;
t.b := 3;
SELECT INTO r * FROM f_init2( t ); -- ERROR: Row »t« does not exist.
RETURN;
END;
' LANGUAGE 'plpgsql' IMMUTABLE;
select f_test_the_functions();