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

BUG #2108: Function with OUT parameters not recognized, using plpgsql

From: "Tony" <tony(at)vectorsalad(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #2108: Function with OUT parameters not recognized, using plpgsql
Date: 2005-12-11 23:57:05
Message-ID: 20051211235705.173CEF0B17@svr2.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-patches
The following bug has been logged online:

Bug reference:      2108
Logged by:          Tony
Email address:      tony(at)vectorsalad(dot)com
PostgreSQL version: 8.1.0
Operating system:   Debian 1:3.3.5-8ubuntu2, 2.6.10-5-k7, i686
Description:        Function with OUT parameters not recognized, using
plpgsql
Details: 

Defined a function with OUT paramter.  Attempts to call it fail as the
function can not be found.

Example:

<code>

CREATE OR REPLACE FUNCTION f_multiparam (
  i1 integer,
  i2 varchar,
  OUT o1 varchar
) AS
$$
BEGIN
  o1 := 'i2 was ' || i2;
END;
$$
LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION f_showperformstatus () RETURNS varchar AS
$$
DECLARE
  outparameter varchar;
BEGIN
  PERFORM f_multiparam(1, 'hello', outparameter);
  RETURN 'successfully run';
END;
$$
LANGUAGE plpgsql;

select f_showperformstatus();

</code>

Output:

CREATE FUNCTION
CREATE FUNCTION
psql:bug2.sql:24: ERROR:  function f_multiparam(integer, "unknown",
character varying) does not exist
HINT:  No function matches the given name and argument types. You may need
to add explicit type casts.
CONTEXT:  SQL statement "SELECT  f_multiparam(1, 'hello',  $1 )"
PL/pgSQL function "f_showperformstatus" line 4 at perform

It appears that the function is not defined properly in the system, with
only 2 parameters instead of 3:

\df f_multiparam
                           List of functions
 Schema |     Name     | Result data type  |    Argument data types
--------+--------------+-------------------+----------------------------
 apps   | f_multiparam | character varying | integer, character varying


Explicitly casting the value 'hello' as suggested does not help.  Changing
the function definition from OUT to INOUT parameter is a successful
workaround.

Responses

pgsql-bugs by date

Next:From: Micha SzelgDate: 2005-12-12 13:38:37
Subject: BUG #2109: NULL=NULL is false
Previous:From: Tony SDate: 2005-12-11 23:44:59
Subject: BUG #2107: Function INOUT parameter not returned to caller, causes plpgsql malfunctions

pgsql-patches by date

Next:From: Christopher Kings-LynneDate: 2005-12-12 01:39:20
Subject: Re: running script on server shutdown (TODO)
Previous:From: Mark KirkwoodDate: 2005-12-11 22:20:42
Subject: Re: running script on server shutdown (TODO)

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