And what about temporary functions? (Was: How to drop a temporary view?) - Mailing list pgsql-general

From Vincenzo Romano
Subject And what about temporary functions? (Was: How to drop a temporary view?)
Date
Msg-id CAHjZ2x4xf6rrX62iu-Nk4eFWE0CLnP4rC6+zC1rSYBUVNsYOAw@mail.gmail.com
Whole thread Raw
Responses Re: And what about temporary functions? (Was: How to drop a temporary view?)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
2012/4/20 Tom Lane <tgl@sss.pgh.pa.us>:
> Vincenzo Romano <vincenzo.romano@notorand.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?

pgsql-general by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: pg_basebackup issues
Next
From: Fujii Masao
Date:
Subject: Re: pgstat wait timeout