Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id E11881337B50 for ; Mon, 27 Dec 2010 12:56:55 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 47840-04 for ; Mon, 27 Dec 2010 16:56:48 +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 8C24A1337B4A for ; Mon, 27 Dec 2010 12:56:48 -0400 (AST) Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Mon, 27 Dec 2010 10:56:47 -0600 Message-Id: <4D1870EB0200002500038BBD@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Mon, 27 Dec 2010 10:56:43 -0600 From: "Kevin Grittner" To: "Omer Anson" , Subject: Re: Triggers on Stored Procedures References: In-Reply-To: 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/187 X-Sequence-Number: 36416 Omer Anson wrote: > First of all, I apologise if I am posting this in the wrong place. Not a bad place to start, I guess. If it gets into the realm of an enhancement request or proposal it might belong on -hackers, but since you're asking about how it might be done now, this is good. > I would like to implement aspect-oriented programming in SQL. To > that end, I figured I need a notification method whenever a stored > procedure is executed (If possible, with rudimentary filtering). Well, PostgreSQL doesn't have stored procedures, but it has functions, which are similar in many respects. > I have seen that this can be done with triggers for INSERT, > UPDATE, and DELETE commands, and with RULES for SELECT commands. > > My question is: Is there a way to do this to stored procedures, > without modifying the stored procedure code? You could put "pointcut" schemas ahead of "concern" schemas (both business logic and cross-cutting). The "join points" would effectively be the business logic concern functions and the "advice" would be embodied in the cross-cutting concern functions. You would just need to build a tool to create the appropriate pointcut methods to tie them together as desired, changing the searchpath locally, or specifying concern function names with schema-qualification. Of course, you could do the pointcut specification manually, one method at a time, but that's not very "enterprisy". -Kevin