Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 0FDCD133740B for ; Mon, 27 Dec 2010 14:32:27 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 70728-03 for ; Mon, 27 Dec 2010 18:32:19 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gw.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by mail.postgresql.org (Postfix) with ESMTP id 7D5A9133616B for ; Mon, 27 Dec 2010 14:32:19 -0400 (AST) Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Mon, 27 Dec 2010 12:32:18 -0600 Message-Id: <4D1887520200002500038BCC@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Mon, 27 Dec 2010 12:32:18 -0600 From: "Kevin Grittner" To: "Omer Anson" , Subject: Re: Triggers on Stored Procedures Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-4.21 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201012/189 X-Sequence-Number: 36418 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 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