Passing composite type to function fails...

From: Wilhelm Pakulla <wilhelm(dot)pakulla(at)gmx(dot)de>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Passing composite type to function fails...
Date: 2004-02-04 18:39:04
Message-ID: 200402041939.04085.wilhelm.pakulla@gmx.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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();

Browse pgsql-bugs by date

  From Date Subject
Next Message pgsql-bugs 2004-02-05 11:48:20 Returned due to virus; was:Status
Previous Message pgsql-bugs 2004-02-03 22:21:44 [Magic OnLine] Suppression du Virus: Server Report