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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers