Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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();


pgsql-bugs by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group