Re: DO ... RETURNING

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Hannu Krosing <hannu(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: DO ... RETURNING
Date: 2013-06-10 19:23:19
Message-ID: CAFj8pRCY0KY5gi+5V0gM05gVczc5u+yoDOMw8mFH-iBRcZw+8w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2013/6/10 Hannu Krosing <hannu(at)2ndquadrant(dot)com>:
> Hallo Everybody
>
> As far as I can see, currently you can not return
> anything out of a DO (anonymous code) block.
>
> Something like
>
> DO LANGUAGE plpythonu RETURNS TABLE (name text, uid int, gid int) $$
> with open('/etc/passwd') as f:
> fields = f.readline().split(':')
> while fields:
> name, uid, gid = fields[0], int(fields[2]),int(fields[3])
> yield name, uid, gid
> fields = f.readline().split(':')
> $$;
>
> As I did not pay attention when DO was introduced,
> I thought it is faster to ask here than read all possibly
> relevant mails in archives
>
> So: has there been a discussion on extending the DO
> construct with ability to rturn data out of it, similar
> to what named functions do.
>
> If there was then what were the arguments against doing this ?
>
> Or was this just that it was not thought important at that time ?

I don't like this idea. I know so DO is +/- function, but it is too
restrict. I hope so we will have a procedures with possibility unbound
queries.

and then you can do

DO $$
SELECT * FROM pg_class;
SELECT * FROM pg_proc;
...
$$ LANGUAGE SQL;

and you don't need to define output structure - what is much more user friendly.

Regards

Pavel

>
> --
> Hannu Krosing
> PostgreSQL Consultant
> Performance, Scalability and High Availability
> 2ndQuadrant Nordic OÜ
>
>
>
> --
> 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2013-06-10 19:32:44 Re: DO ... RETURNING
Previous Message Hannu Krosing 2013-06-10 19:11:02 DO ... RETURNING