Lists: | pgsql-general |
---|
From: | mandjeli(at)mjesec(dot)ffzg(dot)hr (Matko Andjelinic) |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | oid or schema name of current plpgsql function |
Date: | 2005-04-28 20:37:47 |
Message-ID: | 20050428203747.GA14659@mjesec.ffzg.hr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Is there a way to know the OID of the current plpgsql function from
inside the function?
What I really need is to extract the name of the schema where the
function is stored.
--
matko
From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Matko Andjelinic <mandjeli(at)mjesec(dot)ffzg(dot)hr> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: oid or schema name of current plpgsql function |
Date: | 2005-04-29 02:51:50 |
Message-ID: | 20050429025150.GA68248@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
On Thu, Apr 28, 2005 at 10:37:47PM +0200, Matko Andjelinic wrote:
>
> Is there a way to know the OID of the current plpgsql function from
> inside the function?
I'm not aware of a way to get the current function's OID in PL/pgSQL,
but you can do it in C.
> What I really need is to extract the name of the schema where the
> function is stored.
Why do you need to know the function's schema? What are you trying
to do?
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
From: | mandjeli(at)mjesec(dot)ffzg(dot)hr (Matko Andjelinic) |
---|---|
To: | Michael Fuhr <mike(at)fuhr(dot)org> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: oid or schema name of current plpgsql function |
Date: | 2005-04-29 10:08:01 |
Message-ID: | 20050429100801.GA8942@mjesec.ffzg.hr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
On Thu, Apr 28, 2005 at 08:51:50PM -0600, Michael Fuhr wrote:
>
> I'm not aware of a way to get the current function's OID in PL/pgSQL,
> but you can do it in C.
Yeah, i know that...I was hoping it would be possible from pl/pgsql :-(
> Why do you need to know the function's schema? What are you trying
> to do?
I'm designing a logging trigger procedure that logs changes from a table
in a source schema to a table with the same name in the logging schema.
It would be cool if the location of the trigger procedure would imply
the logging schema - the location of the log table.
for example:
create schema myschema_history;
create or replace function myschema_history.log() returns trigger as '
begin
--
-- logging implementation here
--
end;
'language 'plpgsql';
create schema myschema;
create table myschema.foo (
--
-- table definition here
--
);
create trigger foo_history
before insert or update or delete on myschema.foo
for each row execute procedure myschema_history.changed();
I thought it would be really neat to imply the log schema location.
Since it's not possible to know function schema, i will probably use
trigger params:
for each row execute proceudre myschema_history.log('myschema_history');
Or, I could hard code the name inside of every instance of log() procedure. :-/
--
matko