From: | Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Support for OUT parameters in procedures |
Date: | 2020-10-05 09:46:02 |
Message-ID: | d987da89-eafe-465e-f7c1-892c411a37d3@2ndquadrant.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-jdbc |
On 2020-09-29 08:23, Pavel Stehule wrote:
> This was an important issue if I remember well. Passing mandatory NULL
> as OUT arguments solves this issue.
> I fully agree so OUT arguments are part of the procedure's signature.
> Unfortunately, there is another difference
> from functions, but I don't think so there is a better solution, and we
> should live with it. I think it can work well.
This has been committed.
> I found one issue. The routine for selecting function or procedure based
> on signature should be fixed.
>
> CREATE OR REPLACE PROCEDURE public.procp(OUT integer)
> LANGUAGE plpgsql
> AS $procedure$
> BEGIN
> $1 := 10;
> END;
> $procedure$
>
> DO
> $$
> DECLARE n numeric;
> BEGIN
> CALL procp(n);
> RAISE NOTICE '%', n;
> END;
> $$;
> ERROR: procedure procp(numeric) does not exist
> LINE 1: CALL procp(n)
> ^
> HINT: No procedure matches the given name and argument types. You might
> need to add explicit type casts.
> QUERY: CALL procp(n)
> CONTEXT: PL/pgSQL function inline_code_block line 4 at CALL
This is normal; there is no implicit cast from numeric to int. The same
error happens if you call a function foo(int) with foo(42::numeric).
> postgres=# create or replace procedure px(anyelement, out anyelement)
> as $$
> begin
> $2 := $1;
> end;
> $$ language plpgsql;
>
> postgres=# call px(10, null);
> ERROR: cannot display a value of type anyelement
>
> but inside plpgsql it works
> do $$
> declare xx int;
> begin
> call px(10, xx);
> raise notice '%', xx;
> end;
> $$;
This might be worth further investigation, but since it happens also
with INOUT parameters, it seems orthogonal to this patch.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Bharath Rupireddy | 2020-10-05 10:45:49 | Use standard SIGHUP and SIGTERM handlers in autoprewarm module |
Previous Message | John Naylor | 2020-10-05 09:37:27 | Re: small cleanup: unify scanstr() functions |
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Cramer | 2020-10-05 10:54:23 | Fwd: Support for OUT parameters in procedures |
Previous Message | Dave Cramer | 2020-09-30 22:17:37 | [pgjdbc/pgjdbc] 01dbba: fix:remove osgi from karaf fixes Issue #1891 (#1902) |