And what about temporary functions? (Was: How to drop a temporary view?)

From: Vincenzo Romano <vincenzo(dot)romano(at)notorand(dot)it>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: And what about temporary functions? (Was: How to drop a temporary view?)
Date: 2012-04-20 20:05:24
Message-ID: CAHjZ2x4xf6rrX62iu-Nk4eFWE0CLnP4rC6+zC1rSYBUVNsYOAw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2012/4/20 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Vincenzo Romano <vincenzo(dot)romano(at)notorand(dot)it> writes:
>> The weirdness is that it doesn't produce any notice the first two times.
>> At the third invocation I see the notice coming out.
>
> I'd suggest tweaking the exception handler to print the error it caught;
> that would probably clarify what is happening.
>
>                        regards, tom lane

It looks like it works like this:

-- session 1
create or replace function pg_temp.f( out i int )
volatile
language plpgsql
as $l0$
begin
i := 42;
end;
$l0$;
-- session 2
create or replace function pg_temp.f( out i int )
volatile
language plpgsql
as $l0$
begin
i := 0;
end;
$l0$;
-- session 1
tmp1=# SELECT * from f();
ERROR: function f() does not exist
LINE 1: SELECT * from f();
^
HINT: No function matches the given name and argument types. You
might need to add explicit type casts.
tmp1=# SELECT * from pg_temp.f();
i
----
42
(1 row)

Time: 0,301 ms

-- session 2
tmp1=# SELECT * from f();
ERROR: function f() does not exist
LINE 1: SELECT * from f();
^
HINT: No function matches the given name and argument types. You
might need to add explicit type casts.
tmp1=# SELECT * from pg_temp.f();
i
---
0
(1 row)

Time: 0,252 ms
--

Why not using the implicit pg_temp_nnn as seen in views and tables?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Fujii Masao 2012-04-20 20:14:08 Re: pgstat wait timeout
Previous Message Magnus Hagander 2012-04-20 19:31:18 Re: pg_basebackup issues