Re: Anonymous code block with parameters

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: Anonymous code block with parameters
Дата
Msg-id 20140916091905.GH23806@awork2.anarazel.de
обсуждение исходный текст
Ответ на Re: Anonymous code block with parameters  (Heikki Linnakangas <hlinnakangas@vmware.com>)
Список pgsql-hackers
Hi,

On 2014-09-16 10:24:52 +0300, Heikki Linnakangas wrote:
> On 09/16/2014 10:15 AM, Pavel Stehule wrote:
> >Why we don't introduce a temporary functions instead?
> 
> You can already do that:
> 
> create function pg_temp.tempfunc(i int4) returns int4 as $$ begin end; $$
> language plpgsql;

It's quite the, probably undocumented, hack though. I think it's hard to
find as a user, because it's more or less happenstance that it works. I
think we should introduce TEMPORARY properly for function, but that's a
separate patch.

> Compared to DO, you have to do extra steps to create the function, and drop
> it when you're done. And you can't use them in a hot standby, because it
> changes the catalogs. (although a better solution to that would be to make
> it work, as well as temporary tables, but that's a much bigger project).

It'd be neat, but I really don't see it happening.

> Maybe we don't need any of this, you can just use temporary function. But
> clearly someone though that DO statements are useful in general, because
> we've had temporary functions for ages and we nevertheless added the DO
> statement.

Doing a CREATE FUNCTION like that has a mighty amount of cost
associated. If you're not using the DO interactively, but
programmatically the amount of catalog and cache churn can be
problematic. So I'm in favor of adding parameters to DO.

Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



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

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: Anonymous code block with parameters
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: CRC algorithm (was Re: [REVIEW] Re: Compression of full-page-writes)