Re: temporary functions (and other object types)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: temporary functions (and other object types)
Date: 2010-11-05 20:02:07
Message-ID: 578.1288987327@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> A customer of ours has the need for temporary functions.

You can do that now:

regression=# create function pg_temp.foo(f1 int) returns int
regression-# as 'select $1+1' language sql;
CREATE FUNCTION
regression=# select pg_temp.foo(1);
foo
-----
2
(1 row)

You do have to qualify the name explicitly:

regression=# select foo(1);
ERROR: function foo(integer) does not exist

The latter is an intentional security feature and will not get changed.

The general security risks around this make me hesitant to accept the
idea of an explicit CREATE TEMP FUNCTION syntax: it's never going to
be better than a second-class feature, so it shouldn't have a
first-class syntax.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2010-11-05 20:04:48 Re: ALTER OBJECT any_name SET SCHEMA name
Previous Message Dimitri Fontaine 2010-11-05 19:58:00 Re: ALTER OBJECT any_name SET SCHEMA name