Re: Anonymous code block with parameters - Mailing list pgsql-hackers

From Craig Ringer
Subject Re: Anonymous code block with parameters
Date
Msg-id 5417ED7D.4070509@2ndquadrant.com
Whole thread Raw
In response to Re: Anonymous code block with parameters  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: Anonymous code block with parameters  (Heikki Linnakangas <hlinnakangas@vmware.com>)
List pgsql-hackers
On 09/16/2014 03:15 PM, Pavel Stehule wrote:

> Why we don't introduce a temporary functions instead?

I think that'd be a lot cleaner and simpler. It's something I've
frequently wanted, and as Hekki points out it's already possible by
creating the function in pg_temp, there just isn't the syntax sugar for
"CREATE TEMPORARY FUNCTION".

So why not just add "CREATE TEMPORARY FUNCTION"?


It means two steps:

CREATE TEMPORARY FUNCTION ... $$ $$;

SELECT my_temp_function(blah);

but I'm not personally convinced that a parameterised DO block is much
easier, and the idea just rings wrong to me.


I agree with Pavel that the natural way to parameterise DO blocks, down
the track, will be to allow them to get (and set?) SQL-typed session
variables. Of course, we'd need to support them first ;-)

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



pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Anonymous code block with parameters
Next
From: Heikki Linnakangas
Date:
Subject: Re: Anonymous code block with parameters