Re: INOUT parameters in procedures - Mailing list pgsql-hackers

From Merlin Moncure
Subject Re: INOUT parameters in procedures
Date
Msg-id CAHyXU0wMz043mTbg-3h3HEWzPxDd_xgZ8H06XDbhh3rHXhtN4w@mail.gmail.com
Whole thread Raw
In response to Re: INOUT parameters in procedures  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: INOUT parameters in procedures  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-hackers
On Tue, Mar 20, 2018 at 10:09 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
> 2018-03-20 15:18 GMT+01:00 Merlin Moncure <mmoncure@gmail.com>:
>> >> postgres=# create or replace procedure p(a inout int default 7) as $$
>> >> begin return; end; $$ language plpgsql;
>> >> CREATE PROCEDURE
>> >> Time: 1.182 ms
>> >> postgres=# call p();
>> >>  a
>> >> ───
>> >>  0
>> >> (1 row)
>> >
>> >
>> > I wrote patch
>>
>> Confirmed this fixes the issue.
>
> Thanks for info

You're welcome.  Working with this feature some more, I noticed that:
A) you can't assign output variables with into:
CALL p(1) INTO i;  // gives syntax error

B) you can't assign via assignment
i := p(1); // gives error, 'use CALL'

C) but you *can* via execute
EXECUTE 'CALL p(1)' INTO i;  // this works!

...I'm glad 'C' works, as without that there would be no useful way to
get values out of procedures called from within other
procedures/functions as things stand today.  'A' ideally also out to
work, but I'm not sure  'B' should be expected to work since it's
really a thin layer around SELECT.   What do you think?

merlin


pgsql-hackers by date:

Previous
From: Huong Dangminh
Date:
Subject: RE: PostgreSQL 10: Segmentation fault when using GROUPING SETS withall unsortable columns
Next
From: Julian Markwort
Date:
Subject: Re: [HACKERS] [FEATURE PATCH] pg_stat_statements with plans (v02)