Re: Anonymous code blocks

Поиск
Список
Период
Сортировка
От Dimitri Fontaine
Тема Re: Anonymous code blocks
Дата
Msg-id m2ws3uscri.fsf@hi-media.com
обсуждение исходный текст
Ответ на Anonymous code blocks (was: Re: GRANT ON ALL IN schema)  (Petr Jelinek <pjmodos@pjmodos.net>)
Ответы Re: Anonymous code blocks  (Andrew Dunstan <andrew@dunslane.net>)
Re: Anonymous code blocks  (Robert Haas <robertmhaas@gmail.com>)
Re: Anonymous code blocks  (Dimitri Fontaine <dfontaine@hi-media.com>)
Список pgsql-hackers
Hi,

Petr Jelinek <pjmodos@pjmodos.net> writes:
> I attached current version of the patch. I don't expect this to get
> committed or anything, but I'd like other eyes to take a look at it.

I'm reviewing this patch, and have early questions that might allow for
a quick returned with little feedback and much work...

Patch applies cleanly and build cleanly too, basic examples are working
fine. The problem is the following:

dim=# do $$begin select 'foo'; end;$$;
ERROR:  query has no destination for result data
HINT:  If you want to discard the results of a SELECT, use PERFORM instead.
CONTEXT:  PL/pgSQL function "inline" line 1 at SQL statement

Here's an example not so simple as to being meaningless:
 do $$ declare v text := current_setting('server_version');  begin  case when v ~ '8.5' then select 'foo'; else select
'bar';end case;  end;$$;
 

And while this works:
 dim=# do $$ declare i integer; begin for i in 1..10 loop raise notice '%', i; end loop; end;$$;

One might want to have this working too:
 do returns setof integer as $$declare i integer; begin for i in 1..10 loop return next; end;$$;

So here are the major points about this patch:
- it's missing the returns declaration syntax (default value could be  returns void?)
- it would be much more friendly to users if it had a default output  for queries, the returned object seems a good
fit

Regards,
-- 
dim

PS: I'll go mark as returned with feedback but intend to complete this
review in the following days, by having a look at the code and
documentation. Unless beaten to it, as I won't be able to give accurate
guidance for pursuing effort.


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Jeff Davis
Дата:
Сообщение: Re: operator exclusion constraints [was: generalized index constraints]
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: Anonymous code blocks