Re: INOUT parameters in procedures

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: INOUT parameters in procedures
Date: 2018-03-20 21:19:10
Message-ID: CAHyXU0wMz043mTbg-3h3HEWzPxDd_xgZ8H06XDbhh3rHXhtN4w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 20, 2018 at 10:09 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> 2018-03-20 15:18 GMT+01:00 Merlin Moncure <mmoncure(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Julian Markwort 2018-03-20 21:25:01 Re: [HACKERS] [FEATURE PATCH] pg_stat_statements with plans (v02)
Previous Message Huong Dangminh 2018-03-20 21:15:12 RE: PostgreSQL 10: Segmentation fault when using GROUPING SETS with all unsortable columns