Re: Triggers on Stored Procedures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Resending because I just noticed that the list was not copied on the
rest of the exchange.  (Omer, please keep the list copied in any
future exchanges, as it tends to make the discussion available on
search engines for those who may have similar questions.)  Omer
wasn't sure about what I was proposing, so I provided this example,
which Omer said was exactly what was needed.
 
Omer Anson <oaanson@xxxxxxxxx> wrote:
 
> Did I understand you correctly?
 
A simple example would probably be good:
 
test=# create schema pointcut;
CREATE SCHEMA
test=# create schema appconcern;
CREATE SCHEMA
test=# create schema crosscutconcern;
CREATE SCHEMA
test=# set search_path to
test-# pointcut,appconcern,crosscutconcern,public;
SET
test=# create function appconcern.addints(a int, b int)
test-# returns int language sql immutable strict
test-# as 'select $1 + $2;';
CREATE FUNCTION
test=# select addints(2,3);
 addints
---------
       5
(1 row)

test=# create function crosscutconcern.notifyenterfunc(funcname
text)
test-# returns void language plpgsql immutable strict as $$
test$# begin raise notice 'entering fucntion %', funcname; end;
test$# $$;
CREATE FUNCTION
test=# create function crosscutconcern.notifyleavefunc(funcname
text)
test-# returns void language plpgsql immutable strict
test-# as $$
test$# begin raise notice 'leaving fucntion %', funcname; end;
test$# $$;
CREATE FUNCTION
test=# create or replace function pointcut.addints(a int, b int)
test-# returns int language plpgsql immutable strict
test-# as $$
test$# declare resultval int;
test$# begin
test$# perform crosscutconcern.notifyenterfunc('addints');
test$# select appconcern.addints(a, b) into resultval;
test$# perform crosscutconcern.notifyleavefunc('addints');
test$# return resultval;
test$# end;
test$# $$;
CREATE FUNCTION
test=# select addints(2,3);
NOTICE:  entering fucntion addints
CONTEXT:  SQL statement "SELECT
crosscutconcern.notifyenterfunc('addints')"
PL/pgSQL function "addints" line 4 at PERFORM
NOTICE:  leaving fucntion addints
CONTEXT:  SQL statement "SELECT
crosscutconcern.notifyleavefunc('addints')"
PL/pgSQL function "addints" line 6 at PERFORM
 addints
---------
       5
(1 row)
 
Note the unqualified reference to addints was initially the bare
appconcern function and was later wrapped with crosscutting
functions by the pointcut function of the same name.
 
-Kevin

-- 
Sent via pgsql-admin mailing list (pgsql-admin@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux