Re: Out parameters handling

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Dimitri Fontaine <dfontaine(at)hi-media(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Asko Oja <ascoja(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Out parameters handling
Date: 2009-03-08 06:09:02
Message-ID: 162867790903072209o4ff3f80ie974beb96e709fa2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2009/3/7 Dimitri Fontaine <dfontaine(at)hi-media(dot)com>:
> In fact, maybe a new option to set the OUT parameters prefix to use from
> within the function body would do?
>
> Le 7 mars 09 à 19:56, Dimitri Fontaine a écrit :
>>
>> CREATE OR REPLACE FUNCTION test_out
>> (
>>  IN  a integer,
>>  IN  b integer,
>>  OUT s integer
>> )
>> RETURNS setof integer
>
>  SET out_prefix TO 'v_'

-1

this is out of PL languages. There is not well enough solved access to
table out variables. Actually these variables are same as out
variables, but internally we should distinct between. For example:
PL/pgPSM don't declare it as variables - so there isn't possible any
conflict.

fragment of plpgpsm code

create or replace function test_out(a int, b int)
returns table (s int) as $$
return table(select s from some)
$$ language plpgpsm

is correct.

regards
Pavel Stehule

>> LANGUAGE PLPGSQL
>> AS $f$
>
> Those two following lines would be deprecated:
>
>> DECLARE
>>  v_s ALIAS FOR $3;
>
>
>> BEGIN
>>  FOR v_s IN SELECT generate_series(a, b)
>>  LOOP
>>   v_s := v_s * v_s;
>>   RETURN NEXT;
>>  END LOOP;
>>  RETURN;
>> END;
>> $f$;
>>
>> CREATE FUNCTION
>> dim=# SELECT * FROM test_out(2, 4);
>> s
>> ----
>>  4
>>  9
>> 16
>> (3 rows)
>
> --
> dim
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Gregory Stark 2009-03-08 12:44:08 Potential problem with HOT and indexes?
Previous Message Robert Haas 2009-03-08 05:14:44 Re: status of remaining patches