dbTalk Databases Forums  

[BUGS] Passing composite type to function fails...

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] Passing composite type to function fails... in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Wilhelm Pakulla
 
Posts: n/a

Default [BUGS] Passing composite type to function fails... - 02-04-2004 , 12:48 PM






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 :=3D 1;
local.b :=3D 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 :=3D 1;
local.b :=3D 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 :=3D 1;
SELECT INTO r * FROM f_init1( i ); -- This works.

-- Using function with composite-type-parameter
t.a :=3D 2;
t.b :=3D 3;
SELECT INTO r * FROM f_init2( t ); -- ERROR: Row =BBt=AB does not exist.=
=20

RETURN;
END;
' LANGUAGE 'plpgsql' IMMUTABLE;

select f_test_the_functions();


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.